Cloudflare Tunnel + Dynu Setup (Access Raspberry Pi from Anywhere)

Cloudflare Tunnel + Dynu Setup (Access Raspberry Pi from Anywhere)

Published: January 01, 2025

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
Then log in:
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
Now you can visit https://mypiserver.dynu.net from anywhere!

🔗 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.

Securing Your Setup

1. Use **HTTPS only** (Cloudflare will automatically add SSL). 2. Protect sensitive web apps with Cloudflare Access (2FA login). 3. Disable default router remote management. 4. Keep your Raspberry Pi updated.

Why This Setup is Awesome

-> No port forwarding or router hacks required. -> Free and secure (Cloudflare handles SSL). -> Works even with ISPs that block inbound connections. -> Dynu keeps your domain updated automatically.

Final Words

If you want to access your Raspberry Pi or home servers from anywhere, this is the easiest and safest method. 👉 Try it yourself and let me know how it worked. 👉 Also, check my Jio AirFiber + Home Networking Setup Thanks for reading!

Comments