Computer Networks
DHCP: automatic configuration
You plug your laptop into Wi-Fi - and it's immediately on the network. No manual settings. Behind this magic is DHCP - a protocol that automatically configures billions of devices every day.
- **Office:** An employee arrives with a laptop → automatically on the network
- **Guests:** Short lease (1 hour) for security
- **IoT:** Smart devices get IPs without manual setup
Предварительные знания
What DHCP is for
**DHCP** (Dynamic Host Configuration Protocol) is a protocol for automatic network configuration. When a device connects, the DHCP server provides it with an IP address, subnet mask, gateway, DNS - everything needed to operate on the network.
DHCP uses **UDP ports 67 (server) and 68 (client)**. It works via broadcast because the client doesn't have an IP yet for unicast.
**In a home network:** The DHCP server is built into the router. In a corporate network - a dedicated server (Windows Server, Linux dhcpd) for control and logging.
What does a DHCP server provide to a client?
DORA: 4 steps to getting an IP
**DORA** - the four steps of DHCP: Discover, Offer, Request, Acknowledge. It's a dialogue between a client with no IP and a server, entirely over broadcast.
**Why is REQUEST a broadcast?** There may be multiple DHCP servers on the network. The client picks one, and the broadcast REQUEST tells the others: "Thanks, but I chose someone else".
What is the client's IP address when it sends a DHCP Discover?
Lease and renewal
A **lease** is a temporary allocation of an IP. The client doesn't own the address permanently - it leases it for a set period. This allows addresses to be reused when devices leave the network.
**Reservation:** a MAC can be bound to an IP on the server. The device will always get the same IP, but via DHCP. Convenient for printers and servers.
What happens when 50% of the lease time (T1) is reached?
DHCP server and address pool
A **DHCP server** manages a pool of IP addresses and tracks leases. It must be on the same network as the clients, or use a **DHCP Relay** for cross-network requests.
**DHCP Snooping:** Protection against rogue DHCP servers on switches. Only ports of "trusted" servers can respond to DHCP. Important for security!
DHCP always gives the same IP
DHCP assigns an IP from the pool - it can be different each time (without a reservation)
IPs are assigned dynamically from available addresses. For a permanent IP, use a MAC reservation or static configuration.
What is DHCP Relay?
Key ideas
- **DHCP** automatically provides IP, mask, gateway, DNS
- **DORA:** Discover → Offer → Request → Acknowledge
- **Lease:** temporary IP rental (T1=50%, T2=87.5%, expire=100%)
- **Reservation:** binding MAC→IP for a permanent address
- **DHCP Relay:** forwarding requests between networks
Related topics
DHCP interacts with:
Вопросы для размышления
- What happens if there are two DHCP servers on the network with overlapping pools?
- Why is it better for servers to use static IPs or reservations?
- How can an attacker exploit a rogue DHCP server?