< Home

Example for Configuring a DHCP Relay Agent (Connected to a DHCP Server over a GRE Tunnel)

Networking Requirements

In Figure 1, an enterprise deploys its headquarters and branch in different areas. To enable the headquarters and branch to communicate through the Internet, a Generic Routing Encapsulation (GRE) tunnel needs to be deployed. To facilitate unified management, a DHCP server needs to be configured on Switch_1 in the headquarters to assign IP addresses to the terminals in the headquarters and branch. The network segments 10.1.1.0/24 and 10.2.1.0/24 are planned for the headquarters and branch, respectively.

Only the S5720-EI, S5720-HI, S5730-HI, S5731-H, S5731S-H, S5731-S, S5731S-S, S6720-HI, S5732-H, S6730-H, S6730S-H, S6730-S, S6730S-S, S6720-EI, and S6720S-EI support GRE.

Figure 1 Networking diagram for configuring a DHCP server to allocate IP addresses to clients through a GRE tunnel

Configuration Roadmap

The configuration roadmap is as follows:

  1. Run OSPF between Switch_1, Switch_2, and Switch_3 to ensure their reachability.

  2. On Switch_1 and Switch_3, configure tunnel interfaces and create a GRE tunnel.

  3. Configure Switch_1 as a DHCP server based on a global address pool so that the DHCP server can assign IP addresses from the global address pool to the terminals in the headquarters and branch.

  4. Configure Switch_3 as a DHCP relay and to function as the branch's gateway to forward DHCP messages between the terminals and DHCP server.

Huawei S series switch functions as a DHCP server (Switch_1) in this example.

Configure the interface link types and VLANs on LSW_1 and LSW_2 to implement Layer 2 communication.

Procedure

  1. Configure an IP address for each physical interface on Switch_1 through Switch_3.

    # Configure Switch_1.

    <HUAWEI> system-view
    [HUAWEI] sysname Switch_1
    [Switch_1] vlan batch 10 30
    [Switch_1] interface gigabitethernet 0/0/1
    [Switch_1-GigabitEthernet0/0/1] port link-type trunk
    [Switch_1-GigabitEthernet0/0/1] port trunk allow-pass vlan 10
    [Switch_1-GigabitEthernet0/0/1] quit
    [Switch_1] interface gigabitethernet 0/0/2
    [Switch_1-GigabitEthernet0/0/2] port link-type trunk
    [Switch_1-GigabitEthernet0/0/2] port trunk allow-pass vlan 30
    [Switch_1-GigabitEthernet0/0/2] quit
    [Switch_1] interface vlanif 10
    [Switch_1-Vlanif10] ip address 192.168.20.1 24
    [Switch_1-Vlanif10] quit
    [Switch_1] interface vlanif 30
    [Switch_1-Vlanif30] ip address 10.1.1.1 24
    [Switch_1-Vlanif30] quit

    # Configure Switch_2.

    <HUAWEI> system-view
    [HUAWEI] sysname Switch_2
    [Switch_2] vlan batch 10 20
    [Switch_2] interface gigabitethernet 0/0/1
    [Switch_2-GigabitEthernet0/0/1] port link-type trunk
    [Switch_2-GigabitEthernet0/0/1] port trunk allow-pass vlan 10
    [Switch_2-GigabitEthernet0/0/1] quit
    [Switch_2] interface gigabitethernet 0/0/2
    [Switch_2-GigabitEthernet0/0/2] port link-type trunk
    [Switch_2-GigabitEthernet0/0/2] port trunk allow-pass vlan 20
    [Switch_2-GigabitEthernet0/0/2] quit
    [Switch_2] interface vlanif 10
    [Switch_2-Vlanif10] ip address 192.168.20.2 24
    [Switch_2-Vlanif10] quit
    [Switch_2] interface vlanif 20
    [Switch_2-Vlanif20] ip address 192.168.30.1 24
    [Switch_2-Vlanif20] quit

    # Configure Switch_3.

    <HUAWEI> system-view
    [HUAWEI] sysname Switch_3
    [Switch_3] vlan batch 20 30
    [Switch_3] interface gigabitethernet 0/0/1
    [Switch_3-GigabitEthernet0/0/1] port link-type trunk
    [Switch_3-GigabitEthernet0/0/1] port trunk allow-pass vlan 20
    [Switch_3-GigabitEthernet0/0/1] quit
    [Switch_3] interface gigabitethernet 0/0/2
    [Switch_3-GigabitEthernet0/0/2] port link-type trunk
    [Switch_3-GigabitEthernet0/0/2] port trunk allow-pass vlan 30
    [Switch_3-GigabitEthernet0/0/2] quit
    [Switch_3] interface vlanif 20
    [Switch_3-Vlanif20] ip address 192.168.30.2 24
    [Switch_3-Vlanif20] quit
    [Switch_3] interface vlanif 30
    [Switch_3-Vlanif30] ip address 10.2.1.1 24
    [Switch_3-Vlanif30] quit

  2. Run OSPF between Switch_1, Switch_2, and Switch_3.

    # Configure Switch_1.

    [Switch_1] ospf 1
    [Switch_1-ospf-1] area 0
    [Switch_1-ospf-1-area-0.0.0.0] network 192.168.20.0 0.0.0.255
    [Switch_1-ospf-1-area-0.0.0.0] quit
    [Switch_1-ospf-1] quit

    # Configure Switch_2.

    [Switch_2] ospf 1
    [Switch_2-ospf-1] area 0
    [Switch_2-ospf-1-area-0.0.0.0] network 192.168.20.0 0.0.0.255
    [Switch_2-ospf-1-area-0.0.0.0] network 192.168.30.0 0.0.0.255
    [Switch_2-ospf-1-area-0.0.0.0] quit
    [Switch_2-ospf-1] quit

    # Configure Switch_3.

    [Switch_3] ospf 1
    [Switch_3-ospf-1] area 0
    [Switch_3-ospf-1-area-0.0.0.0] network 192.168.30.0 0.0.0.255
    [Switch_3-ospf-1-area-0.0.0.0] quit
    [Switch_3-ospf-1] quit

  3. Configure tunnel interfaces.

    # Configure Switch_1.

    [Switch_1] interface tunnel 1
    [Switch_1-Tunnel1] tunnel-protocol gre
    [Switch_1-Tunnel1] ip address 192.168.40.1 24
    [Switch_1-Tunnel1] source 192.168.20.1
    [Switch_1-Tunnel1] destination 192.168.30.2
    [Switch_1-Tunnel1] quit

    # Configure Switch_3.

    [Switch_3] interface tunnel 1
    [Switch_3-Tunnel1] tunnel-protocol gre
    [Switch_3-Tunnel1] ip address 192.168.40.2 24
    [Switch_3-Tunnel1] source 192.168.30.2
    [Switch_3-Tunnel1] destination 192.168.20.1
    [Switch_3-Tunnel1] quit

  4. Configure Switch_1 as a DHCP server.

    # Enable DHCP. By default, the service is disabled.

    [Switch_1] dhcp enable

    # Create a global address pool and configure related parameters.

    [Switch_1] ip pool pool1
    [Switch_1-ip-pool-pool1] network 10.2.1.0 mask 255.255.255.0
    [Switch_1-ip-pool-pool1] gateway-list 10.2.1.1
    [Switch_1-ip-pool-pool1] quit
    [Switch_1] ip pool pool2
    [Switch_1-ip-pool-pool2] network 10.1.1.0 mask 255.255.255.0
    [Switch_1-ip-pool-pool2] gateway-list 10.1.1.1
    [Switch_1-ip-pool-pool2] quit
    # Configure the terminals connected to VLANIF30 to obtain IP addresses from the global address pool.
    [Switch_1] interface vlanif 30
    [Switch_1-Vlanif30] dhcp select global
    [Switch_1-Vlanif30] quit
    # Configure a static route to the network segment of the terminals in the branch.
    [Switch_1] ip route-static 10.2.1.0 255.255.255.0 tunnel 1

  5. Configure the DHCP relay function on Switch_3.

    # Enable DHCP. By default, the service is disabled.

    [Switch_3] dhcp enable
    # Configure the DHCP relay function on VLANIF 30 and specifies the DHCP server address for the relay.
    [Switch_3] interface vlanif 30
    [Switch_3-Vlanif30] dhcp select relay 
    [Switch_3-Vlanif30] dhcp relay server-ip 10.1.1.1
    [Switch_3-Vlanif30] quit
    # Configure a static route to the network segment of the server.
    [Switch_3] ip route-static 10.1.1.0 255.255.255.0 tunnel 1

  6. Configure each terminal (using a PC running Windows 7 as an example) to automatically obtain an IP address.

    # Right-click Network and choose Properties to display the Network and Sharing Center window.

    # Click Local Area Connection to display the Local Area Connection Status window.

    # Click Properties to display the Local Area Connection Properties window.

    # Select Internet Protocol Version 4 (TCP/IPv4) and click Properties to display the Internet Protocol Version 4 (TCP/IPv4) Properties window.

    # Select Obtain an IP address automatically and click OK.

  7. Verify the configuration.

    # Run the display dhcp relay interface vlanif 30 command on Switch_3 to check the DHCP relay configuration.

    [Switch_3] display dhcp relay interface vlanif 30
     DHCP relay agent running information of interface Vlanif30 :
     Server IP address [00] : 10.1.1.1
     Gateway address in use : 10.2.1.1

    # Run the display ip pool command on Switch_1 to check the IP address allocation of pool1 and pool2. The headquarters in this example has 100 terminals while the branch has 50.

    [Switch_1] display ip pool name pool1
      Pool-name        : pool1
      Pool-No          : 0
      Lease            : 1 Days 0 Hours 0 Minutes
      Domain-name      : -
      DNS-server0      : -
      NBNS-server0     : -
      Netbios-type     : -
      Position         : Local
      Status           : Unlocked
      Gateway-0        : 10.2.1.1
      Network          : 10.2.1.0
      Mask             : 255.255.255.0
      VPN instance     : --
      Logging          : Disable
      Conflicted address recycle interval: -
      Address Statistic: Total       :253       Used        :50
      Idle        :203       Expired     :0
      Conflict    :0         Disabled     :0
    
     -------------------------------------------------------------------------------
      Network section
             Start           End       Total    Used Idle(Expired) Conflict Disabled
     -------------------------------------------------------------------------------
            10.2.1.1      10.2.1.254     253      50        203(0)       0     0
     -------------------------------------------------------------------------------
    [Switch_1] display ip pool name pool2 
      Pool-name        : pool2
      Pool-No          : 1
      Lease            : 1 Days 0 Hours 0 Minutes
      Domain-name      : -
      DNS-server0      : -
      NBNS-server0     : -
      Netbios-type     : -
      Position         : Local
      Status           : Unlocked
      Gateway-0        : 10.1.1.1
      Network          : 10.1.1.0
      Mask             : 255.255.255.0
      VPN instance     : --
      Logging          : Disable
      Conflicted address recycle interval: -
      Address Statistic: Total       :253       Used        :50
      Idle        :203       Expired     :0
      Conflict    :0         Disabled     :0
    
     -------------------------------------------------------------------------------
      Network section
             Start           End       Total    Used Idle(Expired) Conflict Disabled
     -------------------------------------------------------------------------------
            10.1.1.1      10.1.1.254     253     100        153(0)       0     0
     -------------------------------------------------------------------------------

Configuration Files

  • Switch_1 configuration file

    #
    sysname Switch_1
    #
    vlan batch 10 30
    #
    dhcp enable
    # 
    ip pool pool1
     gateway-list 10.2.1.1
     network 10.2.1.0 mask 255.255.255.0
    # 
    ip pool pool2
     gateway-list 10.1.1.1
     network 10.1.1.0 mask 255.255.255.0
    # 
    interface Vlanif10
     ip address 192.168.20.1 255.255.255.0
    #
    interface Vlanif30
     ip address 10.1.1.1 255.255.255.0
     dhcp select global
    #
    interface GigabitEthernet0/0/1
     port link-type trunk
     port trunk allow-pass vlan 10
    #
    interface GigabitEthernet0/0/2
     port link-type trunk
     port trunk allow-pass vlan 30
    #
    interface Tunnel1
     ip address 192.168.40.1 255.255.255.0
     tunnel-protocol gre
     source 192.168.20.1
     destination 192.168.30.2
    #
    ospf 1
     area 0.0.0.0
      network 192.168.20.0 0.0.0.255
    #
    ip route-static 10.2.1.0 255.255.255.0 Tunnel1
    #
    return
  • Switch_2 configuration file

    #
    sysname Switch_2
    #
    vlan batch 10 20
    #
    interface Vlanif10
     ip address 192.168.20.2 255.255.255.0
    #
    interface Vlanif20
     ip address 192.168.30.1 255.255.255.0
    #
    interface GigabitEthernet0/0/1
     port link-type trunk
     port trunk allow-pass vlan 10
    #
    interface GigabitEthernet0/0/2
     port link-type trunk
     port trunk allow-pass vlan 20
    #
    ospf 1
     area 0.0.0.0
      network 192.168.20.0 0.0.0.255
      network 192.168.30.0 0.0.0.255
    #
    return
  • Switch_3 configuration file

    #
    sysname Switch_3
    #
    vlan batch 20 30
    #
    dhcp enable
    # 
    interface Vlanif20
     ip address 192.168.30.2 255.255.255.0
    #
    interface Vlanif30
     ip address 10.2.1.1 255.255.255.0
     dhcp select relay
     dhcp relay server-ip 10.1.1.1  
    #
    interface GigabitEthernet0/0/1
     port link-type trunk
     port trunk allow-pass vlan 20
    #
    interface GigabitEthernet0/0/2
     port link-type trunk
     port trunk allow-pass vlan 30
    #
    interface Tunnel1
     ip address 192.168.40.2 255.255.255.0
     tunnel-protocol gre
     source 192.168.30.2
     destination 192.168.20.1
    #
    ospf 1
     area 0.0.0.0
      network 192.168.30.0 0.0.0.255
    #
    ip route-static 10.1.1.0 255.255.255.0 Tunnel1
    #
    return
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >