Cloudflare Tunnel + Dynu Setup (Access Raspberry Pi from Anywhere)
In this post, I’ll show you how I made my **Raspberry Pi accessible from anywhere in the world** using **Cloudflare Tunnel and Dynu DDNS** – without port forwarding or a static IP. This is the exact method I use to securely access my Raspberry Pi server, TrueNAS storage, and IoT devices remotely.Why I Needed This Setup
-> My ISP (Jio AirFiber) uses a shared IP, so port forwarding doesn’t work. -> I didn’t want to pay extra for a static IP. -> I needed a secure way to access my Raspberry Pi web interfaces (Nextcloud, n8n, etc.). Cloudflare Tunnels + Dynu solved all these problems.What You’ll Need
1. A working **Raspberry Pi** (any model with Internet access). 2. A **Dynu account** (free Dynamic DNS provider). 3. A **Cloudflare account** (free plan is enough). 4. Basic knowledge of SSH and terminal commands.Step 1: Create a Dynu DDNS Domain
1. Go to Dynu.com and create a free account. 2. Add a hostname (e.g., mypiserver.dynu.net). 3. Download the Dynu client or update the IP from your router. Tip: This ensures you have a constant domain even if your ISP changes the public IP.Step 2: Add Your Domain to Cloudflare
1. Go to Cloudflare Dashboard. 2. Add your Dynu domain (e.g., mypiserver.dynu.net) to Cloudflare. 3. Change the Dynu nameservers to the Cloudflare nameservers provided. This connects your Dynu domain with Cloudflare’s powerful network.Step 3: Install Cloudflare Tunnel on Raspberry Pi
SSH into your Raspberry Pi and install Cloudflare Tunnel:
sudo apt-get install cloudflared
cloudflared tunnel login
This will open a browser window to authenticate with Cloudflare.
Step 4: Create and Run the Tunnel
Run this command to create a tunnel:cloudflared tunnel create my-pi-tunnel
Now map the tunnel to your Raspberry Pi service (e.g., a web server on port 80):
cloudflared tunnel route dns my-pi-tunnel mypiserver.dynu.net
cloudflared tunnel run my-pi-tunnel
cloudflared tunnel run my-pi-tunnel
🔗 Related: How I Turned My Raspberry Pi into a Cloud Server – Set up your own private file storage system.
Step 5: Set Tunnel to Auto-Start on Boot
To keep the tunnel running even after a reboot, add it as a service:sudo cloudflared service install
Now your Raspberry Pi will always be accessible.
Comments