Web & Networking › Networking Fundamentals
DNS
The internet's phone book, turning names into IP addresses.
Also known as: Domain Name System, name resolution, domain name system
DNS (the Domain Name System) turns names people use (example.com) into the IP addresses
computers connect to (93.184.216.34). Think of it as the internet’s phone book.
When your browser opens example.com:
- It checks its own cache, then the operating system’s.
- It asks a DNS resolver (usually run by your ISP, company or a public provider).
- If the resolver doesn’t know, it asks the DNS servers in turn, from the root, to the
servers for
.com, to the servers responsible forexample.com. - The answer comes back (and is cached for a while), and the browser connects to that IP.
Seeing it for yourself
dig example.com # or: nslookup example.com
dig example.com MX # ask for a specific record type
What a developer needs to know
- Records. A domain has several:
A(name → IPv4),AAAA(IPv6),CNAME(alias to another name),MX(mail),TXT(verification, email settings). See record types. - TTL. Each answer is cached for a set time. After you change a record, old answers may live on until it expires (DNS TTL). This is why changes “take time to propagate”.
- Failures look like other things. “Could not resolve host” or
ENOTFOUNDmeans the name didn’t resolve. It’s not necessarily a server down. DNS problems are a classic cause of mysterious outages. localhostresolves locally, without asking the internet (localhost).
When a site “works for me but not for them”, or works by IP but not by name, check DNS first. DNS is easy to forget because it works until it doesn’t.