配置DHCPv4中继代理

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 commanddhcp-relay.
  2. Configure one or more IP helper addresses with the commandip 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 commanddhcp-relay option 82.
  4. 定义了门way address that the DHCPv4 agent will use with the commandip bootp-gateway.
  5. If required, enable the hop count increment feature with the commanddhcp-relay hop-count-increment.
  6. Review DHCPv4 relay agent configuration settings with the commandsshow dhcp-relay,show ip helper-address, andshow dhcp-relay bootp-gateway.

Example

This example creates the following configuration:

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

  • Defines an IP helper address of10.10.20.209on 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-relayswitch(config)#interface 1/1/1switch(config-if)#no shutdownswitch(config-if)#ip address 198.51.100.1/24switch(config-if)#ip helper-address 10.10.20.209switch(config-if)#exitswitch(config)#dhcp-relay option 82 replace macswitch#show dhcp-relayDHCP 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