OPNsenseXVII · DHCPDHCPv4 server
DHCP scope and pool design — address range, gateway, DNS, lease time
What you'll learn
- Size a DHCP scope to match the subnet it serves
- Choose a gateway and DNS to advertise via DHCP
- Pick a lease time appropriate to the workload
- Reserve ranges inside the subnet for static addresses, printers, network gear
- Recognise the production failure modes of an undersized or oversized pool
Prerequisites
Verified against OPNsense 25.x · FreeBSD 14.x · PF (FreeBSD packet filter) FreeBSD 14.x · Unbound 1.20+ · Kea DHCP OPNsense 25.x plugin · WireGuard in-kernel + OPNsense plugin · strongSwan (IPsec plugin) OPNsense 25.x plugin · OpenVPN 2.6.x · Suricata 7.x · 2026-08-14
A DHCP scope is the configuration the operator writes for a subnet. The pool boundaries decide which addresses can be assigned automatically; the gateway and DNS advertised via DHCP decide where clients send their traffic; the lease time decides how long a client can hold an address without renewing. A well-designed scope is invisible. A poorly-designed scope is the source of half the connectivity incidents in the production runbook.
This lesson covers the four things the operator must decide for each scope — pool, gateway, DNS, lease time — and the reserved ranges inside the subnet that keep static addressing working.
Scope boundaries
The pool boundaries are the start and end of the range the DHCP server hands out. Two principles:
- The pool must fit inside the subnet. A pool that spans two subnets (e.g.
192.168.1.100to192.168.2.200) is wrong; clients on either subnet get addresses that may not be reachable. - The pool must leave room for static addresses. Printers, network gear, servers, and any other device with a manually-assigned address need IPs that are not in the pool.
For a typical /24 subnet (192.168.1.0/24):
| Range | Purpose |
|---|---|
192.168.1.0 | Network address (unusable) |
192.168.1.1 | Firewall / gateway |
192.168.1.2 - 192.168.1.20 | Reserved for static (servers, printers, gear) |
192.168.1.21 - 192.168.1.99 | DHCP reservations (fixed-by-MAC) |
192.168.1.100 - 192.168.1.250 | DHCP pool (dynamic) |
192.168.1.251 - 192.168.1.254 | Reserved (often for HA VIPs, future use) |
192.168.1.255 | Broadcast (unusable) |
The convention varies; the discipline is to write it down, apply it, and never change it casually. The reserved range for static addressing is the part most often violated — an operator adds a new printer at 192.168.1.100 (in the pool) and a future lease hands that address to a laptop. The result is the laptop failing to communicate and the operator debugging a phantom IP conflict.
$ grep -A1 'range' /var/dhcpd/etc/dhcpd.conf | head -10subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.250;
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1;
option domain-name "lan.example.com";
default-lease-time 3600;
max-lease-time 86400;
}Illustrative output
The gateway option
The DHCP option routers (option 3) carries the default gateway the client should use. For an OPNsense firewall on the LAN at 192.168.1.1, the gateway option is 192.168.1.1.
Three things can go wrong:
- Wrong gateway. The operator configures
192.168.1.254(the old firewall’s address) and clients cannot reach the Internet. Always verify the gateway option matches the firewall’s actual LAN address. - Gateway outside the subnet. The gateway must be on the same subnet as the clients. A client on
192.168.1.0/24with a gateway of192.168.2.1cannot ARP the gateway and cannot send default-routed packets. - Multiple gateways advertised. Some operators try to advertise two gateways for redundancy. DHCP only supports one; for failover, the operator needs HA (CARP) or gateway groups.
The right answer for HA: CARP. The two firewalls share a virtual IP; DHCP advertises the CARP VIP as the gateway. Clients see one gateway; the active firewall responds.
The DNS option
The DHCP option domain-name-servers (option 6) carries the DNS servers clients should use. For an OPNsense firewall running Unbound, the typical configuration is:
- Primary DNS: the firewall’s LAN address (e.g.
192.168.1.1). Clients query Unbound, which resolves recursively. - Secondary DNS: a public resolver (e.g.
1.1.1.1or8.8.8.8) for redundancy if Unbound fails.
The two-DNS pattern is widely deployed. The discipline: the primary must respond; the secondary is a fallback that adds an external dependency. Many operators use only the firewall’s address and rely on Unbound’s reliability.
For an estate with internal DNS (Windows AD, internal-only zones), the operator points DHCP at the internal DNS server, not at the firewall. The firewall’s Unbound is configured to forward to the internal DNS for internal zones.
The domain name option
The DHCP option domain-name (option 15) carries the DNS search domain. For a LAN named lan.example.com, the option is lan.example.com. Clients append this to unqualified hostnames before querying DNS.
The option must match the actual DNS configuration. If the operator sets domain-name "lan.example.com" but the DNS server serves a different zone, clients append the wrong suffix and resolve internal hostnames incorrectly.
Lease time
Three lease-time knobs:
default-lease-time: the lease time given to a new client with no preference.max-lease-time: the longest lease the server will give, regardless of client request.min-lease-time: the shortest lease the server will give, regardless of client request.
The tradeoffs:
| Lease time | Pros | Cons |
|---|---|---|
| Short (15 min - 1 hour) | New DNS/gateway settings reach clients fast; transient clients (guests) release quickly | More DHCP traffic; more server load; more frequent renewals |
| Long (1 day - 1 week) | Less traffic; less server load | DNS or routing changes take up to the lease time to reach clients |
The right default for most production LANs: 1 hour default, 24 hours maximum. This is short enough that DNS changes propagate within an hour, long enough that the DHCP server is not overloaded.
Reserved ranges
Three ranges should be reserved inside the subnet, outside the DHCP pool:
- Static infrastructure. Firewall, switches, routers, access points, printers, servers. These have manually-assigned addresses.
- DHCP reservations. Hosts that need a fixed address (servers, monitoring agents, voice-over-IP phones). The reservation ties the address to a MAC.
- HA / future use. CARP VIPs, gateway group addresses, future subnets, monitoring tools. Keep some space free.
The reserved ranges are documented in the runbook. When the operator adds a new static device, they pick from the reserved range, not from the pool. When the operator adds a new DHCP reservation, they pick from the reserved-for-reservations range.
The discipline: the reserved ranges never overlap the pool. The pool is exactly what DHCP can hand out. Static and reservation ranges are exactly what DHCP cannot hand out.
Scope sizing
For a /24 subnet with 254 usable addresses, typical scope sizing:
| Estate size | DHCP pool size | Reserved for static | Reserved for reservations |
|---|---|---|---|
| Home / small office (10-20 devices) | 50-100 | 20 | 30 |
| Medium office (50-200 devices) | 100-150 | 30 | 50 |
| Large office (500+ devices) | 200-240 | 10 | 10 |
The pool is sized larger than the expected device count to leave headroom for guests, BYOD, and forgotten devices. A pool of 50 in a /24 is reasonable for a small office; a pool of 200 in a /24 is reasonable for a large office. The reserved ranges shrink as the pool grows; the discipline is that the reserved ranges exist and are documented.
Common scope failure modes
Five failure modes appear repeatedly:
-
Pool exhaustion. More devices than the pool can serve. Symptom: clients get APIPA addresses (169.254.x.x). Fix: expand the pool or add a second subnet.
-
Pool overlaps static addresses. The printer is at
192.168.1.100; the pool is192.168.1.50 - 192.168.1.200. Symptom: printer intermittently unreachable; clients sometimes get192.168.1.100. Fix: move the printer out of the pool range. -
Wrong subnet mask. The scope is configured with a
/16mask on a/24subnet. Symptom: clients get addresses that are not on the right segment. Fix: align the subnet mask with the actual subnet. -
Gateway typo. The gateway is set to
192.168.1.10instead of192.168.1.1. Symptom: clients can reach local hosts but not the Internet. Fix: correct the gateway. -
Lease time too long for the workload. A 7-day lease in a guest network means guests who leave keep their addresses. Symptom: pool exhaustion from stale leases. Fix: reduce the lease time for guest networks.
Summary
- A DHCP scope has four critical parameters: pool boundaries, gateway, DNS, lease time.
- The pool must fit inside the subnet and leave room for static and reserved ranges.
- The gateway must be the firewall’s LAN address; for HA, use the CARP VIP.
- Lease time tradeoffs: short leases propagate changes faster; long leases reduce server load. 1 hour default, 24 hour maximum is a sensible production default.
- Reserved ranges for static and reservations are documented and never overlap the pool.
- Verify the scope by reading
/var/dhcpd/etc/dhcpd.confafter each GUI change.
Knowledge check · 4 questions
Q1. You have a /24 subnet (192.168.1.0/24). The firewall is at 192.168.1.1. You have 5 servers, 3 printers, and 2 switches that need static IPs. You expect 30-50 dynamic clients. What is a reasonable DHCP pool?
Q2. A DHCP lease time of 7 days is appropriate for a guest network because it reduces DHCP server load and lets guests keep their IP across visits.
Q3. Which of the following are valid reasons to reserve a range of addresses inside a subnet outside the DHCP pool? Select all that apply.
Q4. An operator changes the firewall LAN address from 192.168.1.1 to 192.168.1.2 and applies the change. New clients cannot reach the Internet. What is the most likely cause?
Passing score: 75%. Answers are checked in this browser.