Programmable Internetworking & Communication Operating System Docs ... Click Spaces -> Space Directory to see docs for all releases ...
Page tree
Skip to end of metadata
Go to start of metadata

As DHCP is used to send the request packet during the dynamic acquisition of IP address, DHCP is only applicable to the case where the DHCP client and the server are on the same subnet.

For this reason, you have to set up a DHCP server on each network segment for dynamic host configuration, which is obviously very uneconomical. The introduction of DHCP relay function solves this problem: the client can communicate with the DHCP server of other network segment through DHCP relay agent, to obtain the IP address finally. In this way, DHCP clients on multiple networks can share the same DHCP server, which saves the cost as well facilitates centralized management.

Note that: the configuration and processing of DHCP relay function have nothing to do with the DHCP snooping trust port.

NOTE:

  • DHCP relay supports VRF function by binding DHCP client VLAN interface to a specified VRF.
  • When configuring DHCP relay, the VLAN interface connected to the clients and the VLAN interface connected to the DHCP server should be in the same VRF.


Procedure

Step 1        Configure VLAN.

               a). Configure VLAN ID.

     set vlans vlan-id <vlan-id>

       b). Add an interface to the VLAN.

    set interface gigabit-ethernet <port> family ethernet-switching native-vlan-id <vlan-id>

               c). Associate a Layer 3 interface with a VLAN.

            set vlans vlan-id <vlan-id> l3-interface <interface-name>

       d). Configure the IP address for the VLAN interface to implement Layer 3 connectivity.

    set vlan-interface interface <interface-name> vif <vif-nameaddress <addressprefix-length <number>

Step 2       Enable IP routing function when using DHCP relay.

  set ip routing enable <true | false>

Step 3       Enable the DHCP relay function on the L3 VLAN interface connected to the client.

  set protocols dhcp relay interface <vlan-interface-name> disable <true | false>

Step 4       Configure the IP address of the DHCP server.

  set protocols dhcp relay interface<vlan-interface-namedhcp-server-address <ipv4-address>

  Note that the VLAN interface is L3 VLAN interface that connected to the client.

Step 5       (Optional) Configure the IP address of the DHCP relay agent.

  set protocols dhcp relay interface <vlan-interface-name> relay-agent-address <agent-ipv4-address>

NOTE:

  • In VRRP topology, DHCP relay agent address is a required configuration, when the VRRP Master/Backup devices are used as the DHCP relay agents, you must configure the DHCP relay agent address to the virtual IP address of the VRRP group. The interface name here should be configured with the L3 VLAN interface which is enabled with DHCP relay and VRRP group.
  • In a non-VRRP topology, but MLAG peer-gateway functionality is enabled, you have to configure a DHCP relay agent address using this command to make DHCP relay work properly. In this case, interface <vlan-interface-name> is the VLAN interface with DHCP relay enabled; relay-agent-address <agent-ipv4-address> needs to be configured as an IP in the same network segment as the VLAN interface but a different value. Note that the DHCP relay agent address should be identical on both MLAG peer devices.
  • Do not configure the DHCP relay agent address when in a non-VRRP topology, and MLAG peer-gateway functionality is not enabled. By default, the system sets the IP address of the L3 VLAN interface that enabled DHCP relay as the DHCP relay agent address.

Step 6       (Optional) Configure the DHCP relay Option 82 policy and the sub-options.

  set protocols dhcp relay interface <vlan-interface-name> option82-policy <drop | keep | insert | replace>

  set protocols dhcp relay option82 circuit-id <port-index | port-name | port-description>

  set protocols dhcp relay option82 remote-id <system-mac | hostname>

Step 7       (Optional) Enable Option 82 trust-all function for DHCP relay.

  set protocols dhcp relay option82 trust-all <true | false>

Step 8       (Optional) Configuring DHCP relay in a VRF.

                  To enable DHCP relay in a VRF, the configuration method is to bind the DHCP client side VLAN interface to a user-defined VRF by using the following command.

  set vlan-interface interface <interface-name> vrf <vrf-name>                 

  By default, the VLAN interface is bound to the default VRF if not specified to a user-defined VRF.

  If DHCP relay is deployed in a VRF, this step is required. The VLAN interface connected to the clients and the VLAN interface connected to the DHCP server should be in the same VRF. Otherwise, the DHCP client cannot obtain the IP address normally.

Configuration Example

Networking Requirements

  • On PICA8 Switch, the interfaces ge-1/1/1 belongs to VLAN 2 and ge-1/1/2 belongs to VLAN 3.
  • The L3 VLAN interface associated with VLAN 2 is vlan-2, the interface IP is 192.168.1.1/24; The L3 VLAN interface associated with VLAN 3 is vlan-3, the interface IP is 192.168.2.1/24.
  • Enable DHCP relay function on the L3 VLAN interface vlan-2.
  • The IP address of DHCP server is 192.168.2.100.

Figure 1 DHCP Relay Network



Procedure

Step 1        Configure VLAN.

admin@XorPlus# set vlans vlan-id 2
admin@XorPlus# set vlans vlan-id 3
admin@XorPlus# set interface gigabit-ethernet ge-1/1/1 family ethernet-switching native-vlan-id 2
admin@XorPlus# set interface gigabit-ethernet ge-1/1/2 family ethernet-switching native-vlan-id 3
admin@XorPlus# set interface gigabit-ethernet ge-1/1/1 family ethernet-switching port-mode trunk
admin@XorPlus# set interface gigabit-ethernet ge-1/1/2 family ethernet-switching port-mode trunk
admin@XorPlus# set vlan-interface interface vlan-2 vif vlan-2 address 192.168.1.1 prefix-length 24
admin@XorPlus# set vlan-interface interface vlan-3 vif vlan-3 address 192.168.2.1 prefix-length 24
admin@XorPlus# set vlans vlan-id 2 l3-interface vlan-2
admin@XorPlus# set vlans vlan-id 3 l3-interface vlan-3

Step 2       Enable IP routing function when using DHCP relay.

admin@XorPlus# set ip routing enable true

Step 3       Enable the DHCP relay function on L3 VLAN interface vlan-2.

admin@XorPlus# set protocols dhcp relay interface vlan-2 disable false

Step 4       Configure the IP address of DHCP server 192.168.2.100.

admin@XorPlus# set protocols dhcp relay interface vlan-2 dhcp-server-address 192.168.2.100

Step 5       Commit the configuration.

admin@XorPlus# commit

Step 6       Verify the configuration.

  • After the configuration is complete, run the show protocols dhcp relay command to view the configuration of DHCP relay.
admin@Xorplus# show protocols dhcp relay
    interface vlan-2 {
        disable: false
        dhcp-server-address 192.168.2.100
        relay-agent-address: 192.168.1.1
   }
  • DHCP client can obtain the IP address normally.
  • No labels