20. DHCP
DHCPv4 DORA, TLV options, relay and snooping, server HA, DHCPv6 prefix delegation, and PXE/iPXE bootstrapping.
1. 20.1 - DHCPv4 DORA Exchange
DHCP lets a host with no address discover local configuration. The client starts from0.0.0.0:68, broadcasts to server port 67, and uses the transaction ID plus client hardware address to match the final ACK to its boot attempt.
A lease is not permanent ownership. T1 is normal renewal with the original server; T2 is rebinding when the original server may be down; after expiry the client must stop using the address.
Minimal C Demo - DORA and Renewal
2. 20.2 - DHCP Options Deep Dive
DHCP options are TLV records: one byte code, one byte length, and length bytes of data. That simple format carries routers, DNS, vendor data, PXE boot paths, relay metadata, and classless routes.
| Option | Name | Operational meaning |
|---|---|---|
| 1 / 3 / 6 | Mask / router / DNS | Basic IPv4 host configuration. |
| 43 / 60 | Vendor-specific / class | Client identifies a vendor class; server returns matching vendor payload. |
| 50 / 51 / 54 / 55 | Requested IP, lease, server ID, PRL | DORA control fields and requested option list. |
| 66 / 67 | TFTP server / bootfile | Classic PXE boot server and first bootloader filename. |
| 82 | Relay agent info | Circuit ID, remote ID, and link selection for relay or snooping policy. |
| 121 | Classless static routes | Prefix/gateway tuples; when present, it supersedes option 3 default routing logic. |
3. 20.3 - DHCP Relay Agent
Client broadcasts do not cross routers, so an SVI or router interface relays the packet to a central server. The giaddr field tells the server which client subnet should be used for scope selection.
4. 20.4 - DHCP Snooping
DHCP snooping turns the access switch into a DHCP firewall. Server messages are allowed only from trusted uplinks; successful ACKs populate a binding table that DAI and IP Source Guard reuse.
5. 20.5 - DHCP Server Implementations
| Server | Best fit | Important traits |
|---|---|---|
| ISC dhcpd | Legacy enterprise networks | Classic config file and lease log; mature but aging and single-threaded. |
| Kea DHCP | Modern enterprise and ISP | Multi-threaded, API controlled, database backends, hooks, built-in HA modes. |
| dnsmasq | SOHO, labs, containers | Small DNS plus DHCP daemon; simple, not a large enterprise lease platform. |
| Windows DHCP | Active Directory shops | GUI/admin tooling and AD authorization to reduce rogue server risk. |
| Cloud DHCP | AWS/GCP/Azure VPCs | Provider-managed link service; tenants configure options indirectly. |
6. 20.6 - DHCP HA and Failover
DHCP HA is mainly a lease-state consistency problem. MCLT limits how long one server may extend a lease without partner confirmation, preventing two servers from assigning the same address after a split.
| Mode | How clients are served | Failure behavior |
|---|---|---|
| Hot standby | Primary answers; standby synchronizes. | Standby takes over after partner failure detection. |
| Load balancing | Client hash splits requests across peers. | Surviving peer can cover the full pool after failover rules allow it. |
| Shared database | Servers use a replicated lease backend. | Depends on database consistency and write conflict handling. |
| Anycast DHCP | Nearest server receives broadcast via relay/unicast design. | Simple reachability, harder global lease synchronization. |
7. 20.7 - DHCPv6
DHCPv6 uses link-local multicast and identity associations instead of DHCPv4 broadcast fields. Stateful mode assigns addresses with IA_NA; stateless mode provides only non-address options.
Prefix delegation is the ISP and enterprise router case: the CPE receives a larger prefix and advertises or delegates smaller LAN prefixes downstream.
8. 20.8 - PXE / iPXE Boot
PXE boot begins before the machine has a local OS. DHCP supplies both the normal lease and boot metadata: option 60 identifies a PXE client, option 66 names the TFTP server, and option 67 names the bootfile.
iPXE is often chainloaded by classic PXE, then switches to HTTP or HTTPS for faster, scriptable provisioning.
Minimal C Demo - PXE Options
9. Interview Prep
Questions and concise answers
| Why does DHCP Request broadcast after receiving offers? | All servers see which offer was accepted; non-selected servers free tentative leases. |
What is giaddr? | The relay interface address used by the server to choose the correct subnet scope. |
| What does option 82 carry? | Relay metadata such as circuit ID, remote ID, and sometimes link-selection data for policy. |
| How does DHCP snooping stop rogue servers? | It drops server replies arriving on untrusted access ports and records valid ACK bindings. |
| What is IA_PD? | DHCPv6 Prefix Delegation, where a router receives a prefix and allocates downstream /64s. |
| Which DHCP options matter for PXE? | Option 60 for client class, 66 for boot server, 67 for bootfile, with option 43 for vendor-specific PXE data. |