DHCP IP Allocation — How Dynamic IP Assignment Works
DHCP (Dynamic Host Configuration Protocol) automatically assigns IP addresses, subnet masks, gateways, and DNS servers to devices. Learn how the DORA process works, DHCP lease...
DHCP eliminates manual IP configuration by automatically assigning addresses from a pool. Every home router runs a DHCP server — your phone, laptop, and smart TV all use it to get their IP addresses.
Calculate subnet ranges with the Subnet Calculator.
How DHCP works: the DORA process
DORA = Discover, Offer, Request, Acknowledge
1. DISCOVER: Client broadcasts "I need an IP address"
Source: 0.0.0.0:68 (client has no IP yet)
Destination: 255.255.255.255:67 (broadcast)
Payload: MAC address, client ID
2. OFFER: DHCP server responds with an available IP
Source: 192.168.1.1:67 (router/server)
Destination: 255.255.255.255:67 (still broadcast)
Payload: Offered IP, subnet mask, gateway, DNS, lease time
3. REQUEST: Client accepts the offer (or requests renewal)
Source: 0.0.0.0:68 (still no IP until acknowledged)
Destination: 255.255.255.255:67
Payload: "I accept the offer from server 192.168.1.1, IP 192.168.1.42"
4. ACKNOWLEDGE: Server confirms the assignment
Source: 192.168.1.1:67
Destination: 255.255.255.255:67 (or unicast to offered IP)
Payload: Confirmed IP, lease duration, all options
Result: Client configures:
IP: 192.168.1.42
Mask: 255.255.255.0 (/24)
Gateway: 192.168.1.1
DNS: 8.8.8.8, 8.8.4.4
Lease: 24 hours
DHCP lease and renewal
Lease time: 24 hours (typical home router default)
Renewal at: T1 = 50% of lease (12 hours) — client sends unicast REQUEST
Rebinding at: T2 = 87.5% of lease (21 hours) — broadcast REQUEST if no response
Expiry: 100% of lease — client must start DORA again
Short lease (1 hour): Good for dynamic environments (conference WiFi, VMs)
Long lease (7 days): Good for stable devices (office desktops, servers)
Infinite lease: Only for static-like assignments via reservation
DHCP scope configuration
A scope is the pool of IPs a DHCP server can assign:
Example scope: 192.168.1.0/24
Total IPs: 256 (0-255)
Reserved:
.0 — Network address (unusable)
.1 — Gateway (router, excluded from pool)
.255 — Broadcast (unusable)
.2–.49 — Static devices (printers, NAS, servers) — excluded from pool
DHCP pool: 192.168.1.50 – 192.168.1.254 (205 addresses)
Router config (dnsmasq format):
dhcp-range=192.168.1.50,192.168.1.254,24h
dhcp-option=3,192.168.1.1 # gateway
dhcp-option=6,8.8.8.8,8.8.4.4 # DNS servers
Static DHCP reservations (DHCP + static hybrid)
A reservation assigns the same IP to a specific device (by MAC address), combining static IP reliability with DHCP management:
# dnsmasq: reserve IP by MAC address
dhcp-host=00:1A:2B:3C:4D:5E,192.168.1.10,printer
# Multiple reservations:
dhcp-host=aa:bb:cc:dd:ee:ff,192.168.1.20,nas-server
dhcp-host=11:22:33:44:55:66,192.168.1.30,media-server
// ISC DHCP server (common Linux server):
// /etc/dhcp/dhcpd.conf
/*
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
default-lease-time 86400; # 24 hours
max-lease-time 604800; # 7 days
# Static reservation:
host printer {
hardware ethernet 00:1a:2b:3c:4d:5e;
fixed-address 192.168.1.10;
}
}
*/
DHCP options
Beyond IP/mask/gateway/DNS, DHCP can send many options:
Option 3: Router (default gateway)
Option 6: DNS servers
Option 12: Hostname
Option 15: Domain name
Option 28: Broadcast address
Option 42: NTP servers
Option 43: Vendor-specific (used by WAPs, VoIP phones)
Option 51: Lease time
Option 66: TFTP server (PXE boot)
Option 67: Boot filename (PXE boot)
Option 121: Classless static routes
DHCP relay (multiple subnets)
DHCP discovers are broadcasts and don’t cross router boundaries. A DHCP relay agent forwards them to a central DHCP server:
Subnet 1: 192.168.1.0/24
Subnet 2: 192.168.2.0/24
Without relay: each subnet needs its own DHCP server
With relay: router forwards DHCP requests to 10.0.0.5 (central server)
# Linux: dhcrelay (ISC DHCP relay)
dhcrelay -i eth0 -i eth1 10.0.0.5
# The central server has scopes for both subnets:
# 192.168.1.50–254 for subnet 1
# 192.168.2.50–254 for subnet 2
DHCP vs static IP: when to use each
| Device type | Recommendation |
|---|---|
| Laptops, phones | DHCP |
| Printers | DHCP reservation (static-by-MAC) |
| Servers, NAS | Static IP (or DHCP reservation) |
| Routers, switches | Static IP |
| Docker containers | Internal bridge network DHCP |
| Kubernetes nodes | Static IP or DHCP reservation |
| IoT devices | DHCP reservation (for firewall rules) |
DHCP reservation is better than manual static: the device can still use DHCP protocol, but always gets the same IP, and the assignment is managed centrally in the DHCP server.
Related tools
- Subnet Calculator — plan your IP ranges and scopes
- IPv6 Subnetting Guide — DHCPv6 and SLAAC
- CIDR Notation Guide — understand subnet masks
Related posts
- Private IP Address Ranges, Subnets, and CIDR Notation Explained — The three RFC 1918 private ranges, what CIDR notation actually means, subnet mas…
- CIDR Notation Explained — What /24, /16, /8 Mean in IP Addresses — CIDR notation is the slash number after an IP address — /24, /16, /8. It specifi…
- IP Address Calculator — Calculate Network and Host Ranges — An IP address calculator finds the network address, broadcast address, and usabl…
- IPv6 Subnetting — Addresses, Prefixes, and Network Planning — IPv6 subnetting uses 128-bit addresses and /64 prefix lengths for LAN segments. …
- Subnet Mask Explained — How Subnetting and Network Masks Work — A subnet mask separates the network portion from the host portion of an IP addre…
Related tool
Calculate IPv4 subnets — network, broadcast, usable range, wildcard mask. Input CIDR (/24) or dotted mask (255.255.255.0). Binary visualization.
Written by Mian Ali Khalid. Part of the Dev Productivity pillar.