DHCP server and DHCP relay configuration

Posted by Win32 on Sun, 09 Jan 2022 00:28:17 +0100

Dhcp server configuration example

As shown in the figure below, a company has three departments. Different departments are in different network segments. Now it is necessary to configure DHCP server on router ar1 in order to provide DHCP configuration services to PCs in each department.

Configuration idea:

1. Enable the dhcp function on ar1

2. Create three global address pools to allocate ip addresses to PCs in three different departments

3. Configure the related attributes of the address pool

4. Configure the service mode based on the global address pool under the ar1 interface to enable the dhcp server to select the assigned address from the global address pool

Configuration steps:

To enable the dhcp function on ar1, you must first enter the system view and then execute dhcp enable

<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]dhcp enable      //Enable dhcp
Info: The operation may take a few seconds. Please wait for a moment.done.
[Huawei]

Then create three ip address pools on ar1 to allocate addresses to three different departments. The configuration is as follows:

IP pool IP pool name red is the name of the address pool you want to get, or xiaohong and xiaoming

[Huawei]ip pool department1
Info: It's successful to create an IP address pool.
[Huawei-ip-pool-department1q]q
[Huawei]ip pool department2
Info: It's successful to create an IP address pool.
[Huawei-ip-pool-department2]q
[Huawei]ip pool department3
Info: It's successful to create an IP address pool.
[Huawei-ip-pool-department3]q
[Huawei]

Using display ip pool, you can see the three address pools created

[Huawei]display ip pool 
  -----------------------------------------------------------------------
  Pool-name      : department1
  Pool-No        : 0
  Position       : Local           Status           : Unlocked
  Gateway-0      : -               
  Mask           : -
  VPN instance   : --

  -----------------------------------------------------------------------
  Pool-name      : department1q
  Pool-No        : 1
  Position       : Local           Status           : Unlocked
  Gateway-0      : -               
  Mask           : -
  VPN instance   : --

  -----------------------------------------------------------------------
  Pool-name      : department2
  Pool-No        : 2
  Position       : Local           Status           : Unlocked
  Gateway-0      : -               
  Mask           : -
  VPN instance   : --

  -----------------------------------------------------------------------
  Pool-name      : department3
  Pool-No        : 3
  Position       : Local           Status           : Unlocked
  Gateway-0      : -               
  Mask           : -
  VPN instance   : --


  IP address Statistic
    Total       :0     
    Used        :0          Idle        :0     
    Expired     :0          Conflict    :0          Disable   :0     
[Huawei]

After the address pool is created, you need to configure the ip address segment, lease term, gateway address, etc. that can be allocated in the address pool. As follows:

ar1:

ip pool department1:

[Huawei]ip pool department1   //Enter department1 address pool
[Huawei-ip-pool-department1]network 192.168.1.0 mask 24    //Assignable address segment
[Huawei-ip-pool-department1]gateway-list 192.168.1.1       //Gateway address, not involved in allocation
[Huawei-ip-pool-department1]lease day 0 hour 1             //Set lease term

ip pool department2 and 3 are the same:

[Huawei]ip pool department2
[Huawei-ip-pool-department2]network 192.168.11.0 mask 24
[Huawei-ip-pool-department2]gateway-list 192.168.11.11 	
[Huawei-ip-pool-department2]lease day 0 hour 10
[Huawei-ip-pool-department2]q
[Huawei]ip pool department3
[Huawei-ip-pool-department3]network 192.168.111.0 mask 24
[Huawei-ip-pool-department3]gateway-list 192.168.111.111
[Huawei-ip-pool-department3]lease day 1 hour 10

So far, we have completed the configuration of the address pool.

Now you need to configure the service mode based on the global address pool under each interface of ar1. The command used is dhcp select global

ar1:

[Huawei]int g0/0/0     //Enter interface g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.1.1 24    //Configure the address for the interface. This address is the gateway address in the address pool just now. Therefore, this address will not be assigned to the pc because it is given to the gateway
[Huawei-GigabitEthernet0/0/0]dhcp select global           //Configure global based address pool service mode
[Huawei-GigabitEthernet0/0/0]q
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.11.11 24
[Huawei-GigabitEthernet0/0/1]dhcp select global 
[Huawei-GigabitEthernet0/0/1]q
[Huawei]int g0/0/2
[Huawei-GigabitEthernet0/0/2]ip address 192.168.111.111 24	
[Huawei-GigabitEthernet0/0/2]dhcp select global 

At this point, the configuration is completed. Click pc, click dhcp and apply

Click the command line and enter ipconfig

You can see that the address has been successfully obtained.

Use display IP pool name pool name used to view the current address pool allocation. As follows:

[Huawei]display ip pool name department1 used 
  Pool-name      : department1
  Pool-No        : 0
  Lease          : 0 Days 1 Hours 0 Minutes
  Domain-name    : -
  DNS-server0    : -               
  NBNS-server0   : -               
  Netbios-type   : -               
  Position       : Local           Status           : Unlocked
  Gateway-0      : 192.168.1.1     
  Mask           : 255.255.255.0
  VPN instance   : --
 -----------------------------------------------------------------------------
         Start           End     Total  Used  Idle(Expired)  Conflict  Disable
 -----------------------------------------------------------------------------
     192.168.1.1   192.168.1.254   253     2        251(1)         0        0
 -----------------------------------------------------------------------------

  Network section : 
  --------------------------------------------------------------------------
  Index              IP               MAC      Lease   Status  
  --------------------------------------------------------------------------
    251   192.168.1.252    5489-98d0-29b3        348   Used       
    252   192.168.1.253    5489-9878-4522        353   Used       
  --------------------------------------------------------------------------

[Huawei]

At this point, the dhcp server is successfully configured.

DHCP relay configuration

In the above case, this configuration can be performed when the pc is directly connected to the dhcp server. However, if the dhcp server of the pc is not directly connected and one or more network segments are separated, how should it be configured? dhcp relay solves this problem.

The experimental topology is as follows:

 1. Configure the idea relay (the rest are the same as the above dhcp configuration)

Enable dhcp function on ar6

Enable the dhcp relay function under each interface of ar6 and configure the ip address of the dhcp server

2. Configuration steps (interface address configuration omitted)

ar2 is configured as follows

[Huawei]dhcp enable  //Enable dhcp
Info: The operation may take a few seconds. Please wait for a moment.done.
[Huawei]ip pool department1   //Create address pool
Info: It's successful to create an IP address pool.	
[Huawei-ip-pool-department1]network 192.168.26.0 mask 24
[Huawei-ip-pool-department1]gateway-list 192.168.26.6     //Assign the address of the gateway
[Huawei-ip-pool-department1]q
[Huawei]ip pool department2
Info: It's successful to create an IP address pool.
[Huawei-ip-pool-department2]network 192.168.36.6 mask 24
[Huawei-ip-pool-department2]gateway-list 192.168.36.6
[Huawei-ip-pool-department2]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]dhcp select global   //Enter this interface to configure the service mode based on the global address pool

ar6 is configured as follows

[Huawei]dhcp enable 
Info: The operation may take a few seconds. Please wait for a moment.done.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]dhcp select relay         //Enable dhcp relay function
[Huawei-GigabitEthernet0/0/0]dhcp relay server-ip 192.168.23.2   //Configure the ip address of the dhcp server
[Huawei-GigabitEthernet0/0/0]q
[Huawei]int g0/0/2
[Huawei-GigabitEthernet0/0/2]dhcp select relay 
[Huawei-GigabitEthernet0/0/2]dhcp relay server-ip 192.168.23.2
[Huawei-GigabitEthernet0/0/2]

In this way, the dhcp configuration has been completed. The important point is that ar2 and ar6 are not available now. How can ar2 provide address services for PCs? It must not be available, so we need to connect ar2 and ar6. Here, the author uses global ospf for connection. Of course, rip and static can be used, as long as ar2 can ping g0/0/0 and g0/0/2 of ar6. (ospf configuration omitted)

At this point, the configuration has been completed, and the test view is as follows:

The pc has obtained the address.

Use display ip pool name department1 used on ar2 to view ip allocation. As follows:

[Huawei]display ip pool name department1 used  
  Pool-name      : department1
  Pool-No        : 0
  Lease          : 1 Days 0 Hours 0 Minutes
  Domain-name    : -
  DNS-server0    : -               
  NBNS-server0   : -               
  Netbios-type   : -               
  Position       : Local           Status           : Unlocked
  Gateway-0      : 192.168.26.6    
  Mask           : 255.255.255.0
  VPN instance   : --
 -----------------------------------------------------------------------------
         Start           End     Total  Used  Idle(Expired)  Conflict  Disable
 -----------------------------------------------------------------------------
    192.168.26.1  192.168.26.254   253     3        250(0)         0        0
 -----------------------------------------------------------------------------

  Network section : 
  --------------------------------------------------------------------------
  Index              IP               MAC      Lease   Status  
  --------------------------------------------------------------------------
    251  192.168.26.252    5489-984d-544b        108   Used       
    252  192.168.26.253    5489-9815-6043        119   Used       
    253  192.168.26.254    5489-9858-72a0        656   Used       
  --------------------------------------------------------------------------

[Huawei]

Summary: it is necessary to ensure the interoperability of the whole network. Under the DHCP server interface, execute dhcp select global, under ar6, execute dhcp select relay, and specify the address of the DHCP server.

Topics: dhcp