Every time you type a web address, tap a link or open an app, your device asks a question before anything else happens: "What's the address for this name?" That question goes to the Domain Name System (DNS), and it's one of those bits of the internet that works so well most people never think about it. I didn't either, until I ran Pi-hole at home and suddenly had a list of every lookup my household made.
In this guide I'll go through what DNS is, what happens step by step when you type a web address, who's answering your lookups, and what to try when DNS goes wrong.
What is DNS?
Computers find each other using IP addresses, numbers like 203.0.113.25 (a made-up example) or a much longer IPv6 address. People are much better at remembering names like freejacktech.com. DNS is the system that turns one into the other.
The easiest way to think of it is as the internet's phone book: you look up a name and get back a number. If you're not sure what an IP address is, start with my post on IP addresses explained.
What happens when you type a web address
Say you type www.example.com into your browser. Here's what happens in the fraction of a second before the page starts to load:
- Your device checks its own memory. Your browser and your operating system both keep a short-term cache of recent answers. If you've visited the site recently, the answer is already there and the lookup stops here.
- It asks your DNS resolver. If there's no saved answer, your device asks a resolver. At home that's usually your router, which passes the question on to your broadband provider's resolver, unless you've changed it.
- The resolver asks the root servers. If the resolver hasn't got the answer cached either, it starts at the top. The root servers don't know where
www.example.comis, but they know who looks after.com. - It asks the .com servers. The top-level domain (TLD) servers for
.comdon't know the final answer either, but they know which servers are in charge ofexample.com. - It asks the site's own name servers. These are the authoritative servers for
example.com, and they give the real answer: the IP address forwww.example.com. - The answer comes back and gets cached. The resolver passes the address back to your device, and everyone along the way keeps a copy for a set time, called the TTL (time to live), so the next lookup is almost instant.
Only then does your browser connect to that IP address and ask for the page.
The main types of DNS record
You don't need to learn these to use the internet, but they're handy to recognise if you ever set up a domain or a home server:
| Record | What it does |
|---|---|
| A | Points a name at an IPv4 address |
| AAAA | Points a name at an IPv6 address |
| CNAME | Points one name at another name, like www at the main domain |
| MX | Says which servers handle email for the domain |
| TXT | Holds text, often used to prove you own a domain or to stop email spoofing |
| NS | Says which name servers are in charge of the domain |
Who's answering your DNS?
This is the question that got me interested in the first place. Whoever runs your resolver can see every name your devices look up, even if they can't see what you do on each site.
- Your broadband provider is the default for most homes, because your router uses its resolvers unless you change them.
- A public resolver like Cloudflare (
1.1.1.1), Google (8.8.8.8) or Quad9 (9.9.9.9) is the next option. Some are faster or offer extra filtering, but you're still trusting a company with your lookups. - Your own filter or resolver at home. When I ran Pi-hole on a Raspberry Pi 3B, every device in the house sent its lookups to the Pi, and it refused to answer for known ad, tracker and malware domains. Pi-hole on its own still forwarded the rest to an upstream provider, though, so I later added Unbound to Pi-hole. Unbound did the whole lookup itself, starting at the root servers, exactly like steps 3 to 5 above.
Normal DNS isn't encrypted, so whoever runs the network you're on could see your lookups if they went looking. Newer options like DNS over HTTPS (DoH), built into browsers like Chrome, Edge and Firefox, encrypt them. A VPN also hides your lookups from the local network, as long as your device uses the VPN's DNS.
DNSSEC: checking the answer is genuine
Plain DNS was designed in the 1980s, when nobody worried much about fake answers. That means a lookup can, in theory, be tampered with to send you to the wrong server. DNSSEC adds digital signatures to DNS records, so a resolver that checks them can tell whether an answer has been changed along the way. It doesn't encrypt anything, it just proves the answer is genuine.
When DNS goes wrong
A surprising number of "the internet is broken" problems are really DNS problems. The classic sign is that apps or sites won't load by name, but your connection is otherwise up. Here's what I'd try:
- Restart the device and the router. This clears out cached answers on both.
- Clear your computer's DNS cache. On Windows, open Command Prompt and run
ipconfig /flushdns. - Test the lookup yourself. On Windows,
nslookup example.comshows which server answered and what address it gave. - Try a different resolver. If your broadband provider's DNS is having a bad day, switching your device or router to a public resolver is a quick test.
- If you run Pi-hole, check it first. If the Pi is off, or has lost its IP address, nothing on the network can look anything up.
For general connection problems, my Fix Common IT Issues checklist covers the rest.
Wrapping up
DNS is the step that happens before every website, app and video loads, and once you know how it works, a lot of home networking makes more sense. If you want to see it in action, setting up Pi-hole is a great way to watch every lookup your network makes, and adding Unbound shows you the whole chain from the root servers down.