task 4.1 · chapter 4 of 8: dhcp · 20 min
DORA
objective
Capture the laptop giving back its address and asking for a new one, find DHCP’s four messages, and read the options in the Offer: the address, the lease, the gateway and the DNS server.
answers/4.1.ymlopen a file in VS Code: Ctrl+P (Cmd+P on a Mac), type its name, Enter
| Capture | make capture AT=laptop:eth1 NAME=4.1 X=dhcp |
|---|---|
| Filter | dhcp |
| Your answers | answers/4.1.yml |
new to this? step by stepbeginner
make capture AT=laptop:eth1 NAME=4.1 X=dhcp, open it, filterdhcp.- Find Discover, Offer, Request, ACK. Open the Offer’s DHCP layer: Your (client) IP address, options 54 and 51.
- Challenge: options 3 and 6 in the same Offer.
- Fill in answers/4.1.yml, then
make check T=4.1.
more in meet the lab
Four messages and a lease
DORA, on the wire
Networking 101’s DHCP lesson walked through DORA, the four messages a host uses to get an address:
| Message | From → to | Says | |
|---|---|---|---|
| D | Discover | laptop → everyone | I need an address. Is there a DHCP server? |
| O | Offer | server → laptop | You can have this one, with these settings |
| R | Request | laptop → everyone | I’ll take that one, from that server |
| A | ACK | server → laptop | It’s yours, for this long |
The laptop has no IP address yet when it sends the Discover, so it sends it from 0.0.0.0 to
255.255.255.255: from nobody, to everybody. All four messages carry the same transaction ID, a random
number the laptop picked, so it can tell the answers to its own question from anyone else’s.
in one sentence DORA is four messages with one transaction ID. The first is sent from 0.0.0.0, because the laptop has no address yet.
Options: everything besides the address
The address itself is in a fixed field, Your (client) IP address. Everything else the server hands out is an option, each with a number:
| Option | What it is |
|---|---|
| 53 DHCP Message Type | which of the four messages this is |
| 54 DHCP Server Identifier | the server’s own address: the one the Request names |
| 51 IP Address Lease Time | how long the address is lent for, in seconds |
| 1 Subnet Mask | the network’s mask |
| 3 Router | the default gateway |
| 6 Domain Name Server | the DNS server(s) |
| 15 Domain Name | the name added to short names (chapter 5) |
Leases end
An address is never given for good, only leased. Halfway through the lease (option 58, the renewal time) the host asks to keep it, directly and only to the server that gave it. That’s why there’s a fifth message in your capture: before asking again, the lab makes the laptop hand its address back with a Release, also sent straight to the server.
The Offer, opened
The DHCP frames of a capture like yours:
6 1.364004043 192.168.1.175 → 192.168.2.53 DHCP 342 DHCP Release - Transaction ID 0xf279e1f
8 3.030021335 0.0.0.0 → 255.255.255.255 DHCP 342 DHCP Discover - Transaction ID 0x80ad2423
9 3.030979710 192.168.1.1 → 192.168.1.175 DHCP 342 DHCP Offer - Transaction ID 0x80ad2423
10 3.066369002 0.0.0.0 → 255.255.255.255 DHCP 342 DHCP Request - Transaction ID 0x80ad2423
11 3.067947294 192.168.1.1 → 192.168.1.175 DHCP 347 DHCP ACK - Transaction ID 0x80ad2423
And the start of the Offer’s DHCP layer (... marks lines left out):
Dynamic Host Configuration Protocol (Offer)
Message type: Boot Reply (2)
Hops: 1
Transaction ID: 0x80ad2423
...
Client IP address: 0.0.0.0
Your (client) IP address: 192.168.1.175
Next server IP address: 192.168.2.53
Relay agent IP address: 192.168.1.1
Client MAC address: aa:aa:aa:11:11:11 (aa:aa:aa:11:11:11)
...
Option: (53) DHCP Message Type (Offer)
Option: (54) DHCP Server Identifier (192.168.2.53)
Option: (51) IP Address Lease Time
IP Address Lease Time: 10 minutes (600)
Option: (58) Renewal Time Value
...
Something’s odd already: the Offer comes from 192.168.1.1, which is r1, but the server identifier says 192.168.2.53, the dns server, two hops away. And there’s a Relay agent IP address. That’s task 4.2.
Read the Offer
Capture the laptop releasing its address and asking for a new one:
run in the terminalmake capture AT=laptop:eth1 NAME=4.1 X=dhcpOpen
/captures/4.1.pcapngand filterdhcp. Find the four DORA messages, and check their transaction IDs match.Click the Offer and open its Dynamic Host Configuration Protocol layer. Find Your (client) IP address, then option 54 and option 51.
Fill in the follow-along lines:
editanswers/4.1.ymlCtrl+P → 4.1.ymloffered_ip: 192.168.1.175 # yours may be different server_id: 192.168.2.53 lease_seconds: 600Ten minutes is short; home routers usually give a day. Short leases suit networks where devices come and go, and labs where you want to watch a renewal.
The settings
From the same Offer:
router: the default gateway it hands out (option 3);dns_server: the DNS server it hands out (option 6).
Then check the laptop actually uses them: click laptop on the Topology tab, then in the laptop tab ip route and cat /etc/resolv.conf.
hint
Scroll down the options list in the details pane, or filter dhcp.option.router.
show the solutionanswers/4.1.yml
or pull it into your lab: make solve T=4.1, then git diff --staged shows what changed
router: 192.168.1.1
dns_server: 192.168.2.53
Every setting the laptop has, apart from its MAC address, came from those few bytes: its address, its mask, its gateway, its DNS server, its domain name, and how long it may keep them. When a host has an address but can’t reach anything, the Offer and the ACK are the first place to look.
5 check: run it, then prove it
$ make check T=4.1when it's right, you'll see
╭─ task 4.1 · DORA
│ ✓ captures/4.1.pcapng: taken on laptop:eth1, 12 frames
│ ✓ the capture has all four: Discover, Offer, Request, ACK
│ ✓ the address offered to the laptop (follow along): ...
│ ✓ the DHCP server's identifier, option 54 (follow along): ...
│ ✓ the lease time, in seconds (follow along): 600
│ ✓ the router (default gateway) the server hands out (challenge): ...
│ ✓ the DNS server it hands out (challenge): ...
╰─ 7/7 checks passed verified