Monday , November 4 2024
Home / IP Services / DHCP Relay Agent configuration in Huawei CLI

DHCP Relay Agent configuration in Huawei CLI

When PCs are in a different subnet than a DHCP server installed, DHCP Relay Agent can be used to forward DHCP requests from PCs to DHCP server. How to configure DHCP Relay Agent using Huawei CLI?

Let’s assume that we have the following topology:

We want our PC to acquire its IP address from the DHCP server configured on the labnarioR1 router. To do so, labnarioR2 should be configured as a DHCP Relay Agent to forward DHCP Requests and Offers between server and clients.

First, DHCP server should be configured. LabnarioR1 router will be configured to offer DHCP service for PC.

<labnarioR1>system-view 
Enter system view, return user view with Ctrl+Z.
[labnarioR1] dhcp enable
[labnarioR1] ip pool 1
[labnarioR1-ip-pool-1] gateway-list 172.16.1.1
[labnarioR1-ip-pool-1] network 172.16.1.0 mask 255.255.255.0
[labnarioR1-ip-pool-1] dns-list 150.100.15.1 150.100.15.2
[labnarioR1-ip-pool-1] domain-name labnario.com
[labnarioR1-ip-pool-1] quit
[labnarioR1]interface Ethernet0/0/0
[labnarioR1-Ethernet0/0/0]dhcp select global

If we want our labnarioR1 router to be able to forward DHCP packets to the PC, static route pointing labnarioR2 should be added:

[labnarioR1] ip route-static 172.16.1.0 255.255.255.0 150.100.12.2

Now labnarioR2 router can be configured to act as a DHCP Relay Agent for 172.16.1.0/24 subnet. Do not forget to enable DHCP service! This step is required on both DHCP Server and Relay.

[labnarioR2]dhcp enable
[labnarioR2-dhcp-server-group-1]quit
[labnarioR2]interface Ethernet0/0/1
[labnarioR2-Ethernet0/0/1] dhcp select relay
[labnarioR2-Ethernet0/0/1] dhcp relay server-ip 150.100.12.1

Let’s check if our PC can acquire IP address:

PC>ipconfig -r

Discover...
Request...
IP: 172.16.1.254
Subnet Mask: 255.255.255.0
Gateway: 172.16.1.1

PC>ipconfig

IPv4 address......................: 172.16.1.254
Subnet mask.......................: 255.255.255.0
Gateway...........................: 172.16.1.1
Physical address..................: 00-0B-09-CF-EB-58
DNS server........................: 150.100.15.1
                                    150.100.15.2

As you see, our DHCP Relay Agent works fine.

How to verify DHCP Relay Agent operation?

[labnarioR2]display dhcp statistics 
Input: total 687 packets, discarded 0 packets
  Bootp request           :          0,  Bootp reply             :          0 
  Discover                :        678,  Offer                   :          3 
  Request                 :          3,  Ack                     :          3 
  Release                 :          0,  Nak                     :          0 
  Decline                 :          0,  Inform                  :          0 

Output: total 12 packets, discarded 0 packets

As you see above, there are DHCP Request and Offer counters, which can be helpful during DHCP troubleshooting.

Below DHCP Relay configuration summary command:

[labnarioR2]display dhcp relay all 
 DHCP relay agent running information of interface Ethernet0/0/1 :
 Server IP address [01] : 150.100.12.1
 Gateway address in use : 172.16.1.1

For debugging use the following commands:

<labnarioR2>debugging dhcp relay packet 
<labnarioR2>debugging dhcp relay event
<labnarioR2>terminal debugging
<labnarioR2>terminal monitor

Look at the debugging output. It shows packet exchange between DHCP client and server. Great commands when troubleshooting DHCP Relay Agent.

<labnarioR2>
Jan 24 2013 15:45:52.710.1-08:00 labnarioR2 DHCP/7/DEBUG:[dhcpr-pkt]:Receives DH
CP DISCOVER message from interface Ethernet0/0/1.(sip:0.0.0.0, dip:255.255.255.2
55, vpn:0) 
Jan 24 2013 15:45:52.710.2-08:00 labnarioR2 DHCP/7/DEBUG:[dhcpr-pkt]:Relay packe
t to server 150.100.12.1. 
Jan 24 2013 15:45:52.740.2-08:00 labnarioR2 DHCP/7/DEBUG:[dhcpr-pkt]:Receives DH
CP OFFER message from interface Ethernet0/0/0.(sip:150.100.12.1, dip:172.16.1.1,
 vpn:0) 
Jan 24 2013 15:45:52.740.3-08:00 labnarioR2 DHCP/7/DEBUG:[dhcpr-pkt]:Unicast DHC
P OFFER to client. (Chaddr=000b-09cf-eb58, Ciaddr=172.16.1.254) 
Jan 24 2013 15:45:55.200.1-08:00 labnarioR2 DHCP/7/DEBUG:[dhcpr-pkt]:Receives DH
CP REQUEST message from interface Ethernet0/0/1.(sip:0.0.0.0, dip:255.255.255.25
5, vpn:0)
Jan 24 2013 15:45:55.200.2-08:00 labnarioR2 DHCP/7/DEBUG:[dhcpr-pkt]:Relay packe
t to server 150.100.12.1. 
Jan 24 2013 15:45:55.210.3-08:00 labnarioR2 DHCP/7/DEBUG:[dhcpr-pkt]:Receives DH
CP ACK message from interface Ethernet0/0/0.(sip:150.100.12.1, dip:172.16.1.1, v
pn:0) 
Jan 24 2013 15:45:55.210.4-08:00 labnarioR2 DHCP/7/DEBUG:[dhcpr-pkt]:Unicast DHC
P ACK to client. (Chaddr=000b-09cf-eb58, Ciaddr=172.16.1.254)

Some time ago I wrote about DHCP configuration. Just go to Huawei AR19/29/49 router DHCP configuration to read more.

Final configuration:

sysname labnarioR1
#
dhcp enable
#
ip pool 1
 gateway-list 172.16.1.1
 network 172.16.1.0 mask 255.255.255.0
 dns-list 150.100.15.1 150.100.15.2
 domain-name labnario.com
#
interface Ethernet0/0/0
 ip address 150.100.12.1 255.255.255.0
 dhcp select global
#
ip route-static 172.16.1.0 255.255.255.0 150.100.12.2
#
return

sysname labnarioR2
#
dhcp enable
#
interface Ethernet0/0/1
 ip address 172.16.1.1 255.255.255.0
 dhcp select relay
 dhcp relay server-ip 150.100.12.1
#
return

Leave a Reply

Your email address will not be published. Required fields are marked *