Build Local DNS in an Afternoon: Stop ISP Snooping?
In this article
- What DNS Snooping Is and Why It Matters
- How a Local DNS Server Works
- Step-by-Step: Setting Up Unbound on a Raspberry Pi
- Choosing the Right Software and Hardware
- Common Problems and How to Fix Them
- What a Local DNS Server Does NOT Do
- Costs and Maintenance
- Alternatives: VPN, Smart DNS, and Public Encrypted DNS
- Frequently Asked Questions
Yes, you can set up a local DNS server in an afternoon, and it can stop your ISP from seeing your DNS queries—but it does not hide your internet traffic. Running your own DNS resolver (like Unbound or Pi-hole) on a Raspberry Pi or an old PC is a practical weekend project that encrypts your DNS lookups and blocks ads and trackers. However, your ISP can still see the IP addresses you connect to and the amount of data you transfer, so if your goal is total privacy, you need a VPN or Tor.
What DNS Snooping Is and Why It Matters
DNS (Domain Name System) is the phonebook of the internet. When you type example.com, your device asks a DNS resolver to translate that name into an IP address. By default, your ISP provides that resolver, and it sees every domain you look up. That data can be logged, sold, or handed over to authorities. Even with HTTPS encryption on websites, the DNS query itself is often unencrypted, so your ISP (or anyone on your network) can see which sites you visit.
DNS snooping is the practice of inspecting these queries. It is not just about censorship—it is also about profiling. Your browsing history, even just the domains, reveals a lot about you. A local DNS server can encrypt those queries (using DNS-over-TLS or DNS-over-HTTPS) so your ISP sees only a stream of encrypted packets, not the domain names.
How a Local DNS Server Works
A local DNS server runs on your network and handles all DNS requests from your devices. You configure your router to point to it, or set it as the DNS server on each device. The server can be a forwarder (it sends queries to an upstream resolver) or a recursive resolver (it queries the root servers itself). For privacy, you want the upstream queries to be encrypted.
- Forwarder with encryption: Unbound or dnsmasq configured to use DNS-over-TLS with a trusted resolver like Cloudflare (1.1.1.1) or Quad9 (9.9.9.9). Your ISP sees only the connection to that resolver, not the domains.
- Recursive resolver: Unbound in recursive mode queries root servers directly. This is more private (no single upstream sees all your queries), but it is slower and can be blocked by ISPs that restrict port 53.
- Blocking server: Pi-hole acts as a DNS sinkhole, blocking ads and trackers before they load. It forwards allowed queries to an upstream resolver, ideally over encryption.
You can also run a local DNS server just for caching, which speeds up lookups, but that alone does not stop snooping—the upstream queries are still visible.
Step-by-Step: Setting Up Unbound on a Raspberry Pi
Here is a typical setup that takes about an hour, assuming you have a Raspberry Pi running Raspberry Pi OS.
- Update the system:
sudo apt update && sudo apt upgrade. - Install Unbound:
sudo apt install unbound. - Edit the config file
/etc/unbound/unbound.confto enable DNS-over-TLS and set forwarders. For example:forward-zone: name: "." forward-tls-upstream: yes forward-addr: 1.1.1.1@853#cloudflare-dns.com forward-addr: 9.9.9.9@853#dns.quad9.net
- Restart Unbound:
sudo systemctl restart unbound. - Test locally:
dig @127.0.0.1 example.com. - Change your router's DNS settings to the Pi's IP address, or set it on each device.
If you prefer Pi-hole, install it with the one-liner script from the official site. It includes a web interface and automatically configures a DNS forwarder. You can then enable DNS-over-HTTPS in Pi-hole settings.
Choosing the Right Software and Hardware
For most people, Pi-hole is the easiest choice because it is beginner-friendly and includes ad-blocking. Unbound is more flexible and can be used as a recursive resolver. dnsmasq is lightweight and good for simple caching.
Hardware requirements are modest. A Raspberry Pi Zero 2 W is enough for a home network, but a Raspberry Pi 4 or an old laptop is better if you want to run a recursive resolver or handle heavy traffic. You need a device that is always on and connected to your network.
Consider whether you want to block ads. Pi-hole does that out of the box. If you only care about privacy, Unbound with DNS-over-TLS is sufficient.
Common Problems and How to Fix Them
A frequent issue is that your router does not let you change the DNS server, or it forces its own. In that case, you can disable DHCP on the router and enable it on the Pi, or set DNS manually on each device. Another problem is that some devices (like smart TVs) ignore DNS settings and use their own. You may need to block outbound port 53 on your router to force them through your server.
If DNS-over-TLS fails, check that your firewall allows outbound TCP port 853. Some networks block it. You can fall back to DNS-over-HTTPS (port 443), which is harder to block because it looks like normal HTTPS traffic.
Performance can be an issue if your Pi is underpowered. If you see timeouts, try a faster SD card or use a USB SSD. Also, ensure your Pi is connected via Ethernet, not Wi-Fi, for reliability.
What a Local DNS Server Does NOT Do
Running a local DNS server is not a silver bullet. It does not hide your IP addresses from your ISP. When you visit a website, your device connects directly to that site's IP address, and your ISP sees that connection. It also sees the amount of data you send and receive. DNS is only the lookup step.
It also does not protect you from malware that uses hardcoded IP addresses, nor does it encrypt your actual web traffic. For that, you need HTTPS (which is standard now) and a VPN for full traffic encryption. A local DNS server is one layer of privacy, not the whole solution.
Costs and Maintenance
The cost is minimal. A Raspberry Pi costs around $35, plus an SD card and power supply. If you already have a computer running 24/7, you can run Unbound or Pi-hole in a Docker container for free. Electricity costs a few dollars per year for a Pi.
Maintenance involves updating the software regularly (sudo apt upgrade) and occasionally checking logs for issues. Pi-hole updates itself via the web interface. Unbound requires manual config changes if you want to change upstream resolvers.
If you are not comfortable with the command line, Pi-hole's web interface makes it easy. You can also buy a pre-configured device like a Raspberry Pi with Pi-hole preinstalled, but that costs more.
Alternatives: VPN, Smart DNS, and Public Encrypted DNS
If you do not want to run your own server, you can set your devices to use a public DNS resolver over TLS or HTTPS. For example, on Windows 11, you can set DNS-over-HTTPS for Cloudflare or Google. This stops your ISP from seeing your queries without any hardware. However, it means that the public resolver (like Cloudflare) sees all your queries, so you are trusting them instead of your ISP.
A VPN encrypts all your traffic, not just DNS, and hides your IP addresses from your ISP. But it adds latency and may be blocked by some services. Smart DNS is a service that only redirects DNS queries, often used for geo-unblocking, but it does not encrypt anything.
The best approach depends on your threat model. If you just want to stop your ISP from logging your DNS, a local encrypted resolver is enough. If you want to hide your browsing from your ISP entirely, use a VPN.
Frequently Asked Questions
Will a local DNS server slow down my internet?
Usually not. A local server can cache responses, making lookups faster. The encryption step adds a few milliseconds, but you will not notice it. If you run a recursive resolver, it can be slower than a forwarder because it does more work, but still acceptable for home use.
Can I use Pi-hole and Unbound together?
Yes, many people run Pi-hole as the front-end (for blocking) and Unbound as the recursive resolver behind it. This gives you both ad-blocking and full DNS privacy. Configure Pi-hole to use Unbound as its upstream DNS server.
Does this work on Windows or Mac?
You can run the DNS server on any computer, including Windows (using Unbound or Pi-hole in a VM) or a Mac. However, a Raspberry Pi is the most common and energy-efficient choice. The setup steps are similar, but you will need to install the software manually.
Will my ISP still see my DNS queries if I use DNS-over-TLS?
No, your ISP will see that you are connecting to a DNS server on port 853, but the queries themselves are encrypted. They cannot read the domain names. However, they can see the IP address of the DNS server you are using, and they can see all other traffic.
Can I use a local DNS server to bypass censorship?
It depends. If your ISP blocks specific domains at the DNS level, a local server that uses a different resolver can bypass that. But if the ISP blocks IP addresses or uses deep packet inspection, it will not help. In such cases, a VPN or Tor is more effective.
Is it legal to run my own DNS server?
In most countries, yes. You are allowed to run your own DNS server on your own network. However, some countries have laws that require ISPs to block certain domains, and using a different resolver might violate those laws. Check your local regulations.