Configuring DNS for Your Tunnel with Cloudflare

When setting up a tunnel to expose your local services to the internet, correctly configuring DNS records is crucial for ensuring that your services are accessible via a friendly domain name. In my case, I wanted to connect my services running on a Raspberry Pi to my custom domain. Here’s how I did it using Cloudflare.

Overview

For my project, I used Cloudflare’s tunneling service to expose my Raspberry Pi’s web server to the internet. This service creates a secure tunnel from my local network to Cloudflare’s edge network, allowing me to serve content from my Pi without configuring complex firewall and NAT rules.

Step-by-Step Guide

Step 1: Create Public Hostnames

In the Cloudflare dashboard, under the tunnel configuration, you need to define your public hostnames. Here’s where you map the domain names you want to use to the local service running on your Raspberry Pi. I added two records:

Both are pointed to http://localhost:80 which is where my service is running on the Pi.

Step 2: DNS Records Update

Once the public hostnames are added, Cloudflare automatically creates corresponding DNS records in the DNS management section of your domain. In my case, CNAME records for logos.net.pl and www.logos.net.pl were created, pointing to Cloudflare’s tunnel service.

Step 3: Verify DNS Propagation

After the DNS records are in place, it’s always a good practice to verify that they have propagated correctly across the internet. You can use tools like dig or nslookup, or online services to check that the CNAME records are resolving to the correct Cloudflare addresses.

Conclusion

Setting up a tunnel and configuring DNS can seem daunting, but Cloudflare makes it relatively straightforward. Now my Raspberry Pi is accessible from anywhere securely, and I didn’t have to make any direct changes to my domain’s DNS settings outside of Cloudflare.


Remember to replace the image references with the actual paths where your images are hosted or embedded in your blog post. This guide should help you remember how to configure DNS for your tunnels in the future and can also assist others with similar setups.