DNS and Domain Names
Level 3 · How data travels
How DNS finds the IP address behind a name like example.com. What a resolver does, why answers are kept for a while, and how to look one up.
Course contentsLesson 7 of 13
Level 1 · Networks and packets
Level 2 · Addresses and ports
Level 3 · How data travels
Level 4 · HTTP, the language of the web
Level 5 · Locked lines and go-betweens
After this lesson you can
- Explain what DNS does for a browser
- Look up a name with dig
- Say why a DNS change takes time to reach everyone
11 mincovers 2 glossary entries
Worth reading first: IP Addresses and Subnets
How a name becomes an IP address
DNS, the domain name system, finds the IP address behind a name. You type a name, but a packet can only go to a number. So before anything loads, your device asks DNS for the number. The answer usually comes back in a few thousandths of a second.
Your device asks a resolver, a DNS service run by your internet provider or a public one. If the resolver does not know the answer, it asks the servers that do, step by step. First it asks which servers handle .com. Then it asks those servers which ones handle example.com. Those give the final answer.
The answer is a DNS record. An A record holds the common kind of IP address. An AAAA record holds the longer IPv6 kind. Other kinds point one name at another, or say which server takes the email for a name.
Every record carries a number of seconds that says how long it may be kept. A resolver keeps the answer for that long and gives the same one to everyone who asks. That is why most lookups are almost instant. It is also why a change does not reach everyone at once.
DNS is like asking a friend for a phone number. If they know it, they tell you. If not, they ring someone who does and remember it for next time. After a while they forget, in case the number has changed.
You can ask DNS yourself. The dig command prints the records for a name. On Windows, nslookup does the same job. It is the first tool to reach for when a site works for one person and not another.
A common mistake is to change a record and expect the whole world to see it at once. A resolver that asked an hour ago may keep the old answer until its time runs out. Lower that time to a few minutes a day before a move. Raise it again once the move is done.
$ dig +short emmas-shop.com
203.0.113.10Worked example
A shop moves to a new server
Jack moves his shop to a new server with a new address. The day before, he lowers the record's time from 24 hours to 5 minutes.
On moving day he changes the A record. Within about 5 minutes, almost every visitor reaches the new server. The next day he sets the time back to 24 hours.
The words for this lesson2
Check yourself
Why does a DNS change not reach everyone straight away?
Finished this lesson?
Marking it complete also marks its 2 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.