DHCP relay agent configuration example

Network requirements

As shown in Figure 34, DHCP clients reside on network 10.10.1.0/24. The IP address of the DHCP server is 10.1.1.1/24. Because the DHCP clients reside on a different network than the DHCP server, a DHCP relay agent is deployed to forward messages between DHCP clients and the DHCP server. VLAN-interface 1 on the DHCP relay agent (Switch A) connects to the network where DHCP clients reside. The IP address of VLAN-interface 1 is 10.10.1.1/24 and the IP address of VLAN-interface 2 is 10.1.1.2/24.

Figure 34: Network diagram

Configuration procedure

The DHCP relay agent and server are on different subnets, so configure a static route or dynamic routing protocol to make them reachable to each other.

Configurations on the DHCP server are also required to guarantee the client-server communication via the DHCP relay agent. For DHCP server configuration information, see "Configuring DHCP server."

# Specify IP addresses for the interfaces. (Details not shown.)

# Enable DHCP.

<SwitchA> system-view
[SwitchA] dhcp enable

# Add DHCP server 10.1.1.1 into DHCP server group 1.

[SwitchA] dhcp relay server-group 1 ip 10.1.1.1

# Enable the DHCP relay agent on VLAN-interface 1.

[SwitchA] interface vlan-interface 1
[SwitchA-Vlan-interface1] dhcp select relay

# Correlate VLAN-interface 1 to DHCP server group 1.

[SwitchA-Vlan-interface1] dhcp relay server-select 1

After the preceding configuration is complete, DHCP clients can obtain IP addresses and other network parameters through the DHCP relay agent from the DHCP server. You can use the display dhcp relay statistics command to view statistics of DHCP packets forwarded by DHCP relay agents. After you enable address check of the DHCP relay agents with the dhcp relay address-check enable command, use the display dhcp relay security command to view bindings of DHCP relay agents