DHCP and DNS
Follow the four DHCP steps that configure a device automatically, then see how DNS resolves names through root, TLD and authoritative servers.
Welcome back!
Step 1 of 13Learn
Configured without lifting a finger
When you join a Wi-Fi network at a hotel, your phone needs four pieces of information before it can do anything: an IP address, a subnet mask, a default gateway and the address of a DNS server. You never type any of them. A protocol called DHCP (Dynamic Host Configuration Protocol) supplies them in a fraction of a second.
DHCP works in four steps, remembered as DORA:
- Discover. The new device has no address yet, so it broadcasts: "Is there a DHCP server here?"
- Offer. A DHCP server (usually your router at home, a dedicated server in offices) replies with an available address and settings.
- Request. The device broadcasts that it accepts that offer. Broadcasting lets any other DHCP servers know their offers were declined.
- Acknowledge. The server confirms, and the device configures itself.
The address is given as a lease for a limited time, from an hour to several days. The device renews it automatically, typically when half the lease has passed. When devices leave, their addresses return to the pool for reuse.
For printers, servers and other devices that others need to find at a fixed address, admins either set a static IP outside the DHCP pool or create a DHCP reservation that always gives the same address to a specific MAC address. If two devices end up with the same address, you get an IP conflict and both behave erratically.
Step 2 of 13Practice · Put in order
Put the four DHCP messages in the order they occur.
Drag the items, or use the arrow buttons, to put them in order.
- Discover
- Request
- Acknowledge
- Offer
Step 3 of 13Diagram
DHCP in four messages (DORA)
Tap a shape with to see more.
- Discover
The new device broadcasts: "Is there a DHCP server?"
- Offer
A server proposes an address and settings.
- Request
The device asks for that offer, telling any other servers it chose this one.
- Acknowledge
The server confirms the lease: IP, mask, gateway, DNS servers and lease time.
Step 4 of 13Learn
DNS: the internet's phone book
People remember names like example.com; networks route by IP addresses like 203.0.113.10. The Domain Name System (DNS) translates between them. It is distributed across millions of servers worldwide, organized as a hierarchy read from right to left:
- The root (an invisible dot at the end:
www.example.com.) is served by 13 named root server identities, run as hundreds of copies around the world. - Top-level domains (TLDs) such as
.com,.org,.netand country codes like.ukor.de. - Second-level domains such as
exampleinexample.com, registered by organizations and people. - Subdomains such as
www,mailorshop, created freely by the domain owner.
Each domain has authoritative name servers that hold its official records. Most lookups never travel the whole tree because of caching: your browser, your operating system and your DNS resolver all remember recent answers for as long as each record's TTL (time to live, in seconds) allows. That's why a DNS change can take minutes to hours to be seen everywhere, depending on the TTL that was set.
DNS normally uses UDP port 53. Newer options encrypt lookups for privacy: DNS over HTTPS (DoH) and DNS over TLS (DoT).
Step 5 of 13Practice · Put in order
Your laptop looks up shop.example.org and nothing is cached anywhere. Put the resolution steps in order.
Drag the items, or use the arrow buttons, to put them in order.
- The resolver asks a root server, which refers it to the .org servers
- The resolver asks example.org's authoritative server, which returns the IP address
- The resolver asks a .org TLD server, which refers it to example.org's name servers
- The resolver caches the answer and returns it to the laptop
- The laptop asks its configured recursive resolver
Step 6 of 13Practice · Diagram
DNS is a tree read from right to left
Which servers hold the actual record for shop.example.org?
Tap the shape that answers the question, then press Check.
- Root (.)
Knows where every top-level domain's servers are.
- .org
- .com
- example.org
Its authoritative servers hold the zone records.
- shop.example.org
An A or AAAA record gives its address.
- www.example.org
- example.com
Step 7 of 13Learn
DNS record types
A domain's DNS zone holds records of different types. The ones you'll meet most:
| Type | Purpose | Example |
|---|---|---|
| A | name → IPv4 address | shop.example.com → 203.0.113.10 |
| AAAA | name → IPv6 address | shop.example.com → 2001:db8::10 |
| CNAME | alias pointing to another name | www.example.com → example.com |
| MX | mail servers for the domain, with priorities | example.com → 10 mail.example.com |
| TXT | free text, used for verification and email security (SPF, DKIM, DMARC) | "v=spf1 include:... -all" |
| NS | the authoritative name servers for the domain | example.com → ns1.dnshost.net |
| PTR | reverse lookup: IP address → name | 10.113.0.203.in-addr.arpa → shop.example.com |
A few practical points. A CNAME can't sit at the bare domain (example.com) alongside other records, which is why some providers offer special "alias" records there. MX records must point to a name, not directly to an IP address. And lowering a record's TTL a day before a planned server move makes the switch take effect faster.
Command-line tools let you query DNS directly: nslookup example.com works on Windows, macOS and Linux, and dig example.com (Linux and macOS) shows more detail, including the TTL. dig MX example.com asks for a specific record type.
Step 8 of 13Practice · Match the pairs
Match each DNS record type to its purpose.
Tap an answer, then tap the place where it belongs (or drag it there).
- A
- AAAA
- CNAME
- MX
- TXT
- NS
Step 9 of 13Note
Step 10 of 13Practice · Work it out
A DNS record has a TTL of 3600. You change the record at 9:00 a.m. In the worst case, how many minutes could a resolver that cached the old answer just before your change keep serving it?
Step 11 of 13Diagram
Common DNS TTL choices
Tap a shape with to see more.
- 60 s
Lowered a day or so before a planned migration so changes spread fast.
- 5 min
Records that change often, such as failover setups.
- 1 hour
A common default.
- 1 day
Stable records such as MX and NS.
Step 12 of 13Note
Step 13 of 13Practice · What would you do?
What would you do?
Employees can open websites by IP address but not by name. ipconfig /all on a PC shows the DNS server as 192.168.50.53, an old server that was retired last week. What is the best fix?
Lesson complete!