On Monday morning a floor calls to say “we can’t get an IP”; or worse, they get an address but from the wrong network: a home router someone plugged in at their desk has started handing out 192.168.1.x. DHCP on a campus network has two separate problems. How will requests from clients in different VLANs reach the central server? How will an unauthorized DHCP server (a home router, a misconfigured virtual machine) be prevented from handing out addresses to clients? The answer to the first is DHCP relay, to the second DHCP snooping. Below we address both from the switch side, with their interactions and Cisco IOS examples.
DHCP message flow and the VLAN boundary
DHCPv4 (RFC 2131) works with four basic messages: DISCOVER, OFFER, REQUEST and ACK. A client without an address sends DISCOVER as a broadcast with source 0.0.0.0, destination 255.255.255.255, from UDP 68 to UDP 67. Broadcasts don’t pass through routers. So the boundary of the VLAN is also the boundary of the DHCP request; if the server isn’t in the same VLAN, an intermediary has to carry the request.
Putting a separate DHCP server in each VLAN works in a small environment; but it scatters scope management, fragments logs and makes redundancy harder. The common model in enterprise networks is a redundant DHCP service in the data center and relay configured on the default gateway (SVI) of each user VLAN. For redundancy on the server side, the Windows Server DHCP failover configuration article on our systems site is the other half of this article.
DHCP relay: ip helper-address and giaddr
The relay agent is the L3 interface in the client’s VLAN: mostly the SVI on the distribution or collapsed core switch, or the firewall interface if the VLANs terminate on the firewall. On Cisco IOS, the configuration is a single line:
interface Vlan20
description USERS-BLDG-A
ip address 10.20.0.1 255.255.252.0
ip helper-address 10.0.50.11
ip helper-address 10.0.50.12
When the relay agent receives the broadcast, it does three things. It writes the IP address of the interface the request came in on (10.20.0.1 in the example) into the packet’s giaddr (gateway IP address) field, forwards the packet as unicast over UDP 67 to each defined server, and passes the reply from the server back to the client VLAN. The server decides which scope to give an address from by looking at giaddr; if giaddr is 10.20.0.1, it looks for the 10.20.0.0/22 scope. That’s why the SVI’s primary address and the scope on the server must be in the same subnet. If the SVI has a secondary address, the primary address is used as giaddr. No scope, no reply.
When two helper addresses are defined, the request goes to both servers. This is the expected behavior in redundant setups such as Windows DHCP failover or ISC Kea. A gap you may encounter is only the first server being written on the SVI of a newly opened VLAN; failover is assumed to be working, and when the first server goes down that VLAN is left without addresses.
Whether routing between VLANs will be done on the switch or the firewall also determines the relay point. For the options, see the inter-VLAN routing options article.
DHCP snooping: trusted and untrusted ports
DHCP snooping is the switch inspecting DHCP messages and dividing ports into two classes:
- Trusted port: A port where DHCP server messages (OFFER, ACK, NAK) can arrive. Uplinks, ports to the server and the path to the relay agent are in this class.
- Untrusted port: Client ports. Server messages arriving here are dropped; client messages are checked and forwarded. Every unconfigured port is untrusted by default.
So even if a router plugged in at a user’s desk sends an OFFER, the switch throws the message away. On untrusted ports, the source MAC address can also be compared with the client hardware address (chaddr) in the DHCP packet; a mismatching request is dropped. This check makes attacks that try to exhaust the pool with fake requests harder.
Snooping is enabled per VLAN. Issuing the global command and forgetting to make the uplink trusted means all clients in that VLAN can’t get an address. Outages can happen this way. That’s why the order of implementation is fixed: trusted ports first, then the VLAN list, the global command last.
The binding table and dependent features
Snooping creates a record from every DHCP transaction that completes successfully on untrusted ports: MAC address, IP address, lease time, VLAN and port. This binding table is the foundation of two security features:
| Feature | What does it do? | Point to watch |
|---|---|---|
| Dynamic ARP Inspection (DAI) | Validates the IP–MAC mapping in ARP packets arriving on untrusted ports against the binding table | Devices with static IPs need an ARP ACL |
| IP Source Guard | Allows traffic from a port only with the source IP in the binding table | Devices with static IPs need a static binding |
| Snooping database | Preserves the table across reboots | If not saved, the table is empty at boot |
The binding table is kept in memory by default. When the switch restarts, the table empties; on ports with DAI and IP Source Guard enabled, clients can be left without traffic until they renew their lease. This is one of the common reasons behind the “half the floor is working” complaint after a power outage. Have the table written to flash or to a server with the ip dhcp snooping database command.
Option 82 and server compatibility problems
Option 82 (Relay Agent Information, RFC 3046) adds the switch and port the request came from to the DHCP request. It’s useful in environments that need port-based address assignment or logging. The problem is this: on Cisco switches, when DHCP snooping is enabled, inserting option 82 is enabled by default. Because the L2 access switch isn’t a relay agent, the giaddr field stays 0; the relay agent above receives a packet that “contains option 82 but has a giaddr value of 0.”
Two typical faults are seen at this point:
- The distribution switch drops the packet: If snooping is also enabled on the distribution switch and the request came in on an untrusted port, a packet containing option 82 is dropped by default. The Cisco IOS relay agent can also reject such packets arriving from an interface not marked as trusted.
- The server doesn’t respond, or the reply doesn’t return to the client: According to RFC 3046, the server is expected to echo option 82 back in the reply; if the server or a device in between doesn’t support this, the transaction doesn’t complete.
If you don’t use option 82, the cleanest solution is to disable insertion on the access switches: no ip dhcp snooping information option. If you do use it, have these packets accepted with ip dhcp snooping information option allow-untrusted on the aggregation switch and ip dhcp relay information trusted on the relay interface, and verify that the option is processed on the server side. A half-done configuration is the worst.
Cisco IOS configuration example
The example below configures snooping on an L2 access switch for VLAN 20 (users) and VLAN 120 (voice), for an environment where option 82 isn’t used. Te1/1/1 is the uplink to the distribution layer.
! 1) First make the uplink trusted
interface TenGigabitEthernet1/1/1
description UPL | DS01 Te1/0/5
ip dhcp snooping trust
!
! 2) Rate limiting on client ports
interface range GigabitEthernet1/0/1 - 46
ip dhcp snooping limit rate 15
!
! 3) Disable option 82 insertion, make the database persistent
no ip dhcp snooping information option
ip dhcp snooping database flash:dhcp-snooping.db
!
! 4) Select the VLANs and enable the feature
ip dhcp snooping vlan 20,120
ip dhcp snooping
!
! 5) Automatic recovery if a port goes err-disabled on exceeding the rate limit
errdisable recovery cause dhcp-rate-limit
errdisable recovery interval 300
The rate limit is the number of DHCP packets per second. On an access port with a single client, a low value is enough; on a port with a small switch or many virtual machines behind it, raise the value. Putting a rate limit on a trusted uplink is a separate trap: at boot, when all clients send requests at the same time, the uplink can go err-disabled and the whole floor drops. For a complete set of access and uplink port templates, there’s a ready template in the switch configuration standard article.
Common faults and diagnostic commands
What shortens a DHCP fault is splitting the problem into layers. Is the request reaching the switch? Is it being relayed? Is the server responding? Is the reply returning to the client? Proceed in this order on the console:
| Symptom | Likely cause | Check |
|---|---|---|
| After snooping, no one in the VLAN can get an address | The uplink isn’t trusted | show ip dhcp snooping |
| Only clients on one floor can’t get an address | Option 82 / giaddr 0 drop | show ip dhcp snooping statistics |
| Addresses come from the wrong subnet | Wrong helper, or a scope and giaddr mismatch | show ip interface Vlan20 |
| The port suddenly shuts down | Rate limit exceeded | show interfaces status err-disabled |
| Devices with static IPs cut off after a restart | Static exception missing for DAI/IPSG | show ip dhcp snooping binding |
On the server side, for Windows DHCP you can see scope utilization with Get-DhcpServerv4ScopeStatistics and leases in a specific scope with Get-DhcpServerv4Lease -ScopeId 10.20.0.0; audit logs are in the C:\Windows\System32\dhcp folder by default. A pool whose scope is full looks like a network fault. On the switch side, debug ip dhcp snooping packet gives detailed output; but because it can create CPU load on busy VLANs, enable it only briefly and in a maintenance window.
Pre-deployment checklist:
- If there is redundant DHCP, are both servers defined as helpers on the SVI of every user VLAN?
- Are the scopes on the server in the same subnet as the SVI primary addresses?
- On every switch where snooping is enabled, are the uplink and server ports trusted?
- Is the use of option 82 a deliberate decision; if not, is insertion disabled?
- Is the binding database written to a persistent location?
- Are DAI/IPSG exceptions defined for printers, cameras and servers with static IPs?
On the IPv6 side, relay and rogue server protection work with different mechanisms (DHCPv6 relay, RA Guard, DHCPv6 Guard); these are covered in the IPv6 migration plan for a campus network article. Deploying relay, snooping and DAI together with the VLAN architecture falls within VLAN, routing and network segmentation work, and applying them to existing switches within the switch and router installation service.
Frequently asked questions
On which switch is ip helper-address configured?
On the L3 interface that is the default gateway for the client’s VLAN. This is usually the SVI on the distribution or collapsed core switch; if the VLANs terminate on the firewall, relay is configured on the firewall interface. A helper address written on an L2 access switch is of no use.
Why couldn’t anyone get an address after enabling DHCP snooping?
The most common reason is the uplink toward the DHCP server not being made trusted; the server’s OFFER and ACK messages are dropped because they arrive on an untrusted port. The second common reason is requests with option 82 inserted and a giaddr value of 0 being rejected on the distribution switch or relay agent.
Does disabling option 82 reduce security?
No. Snooping’s functions of blocking rogue DHCP servers and building the binding table don’t depend on option 82. Option 82 only carries switch and port information to the server. If you don’t need port-based address assignment or logging, disabling it doesn’t change the level of protection.
Why should the binding table be saved to flash?
If the table is kept only in memory, it empties when the switch restarts. On ports with DAI or IP Source Guard enabled, clients’ traffic can be blocked until they renew their leases. Writing the table to a persistent location allows the entries to be restored after boot.