Configuring DHCP Relay (IPv4)


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 l3-interface vlan-interface <interface-name> address <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:

DHCP relay agent address is a required configuration in VRRP topology, 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.

However, in a non-VRRP topology, there’s no need to configure the DHCP relay agent address. 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 l3-interface vlan-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 l3-interface vlan-interface vlan-2 address 192.168.1.1 prefix-length 24
admin@XorPlus# set l3-interface vlan-interface 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.


Copyright © 2024 Pica8 Inc. All Rights Reserved.