Configuring the DHCPv4 relay agent

Prerequisites
  • An enabled layer 3 interface.

Procedure
  1. The DHCPv4 relay agent is enabled by default. If it was previously disabled, enable it with the command dhcp-relay.
  2. Configure one or more IP helper addresses with the command ip helper-address. This determines where the DHCPv4 agent forwards DHCP requests. IP helper addresses can be configured on layer 3 interfaces, layer 3 VLAN interfaces, and LAG interfaces.
  3. If you want to modify the content of forwarded DHCP packets or drop DHCP packets, configure option 82 support with the command dhcp-relay option 82.
  4. Define the gateway address that the DHCPv4 agent will use with the command ip bootp-gateway.
  5. If required, enable the hop count increment feature with the command dhcp-relay hop-count-increment.
  6. Review DHCPv4 relay agent configuration settings with the commands show dhcp-relay, show ip helper-address, and show dhcp-relay bootp-gateway.

Example

This example creates the following configuration:

  • Enables the DHCPv4 relay agent.
  • Enables interface 1/1/1 and assigns an IPv4 address to it. (By default, all interfaces are layer 3 and disabled.)

  • Defines an IP helper address of 10.10.20.209 on the interface.
  • Enables DHCP option 82 support and replaces all option 82 information with the values from the switch with the switch MAC address as the remote ID.

switch(config)# dhcp-relay
switch(config)# interface 1/1/1
switch(config-if)# no shutdown
switch(config-if)# ip address 198.51.100.1/24 
switch(config-if)# ip helper-address 10.10.20.209 
switch(config-if)# exit 
switch(config)# dhcp-relay option 82 replace mac
switch# show dhcp-relay
 DHCP Relay Agent                 : Enabled
 DHCP Request Hop Count Increment : Enabled
 Option 82                        : Disabled
 Response Validation              : Disabled
 Option 82 Handle Policy          : replace
 Remote ID                        : mac

 DHCP Relay Statistics:

  Valid Requests Dropped Requests Valid Responses Dropped Responses
  -------------- ---------------- --------------- -----------------
  60             10               60              10

 DHCP Relay Option 82 Statistics:

  Valid Requests Dropped Requests Valid Responses Dropped Responses
  -------------- ---------------- --------------- -----------------
  50             8                50              8