Differences

Compared

DNS vs DHCP

DHCP gives a device its settings when it joins a network: an address, the default gateway and which DNS server to ask. DNS then turns names into addresses, every time the device looks one up. DHCP tells a device where its DNS server is; DNS never hands out addresses.

Side by side

DNSDHCP
Job Turns a name into an addressGives a device its address, default gateway and resolver
Runs At every lookup; answers are cached for their TTLWhen a device joins a network, and to renew its lease
Ports UDP 53, and TCP 53UDP 67 (server) and UDP 68 (client)
Messages A question and an answerDiscover, Offer, Request, Ack
Reaches Servers anywhere, through a resolverIts own network, by broadcast; other networks through a DHCP relay
When it fails Names do not resolve; IP addresses still workThe device gets no address
Check with digudhcpc, then ip addr

Each one explained

DNS
The distributed directory that turns names like bank.lab into addresses.
DHCP
How a device gets its address, gateway and DNS server when it joins a network.
Recursive resolver
The DNS server a device asks: it does the whole search and caches the answers.
DHCP relay
A router that passes DHCP broadcasts on to a server on another network, so one server can serve many.

See the difference on real machines

Each lab is a small network of real Linux machines in your browser.

Open DNS: how a name finds its address, and why changes take time

When it breaks

Sources

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab