Configure a DHCP Relay
Network Requirements
- Device1 is the DHCP server, and the interface of Device2 enables the DHCP relay function.
- The DHCP server provides the service for the client of the segment 1.0.0.0/24, and the first ten IP addresses are reserved.
- The DHCP client gets the IP address via DHCP relay.
Network Topology
Figure 3-3 Networking for Configuring a DHCP Relay
Configuration Steps
Step 1: Configure VLAN, and add the port to the corresponding VLAN. Configure the IP address of the interface (omitted).
Step 2: Configure the IP address pool of Device1 and the reserved IP address, and work in the DHCP server mode.
#Configure the DHCP server.
Device1(config)#interface vlan2
Device1(config-if-vlan2)#ip dhcp server
Device1(config-if-vlan2)#exit
|
#Configure the IP addresses of 1.0.0.1 to 1.0.0.10 not to be distributed.
Device1#configure terminal
Device1(config)#ip dhcp excluded-address 1.0.0.1 1.0.0.10
|
#Configure the IP address pool of Device1 dynamic-pool.
Device1(config)#ip dhcp pool dynamic-pool
Device1(dhcp-config)#network 1.0.0.0 255.255.255.0
Device1(dhcp-config)#default-router 1.0.0.1
Device1(dhcp-config)#lease 1 0 0
Device1(dhcp-config)#exit
|
#Configure the static route to the segment 1.0.0.0/24.
Device1(config)#ip route 1.0.0.0 255.255.255.0 2.0.0.2
|
Step 3: On the vlan3 interface of Device2, configure the address of the DHCP server as 2.0.0.1, and make the interface work in the relay mode.
Device2(config)#interface vlan3
Device2(config-if-vlan3)#ip dhcp relay
Device2(config-if-vlan3)#ip dhcp relay server-addres 2.0.0.1
Device2(config-if-vlan3)#exit
|
Step 4: Check the result.
#Query the information of the IP address distributed on Device1.
Device1#show ip dhcp pool dynamic-pool lease
IP Address MAC Address Vendor Id Type Time Left(s)
-------------- --------------- ------------- ------- -----------
1.0.0.11 0001.7a6a.0268 Global Lease 86387
Use the show ip dhcp pool dynamic-pool lease command to query the IP address that has been allocated to the client. The result shows that the client has obtained the IP address 1.0.0.12.