User Agents

Web browsers and everyday web tech, explained

Self-Hosted DNS: Why I Left Cloudflare

· 5 min read · How the Web Works

In this article
  1. Background: Why People Move Off Cloudflare DNS
  2. How DNS Resolution Works (Briefly)
  3. What You Need to Self-Host DNS
  4. Step-by-Step Setup (Using Unbound as an Example)
  5. Costs and Maintenance
  6. Common Problems and How to Fix Them
  7. Comparison: Self-Hosted vs. Cloudflare vs. Other Public Resolvers
  8. Security and Safety Considerations
  9. Frequently Asked Questions

Yes, you can stop trusting Cloudflare with your DNS and run your own resolver, and for many people it is a practical privacy and control upgrade. This article explains what self-hosted DNS means, how to set it up, what it costs, and where it falls short, so you can decide if it is right for you.

Background: Why People Move Off Cloudflare DNS

Cloudflare’s public resolver (1.1.1.1) is fast and free, but it still sees every domain you look up. That metadata—which sites you visit, when, and from what IP—is valuable and, for some, a privacy concern. Cloudflare publishes transparency reports and claims to delete logs within 24 hours, but you are still trusting a third party with your browsing history. Self-hosting puts that data back on hardware you control, which appeals to privacy advocates, homelab enthusiasts, and anyone who has had a bad experience with a DNS provider’s outage or policy change.

How DNS Resolution Works (Briefly)

When you type a domain like example.com, your device asks a resolver to find the IP address. The resolver queries a chain of servers: root, TLD, and authoritative. Your options are:

  • Recursive resolver – does the full lookup for you (e.g., Unbound, Knot Resolver).
  • Forwarder – sends queries to another resolver, like Cloudflare or your ISP, and caches the results (e.g., Pi-hole in forwarding mode).
  • Split-horizon – resolves internal names (like nas.local) locally and forwards everything else.

Most self-hosters run a recursive resolver to avoid sending queries to any third party, or a forwarder to keep setup simple.

What You Need to Self-Host DNS

To run your own resolver you need a device that is always on—a Raspberry Pi, an old PC, a NAS, or a cloud VPS. The software is free and open-source. The most common choices are:

  • Unbound – a lightweight, secure recursive resolver from NLnet Labs.
  • Knot Resolver – a modern, modular resolver with good performance.
  • Pi-hole – a network-wide ad blocker that can also act as a forwarder.
  • AdGuard Home – similar to Pi-hole, with a built-in DNS server and parental controls.

You will also need to configure your router to hand out your server’s IP as the DNS server via DHCP, or set it manually on each device.

Step-by-Step Setup (Using Unbound as an Example)

  1. Install Unbound on your server (e.g., sudo apt install unbound on Debian/Ubuntu).
  2. Edit /etc/unbound/unbound.conf to enable the local interface and set access control to your LAN subnet.
  3. Start the service and enable it at boot.
  4. Point your router’s DHCP settings to your server’s LAN IP.
  5. Test with dig example.com from a client to confirm it resolves.
  6. Optional: add DNSSEC validation (Unbound does this by default) and set up logging if you want to see queries.

If you prefer a forwarder, install Pi-hole and set its upstream to 1.1.1.1 or 8.8.8.8—but that still sends your queries to a third party, so it defeats the privacy purpose.

Costs and Maintenance

Self-hosting DNS is cheap in money but not in time. A Raspberry Pi costs around $50, and electricity is negligible. However, you become your own support team. You must monitor for software updates, handle certificate renewals if you use DoT/DoH, and troubleshoot when a site fails to load because your resolver returned a stale record. If your server goes down, you lose DNS for your whole network—unless you set up a secondary resolver on another device. Cloudflare’s 1.1.1.1 has a 99.99% uptime SLA; your homelab likely won’t match that.

Common Problems and How to Fix Them

The most frequent issues are:

  • Slow lookups – your resolver’s cache is cold. It warms up after a few days; you can also increase cache size.
  • Some sites don’t resolve – often a DNSSEC validation failure. Check unbound -d logs and temporarily disable DNSSEC to test.
  • Devices ignore the DNS server – some routers hardcode their own DNS; you may need to disable “DNS rebind protection” or set per-device DNS.
  • IPv6 issues – if your server has an IPv6 address, ensure your router advertises it correctly, or disable IPv6 on the resolver.
  • VPN conflicts – if you use a VPN, it may override your DNS settings; configure the VPN to use your local resolver.

Comparison: Self-Hosted vs. Cloudflare vs. Other Public Resolvers

Cloudflare 1.1.1.1 is fast, supports DNS-over-HTTPS (DoH) and DNS-over-TLS (DoT), and has a no-logs promise. Google Public DNS (8.8.8.8) is similar but logs more. Quad9 (9.9.9.9) blocks malicious domains. Self-hosted gives you:

  • Privacy – no third party sees your queries.
  • Control – you can block domains, add local records, and see exactly what is queried.
  • Learning – you understand DNS deeply.

But you lose convenience, reliability, and sometimes speed. Public resolvers have massive anycast networks that are hard to replicate at home. For most people, the trade-off is not worth it—but for a privacy-focused homelabber, it is.

Security and Safety Considerations

Running your own resolver can be safer than using your ISP’s DNS, because you control DNSSEC validation and can block known malicious domains. However, you must secure the server itself: keep it patched, disable remote access except from your LAN, and use a firewall. If you expose your resolver to the internet (e.g., on a VPS), you risk being used in DDoS amplification attacks—never do that unless you know what you are doing. Also, if you use DoH/DoT, you need to configure certificates correctly to avoid man-in-the-middle attacks.

Frequently Asked Questions

Will self-hosting DNS make my internet faster?
Probably not. Your home server has less cache and network capacity than Cloudflare’s anycast network. Lookups may be slower at first, but after a week of caching, the difference is usually negligible for normal browsing.

Do I need a static IP for my DNS server?
No, not if it’s only for your LAN. You only need a static IP if you want to access it from the internet, which is not recommended for security reasons.

Can I use Pi-hole as a recursive resolver?
Pi-hole is a forwarder by default, but you can install Unbound alongside it and set Pi-hole to use Unbound as its upstream. This gives you ad-blocking plus full recursion.

What is the difference between a recursive and a forwarding resolver?
A recursive resolver does the whole lookup from scratch, while a forwarder just sends the query to another resolver and caches the answer. Recursive is more private but slower to start; forwarding is easier but still relies on a third party.

Is it legal to run your own DNS server?
Yes, on your own network it is perfectly legal. On a VPS, you must follow the provider’s terms; some prohibit running open resolvers to prevent abuse.

What happens if my DNS server crashes?
Devices that have cached IPs will still work, but new lookups will fail. To avoid a single point of failure, run a second resolver on another device and configure your router to offer both.