networking, updated

DHCP

The Dynamic Host Configuration Protocol hands out IP addresses, gateway, DNS servers and other settings to clients. Whoever answers first configures the client, which is why rogue DHCP servers are dangerous.

OSI layer
7 Application
Carried in
UDP
Ports
67/udp (server), 68/udp (client), 546/547 udp (DHCPv6)
Specs
RFC 2131, RFC 2132, RFC 8415
Wireshark filter
dhcp
Encrypted
no

Packet structure

DHCP message240 bytes + variable

Select a field to see what it does.

RFC 2131 (format inherited from BOOTP). 240 bytes fixed incl. magic cookie, then options; the message type is option 53. The long sname and file fields are drawn shortened.

Wireshark still calls the protocol bootp in older versions (filter bootp before 3.0).

How it works

The four-message exchange is called DORA:

sequenceDiagram
    participant C as Client 0.0.0.0
    participant S as DHCP server
    C->>S: DISCOVER (broadcast to 255.255.255.255:67)
    S-->>C: OFFER yiaddr=10.0.0.50, router, DNS, lease
    C->>S: REQUEST (broadcast, names the chosen server, option 54)
    S-->>C: ACK (lease confirmed)
    Note over C: Renew at 50 % of the lease (unicast), rebind at 87.5 % (broadcast)

Before using the address, many clients send an ARP probe to check nobody else has it.

Relays: DHCP broadcasts do not cross routers. A relay agent (ip helper-address) forwards them as unicast to the central server and fills in giaddr and often option 82 (switch and port).

Other messages: RELEASE (client gives the address back), DECLINE (address already in use), NAK (server refuses, e.g. wrong subnet), INFORM (client has an address and only wants options).

In Wireshark

FilterShows
dhcpAll DHCP (bootp in Wireshark 2.x)
dhcp.option.dhcp == 1Discovers (2 Offer, 3 Request, 5 ACK, 6 NAK)
dhcp.option.dhcp == 2Offers: who answers as server?
dhcp.hw.mac_addr == aa:bb:cc:dd:ee:ffOne client
dhcp.option.hostnameClient host names
dhcp.option.request_list_itemParameter request list (OS fingerprint)
dhcp.option.type == 252WPAD offers
dhcp.option.type == 121Classless static routes
dhcpv6DHCPv6

What normal looks like: Offers and ACKs only from your DHCP servers or relays, one DORA per client per boot, renewals at half the lease time. Offers from an unknown source are a rogue server, by accident (home router) or on purpose.

Security notes

References

§ home
~/knubertus/home/
1,1 Top