配置DHCPv4中继代理
Prerequisites
An enabled layer 3 interface.
Procedure
- The DHCPv4 relay agent is enabled by default. If it was previously disabled, enable it with the command
dhcp-relay
. - 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. - 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
. - 定义了门way address that the DHCPv4 agent will use with the command
ip bootp-gateway
. - If required, enable the hop count increment feature with the command
dhcp-relay hop-count-increment
. - Review DHCPv4 relay agent configuration settings with the commands
show 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