Hone

Lessons · IT support · DNS and how a name is found

DNS: a name is looked up in a fixed order

Machines talk in addresses; people type names. DNS turns the name into the address, and a name is looked up in order: the local cache first, then the hosts file, then the DNS server the machine was given, which asks upward until something knows. The first place with an answer wins, even if it is wrong.

Hone is a place to practise a career, one idea a day. This is one of its lessons, written out in full and free to read without an account.

What it is for

The intranet moved to a new server at lunchtime. Half the building reaches it; the other half gets the old page, or nothing. Nobody's cable moved. Half the building has the old address in its cache and the other half asked fresh. Knowing the order tells you to flush the cache on one machine, watch it come right, and write the article.

How to think about it

If the address works and the name does not, it is DNS. Ask the name with nslookup and read two things: which server answered and what it said. A wrong answer from the right server means the record is wrong; a right answer with a still-failing program means a stale cache on the machine; no answer means the machine cannot reach its DNS server, which is a network fault wearing a DNS coat.

Worked example

Browser: 'intranet' cannot be found. ping 10.4.10.20 → reply
The address works. The name does not. The fault is at the name layer.
nslookup intranet → server 10.4.0.5 → answer 10.4.10.20
The DNS server is reached and gives the right address. So the server is not the fault.
Local cache shows intranet → 10.4.10.7 (the old server)
Stale. The cache is checked before the server, so the right answer never gets asked for.
Flush the cache, retry: intranet opens
One change, verified. The cache will now hold the new address until its time-to-live runs out.

Your turn

Write the first place a machine looks when it is given a name to resolve.

name → local  → hosts file → DNS server

The trap

Restarting the DNS server because one machine cannot resolve a name. Test the name from a second machine first. If the second one resolves, the server is fine and the fault is in the first machine's cache or its settings.

Practise DNS and how a name is found on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.