Skip to main content
RunBook Academy

OPNsenseI · Networking Foundations for Firewall AdministratorsLayer 2 and Layer 3 foundations

DHCP for the firewall operator

Foundation⏱ ~12 mintcpdumpdhcpdump

What you'll learn

  • Describe the four-step DORA exchange
  • Configure DHCP scopes, pools and reservations on OPNsense
  • Plan DHCP relay across VLANs
  • Identify common DHCP failure modes in production

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

Not yet marked complete on this device.

Most firewall operators have configured DHCP at some point. Few have thought carefully about what happens when DHCP is broken. This lesson covers DHCP at the depth the operator needs to debug the production failures.

The DORA exchange

DHCPv4 uses a four-step exchange: Discover, Offer, Request, Acknowledge.

Client                                          Server (OPNsense)
  | --- DHCP Discover (broadcast) ----------->       |
  | <-- DHCP Offer 192.0.2.50, lease 1h, GW .1 ---   |
  | --- DHCP Request 192.0.2.50 --------------->     |
  | <-- DHCP Acknowledge, lease confirmed -----      |

The Discover is a broadcast — every DHCP server on the segment hears it. The Offer comes back unicast from the server that wins. The client Request is a broadcast to tell every server who offered “I picked this one”. The Acknowledge completes the lease.

For DHCP to work across a router (which does not forward broadcasts by default), you need a DHCP relay. The relay agent on the router side receives the broadcast, unicasts it to the configured DHCP server, and unicasts the response back to the client. OPNsense can be either the DHCP server or the relay agent (under Services → DHCPv4 → Relay).

Lease lifecycle

A DHCP lease has three timings:

  • Default lease time — how long a fresh lease is given (typically one hour).
  • Maximum lease time — the longest lease the server will give (typically one day or one week).
  • Renewal (T1) — when the client first attempts to renew (default: 50% of the lease time).
  • Rebinding (T2) — when the client broadcasts to any server (default: 87.5% of the lease time).

The firewall operator’s choice of lease time matters. Short leases (15 minutes, 1 hour) are good for transient clients (guests, DHCP-by-MAC rollouts) but generate more traffic and stress the server. Long leases (1 week, 30 days) reduce load but mean new DNS or routing changes take longer to reach clients.

Reservations and static mappings

A reservation (also called “static mapping” in OPNsense) is a permanent DHCP lease tied to a MAC address. The client still uses DHCP, but the server always gives it the same IP.

Reservations are the right tool when:

  • A server needs a fixed IP for documentation, firewall rules, monitoring, or external DNS.
  • The network manager wants central control of IP assignments rather than configuring every host’s network stack.

Reservations are not the right tool when:

  • The host moves between networks (laptops) — use a regular lease.
  • The MAC address is unpredictable (some virtualisation environments generate new MACs on every boot) — the reservation will not match.

DHCPv6 — a different protocol

DHCPv6 is not an extension of DHCPv4; it is a different protocol. The same OPNsense service handles both, but the message exchange, ports, and lease semantics are different.

The relevant differences:

AspectDHCPv4DHCPv6
Default portsUDP 67 (server), 68 (client)UDP 547 (server), 546 (client)
Lease confirmationAcknowledge (unicast)Reply (solicit/advertise/request/reply)
IdentityMAC addressDUID (DHCP Unique Identifier)
Required vs informationalAlways issues an addressCan be stateful (assign) or stateless (inform only, address from SLAAC)

DHCPv6 uses DUID, not MAC, as the stable identifier. A DUID is built from a timestamp + MAC (DUID-LL) or from an opaque identifier chosen by the host at install time. The operator who copies a host’s MAC and uses it for a DHCPv6 reservation will be disappointed — the host identifies itself by DUID, not MAC.

Common DHCP failure modes

SymptomMost likely cause
Clients get no IPDHCP service is not running on the firewall, or the firewall is blocking DHCP from the LAN (UDP 67/68)
Clients get a 169.254.x.x addressNo DHCP response reached the client. Check the service is up, the interface has the right IP, and no firewall rule is blocking the broadcast
Clients get an IP but wrong gatewayThe DHCP scope is bound to the wrong interface or subnet
Clients get an IP but cannot reach the InternetMost often an outbound NAT issue — see the NAT parts of this course
Reservations don’t take effectThe MAC entered is wrong (case-insensitive but format matters: aa:bb:cc:11:22:33 vs aa-bb-cc-11-22-33)
DHCPv6 reservations don’t workThe host is identified by DUID, not MAC — get the DUID from the client’s lease query
Existing clients don’t see changesThey have an old lease — wait for renewal or force release/renew

Knowledge check · 3 questions

  1. Q1. A VLAN is on 10.10.10.0/24 with the firewall at 10.10.10.1 and a Linux server on the VLAN. The server should get a fixed IP via DHCP reservation but keeps getting 10.10.10.50. The MAC in the reservation is correct. What is the most likely cause?

  2. Q2. DHCPv6 reservations can be created using the client's MAC address the same way DHCPv4 reservations are.

  3. Q3. Which of the following are reasons an OPNsense operator might need a DHCP relay agent? Select all that apply.

Passing score: 75%. Answers are checked in this browser.