DHCP
Automatic host configuration: address, mask, gateway, DNS, lease.
Level: beginner
What is it?
Dynamic Host Configuration Protocol (DHCP) automatically supplies network configuration such as an IP address, subnet mask/prefix, default gateway, DNS resolvers, and lease timing. DHCPv4 commonly uses UDP ports 67 and 68 and the discover-offer-request-acknowledge exchange.
Why does it matter?
Manual addressing does not scale well and creates conflicting configurations. DHCP centralizes allocation and reduces mistakes, while leases allow addresses to be reused when clients leave.
Mental model
Think of DHCP as a time-limited address lease from a network administrator. A client requests configuration, a server offers a lease, the client requests it, and the server confirms the parameters.
How it works
- The familiar DHCPv4 DORA sequence is Discover, Offer, Request, Acknowledge.
- A lease has a duration; clients renew before expiry under the protocol's timing rules.
- DHCP options convey more than the address itself, including gateway and DNS configuration.
- A rogue or compromised DHCP server can give malicious gateway or resolver settings.
- DHCP broadcasts stay within their local broadcast domain unless a relay forwards requests to a server elsewhere.
Steps
- A new client joins a LAN without a usable IPv4 configuration.
- It broadcasts DHCP Discover; one or more servers may send Offers.
- The client requests one offered configuration and the chosen server sends an Acknowledgement.
- The client configures its interface and later renews the lease as needed.
Real-world usage
- Investigating a host with no address, wrong gateway, or wrong DNS server.
- Understanding DHCP relay in multi-subnet networks.
- Planning address pools, reservations, lease periods, and conflict handling.
Common mistakes
- Assuming DHCP itself resolves human-readable hostnames; DNS does that.
- Assuming a DHCP offer proves the server is trusted.
- Checking only the assigned IP and ignoring the mask, gateway, DNS, lease, and duplicate-address state.
Interview questions
What does DORA stand for in DHCPv4?
Discover, Offer, Request, Acknowledge.
Why use a DHCP relay?
It forwards client DHCP messages across a routed boundary to a server, because local broadcasts do not normally cross routers.