[Enterprise SONiC] DHCP Relay Follow
Tested model & firmware version:
- Switch model name:
DCS204 (AS7726-32X)
- Edgecore SONiC version:
202012.2 ~ 202012.4
202111.0 ~ 202111.8
Topology:
Pre-configuration:
- Ethernet4 breakout to 4x10G.(refer Dynamic Port Breakout)
admin@sonic:~$ show interface status Ethernet4-7
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC Oper Speed
----------- ------- ------- ----- ----- ------------- ------ ------ ------- -------------- ---------- ------------
Ethernet4 5 10G 9100 none Eth2/1(Port2) trunk up up QSFP+ or later N/A 10G
Ethernet5 6 10G 9100 none Eth2/2(Port2) trunk up up QSFP+ or later N/A 10G
Ethernet6 7 10G 9100 none Eth2/3(Port2) routed up up QSFP+ or later N/A 10G
Ethernet7 8 10G 9100 none Eth2/4(Port2) routed down up QSFP+ or later N/A 10G
- VLAN configuration is as topology.(refer to VLAN & Inter-VLAN Routing)
admin@sonic:~$ show vlan brief +-----------+--------------+-----------+-----------+----------+---------------+----------------------------+ | VLAN ID | IP Address | Ports | Port | Proxy | DHCP Helper | DHCP Relay Configuration | | | | | Tagging | ARP | Address | | +===========+==============+===========+===========+==========+===============+============================+ | 10 | | Ethernet4 | untagged | disabled | | Source Interface: | | | | | | | | Link Selection: | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+--------------+-----------+-----------+----------+---------------+----------------------------+ | 20 | | Ethernet5 | untagged | disabled | | Source Interface: | | | | | | | | Link Selection: | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+--------------+-----------+-----------+----------+---------------+----------------------------+
- IP binding is as topology.(refer to Management and front port IPv4/IPv6 Address)
admin@sonic:~$ show ip interfaces
Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP
----------- -------- ------------------- ------------ -------------- -------------
Loopback0 1.1.1.1/32 up/up N/A N/A
Vlan10 192.168.10.1/24 up/up N/A N/A
Vlan20 192.168.20.1/24 up/up N/A N/A
docker0 240.127.1.1/24 up/down N/A N/A
eth0 192.168.254.1/24 up/up N/A N/A
lo 127.0.0.1/16 up/up N/A N/A
Expect result:
DHCP client will get IP from DHCP server. DHCP server will get DHCP request from DHCP client which source IP is Loopback interface IP.
Procedure:
Step 1. Modify the type of DEVICE_METADATA to "ToRRouter" in /etc/sonic/config_db.json.
admin@sonic:~$ sudo sed -i 's/LeafRouter/ToRRouter/g' /etc/sonic/config_db.json
Note: This step is only for the branch 202012 version, other branch versions please start to Step 3.
Step 2. Reboot device to apply the configuration.
admin@sonic:~$ sudo reboot
Step 3. Enable DHCP relay on VLAN10
admin@sonic:~$ sudo config vlan dhcp_relay add 10 192.168.20.100
Added DHCP relay destination address 192.168.20.100 to Vlan10
Restarting DHCP relay service...
Step 4. Modify the src_intf to change the source IP of DHCP relay agent.
admin@sonic:~$ sudo config vlan dhcp_relay src_intf add 10 Loopback0
Added DHCP relay source interface Loopback0 for Vlan10
Restarting DHCP relay service...
Step 5. Check switch can reach to DHCP server and the arp table has been correctly learned.
admin@sonic:~$ show vlan brief +-----------+-----------------+-----------+-----------+----------+----------------+-----------------------------+ | VLAN ID | IP Address | Ports | Port | Proxy | DHCP Helper | DHCP Relay Configuration | | | | | Tagging | ARP | Address | | +===========+=================+===========+===========+==========+================+=============================+ | 10 | 192.168.10.1/24 | Ethernet4 | untagged | disabled | 192.168.20.100 | Source Interface: Loopback0 | | | | | | | | Link Selection: | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+-----------------+-----------+-----------+----------+----------------+-----------------------------+ | 20 | 192.168.20.1/24 | Ethernet5 | untagged | disabled | | Source Interface: | | | | | | | | Link Selection: | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+-----------------+-----------+-----------+----------+----------------+-----------------------------+ admin@sonic:~$ show arp Address MacAddress Iface Vlan --------------- ----------------- --------- ------ 192.168.20.100 3c:fd:fe:ed:bf:bd Ethernet5 20 Total number of entries 1
Result:
As expect result.
- Packet capture
DHCP relay on a single VRF
Tested model & firmware version:
- Switch model name:
DCS203 (AS7326-56X)
- Edgecore SONiC version:
202012.2 ~ 202012.4
202111.0 ~ 202111.8
Topology:
Pre-configuration:
-
VLAN configuration is as topology.(refer to VLAN & Inter-VLAN Routing)
admin@sonic:~$ show vlan brief +-----------+-----------------+-----------+-----------+----------+----------------+-----------------------------+ | VLAN ID | IP Address | Ports | Port | Proxy | DHCP Helper | DHCP Relay Configuration | | | | | Tagging | ARP | Address | | +===========+=================+===========+===========+==========+================+=============================+ | 10 | 192.168.10.1/24 | Ethernet1 | untagged | disabled | | Source Interface: | | | | | | | | Link Selection: | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+-----------------+-----------+-----------+----------+----------------+-----------------------------+ | 20 | 192.168.20.1/24 | Ethernet0 | untagged | disabled | | Source Interface: | | | | | | | | Link Selection: | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+-----------------+-----------+-----------+----------+----------------+-----------------------------+
-
Binding the Interface to VRF. (refer to VRF(Virtual routing and forwarding))
admin@sonic:~$ show vrf
VRF Interfaces
----- ------------
Vrf1 Vlan10
Vlan20 -
IP binding is as topology.(refer to Management and front port IPv4/IPv6 Address)
admin@sonic:~$ show ip interfaces Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP ----------- -------- ------------------- ------------ -------------- ------------- Vlan10 Vrf1 192.168.10.1/24 up/up N/A N/A Vlan20 Vrf1 192.168.20.1/24 up/up N/A N/A docker0 240.127.1.1/24 up/down N/A N/A eth0 188.188.9.11/16 up/up N/A N/A lo 127.0.0.1/16 up/up N/A N/A
Expect result:
DHCP client can get IP via DHCP relay from remote DHCP server.
Procedure:
Step 1. Enable DHCP relay on VLAN10
admin@sonic:~$ sudo config vlan dhcp_relay add 10 192.168.20.100
Added DHCP relay destination addresses ['192.168.20.100'] to Vlan10
Restarting DHCP relay service...
Step 2. Check switch can reach to DHCP server and the arp table has been correctly learned.
admin@sonic:~$ show vlan brief +-----------+-----------------+-----------+-----------+----------+----------------+----------------------------+ | VLAN ID | IP Address | Ports | Port | Proxy | DHCP Helper | DHCP Relay Configuration | | | | | Tagging | ARP | Address | | +===========+=================+===========+===========+==========+================+============================+ | 10 | 192.168.10.1/24 | Ethernet1 | untagged | disabled | 192.168.20.100 | Source Interface: | | | | | | | | Link Selection: | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+-----------------+-----------+-----------+----------+----------------+----------------------------+ | 20 | 192.168.20.1/24 | Ethernet0 | untagged | disabled | | Source Interface: | | | | | | | | Link Selection: | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+-----------------+-----------+-----------+----------+----------------+----------------------------+ admin@sonic:~$ show arp Address MacAddress Iface Vlan --------------- ----------------- --------- ------ 192.168.20.100 3c:fd:fe:ed:bf:bd Ethernet0 20 Total number of entries 1
DHCP relay over different VRFs
Tested model & firmware version:
- Switch model name:
DCS203 (AS7326-56X)
- Edgecore SONiC version:
202012.2 ~ 202012.4
202111.0 ~ 202111.8
Topology:
Pre-configuration:
-
VLAN configuration is as topology. (refer to VLAN & Inter-VLAN Routing)
admin@sonic:~$ show vlan brief +-----------+-----------------+-----------+-----------+----------+---------------+----------------------------+ | VLAN ID | IP Address | Ports | Port | Proxy | DHCP Helper | DHCP Relay Configuration | | | | | Tagging | ARP | Address | | +===========+=================+===========+===========+==========+===============+============================+ | 10 | 192.168.10.1/24 | Ethernet1 | untagged | disabled | | Source Interface: | | | | | | | | Link Selection: | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+-----------------+-----------+-----------+----------+---------------+----------------------------+ | 20 | 192.168.20.1/24 | Ethernet0 | untagged | disabled | | Source Interface: | | | | | | | | Link Selection: | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+-----------------+-----------+-----------+----------+---------------+----------------------------+
-
Binding the Interface to VRF. (refer to VRF(Virtual routing and forwarding))
admin@sonic:~$ show vrf
VRF Interfaces
----- ------------
Vrf1 Vlan10
Vrf2 Vlan20 -
IP binding is as topology.(refer to Management and front port IPv4/IPv6 Address)
admin@sonic:~$ show ip interfaces
Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP
----------- -------- ------------------- ------------ -------------- -------------
Vlan10 Vrf1 192.168.10.1/24 up/up N/A N/A
Vlan20 Vrf2 192.168.20.1/24 up/up N/A N/A
docker0 240.127.1.1/24 up/down N/A N/A
eth0 188.188.36.202/16 up/up N/A N/A
lo 127.0.0.1/16 up/up N/A N/A
Procedure:
Step 1. Enable DHCP relay on VLAN10
admin@sonic:~$ sudo config vlan dhcp_relay add 10 192.168.20.100
Added DHCP relay destination addresses ['192.168.20.100'] to Vlan10
Restarting DHCP relay service...
Step 2. add VRF route leaking. (The routing from the Server's VRF needs to leak to the Client's VRF. )
admin@sonic:~$ vtysh Hello, this is FRRouting (version 8.1). Copyright 1996-2005 Kunihiro Ishiguro, et al. sonic# sonic# configure sonic(config)# vrf Vrf1 sonic(config-vrf)# ip route 192.168.20.0/24 Vlan20 nexthop-vrf Vrf2 admin@sonic:~$ show ip route vrf all Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR, f - OpenFabric, - selected route, * - FIB route, q - queued route, r - rejected route VRF Vrf1: C*192.168.10.0/24 is directly connected, Vlan10, 00:16:59 K*192.168.10.1/32 [0/0] is directly connected, Vlan10, 00:16:59 S*192.168.20.0/24 [1/0] is directly connected, Vlan20,(vrf Vrf2, Vlan20, 00:00:13 VRF Vrf2: C*192.168.20.0/24 is directly connected, Vlan20, 00:03:08 K*192.168.20.1/32 [0/0] is directly connected, Vlan20, 00:03:08 VRF default: K*0.0.0.0/0 [0/202] via 188.188.1.1, eth0, 02:45:13 C*188.188.0.0/16 is directly connected, eth0, 02:45:13
Step 3. Modify the src_intf to change the source IP of DHCP relay agent.
admin@sonic:~$ sudo config vlan dhcp_relay src_intf add 10 Vlan20
Added DHCP relay source interface Vlan20 for Vlan10
Restarting DHCP relay service...
Note: The DHCP server will determine the destination IP of the "DHCP Offer" based on the Relay agent IP address field(IP address of the client-interface) of "DHCP discover" packet. But socket cannot receive "DHCP Offer" from different VRF. Therefore, need to change the Relay agent IP address that designates the source interface in the Server's VRF, and enable the link-selection sub-option.
Step 4. Enable DHCP Link Selection.
admin@sonic:~$ sudo config vlan dhcp_relay link_selection add 10
Enable DHCP relay link selection for Vlan10
Restarting DHCP relay service...
Note: The link-selection sub-option of the Agent information option for the DHCP is used by any DHCP relay agent that desires to specify a subnet/link for a DHCP client request that it is relaying but needs the subnet/link specification to be different from the IP address the DHCP server should use when communicating with the relay agent. Therefore, the link-selection sub-option specifies an IP address that determines a subnet on which the DHCP client is located, and the relay agent IP address field can be used to communicate with the relay agent.
Step 5. Check switch can reach to DHCP server and the arp table has been correctly learned.
admin@sonic:~$ show vlan brief +-----------+-----------------+-----------+-----------+----------+----------------+----------------------------+ | VLAN ID | IP Address | Ports | Port | Proxy | DHCP Helper | DHCP Relay Configuration | | | | | Tagging | ARP | Address | | +===========+=================+===========+===========+==========+================+============================+ | 10 | 192.168.10.1/24 | Ethernet1 | untagged | disabled | 192.168.20.100 | Source Interface: Vlan20 | | | | | | | | Link Selection:enabled | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+-----------------+-----------+-----------+----------+----------------+----------------------------+ | 20 | 192.168.20.1/24 | Ethernet0 | untagged | disabled | | Source Interface: | | | | | | | | Link Selection: | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+-----------------+-----------+-----------+----------+----------------+----------------------------+ admin@sonic:~$ show arp Address MacAddress Iface Vlan --------------- ----------------- --------- ------ 192.168.20.100 3c:fd:fe:ed:bf:bd Ethernet0 20 Total number of entries 1
Result:
After 202111.7, there's a new command used to specify the DHCP relay server VRF on a VLAN.
admin@sonic:~$ sudo config vlan dhcp_relay server_vrf add 10 Vrf2
Added DHCP relay server vrf Vrf2 for Vlan10
Restarting DHCP relay service...
With it, the route leaking(in Step 2) will no longer needed to be set.
admin@sonic:~$ show vlan brief +-----------+-----------------+-----------+-----------+----------+----------------+----------------------------+ | VLAN ID | IP Address | Ports | Port | Proxy | DHCP Helper | DHCP Relay Configuration | | | | | Tagging | ARP | Address | | +===========+=================+===========+===========+==========+================+============================+ | 10 | 192.168.10.1/24 | Ethernet1 | untagged | disabled | 192.168.20.100 | Source Interface: Vlan20 | | | | | | | | Link Selection:enabled | | | | | | | | Server Vrf: Vrf2 | | | | | | | | Server ID Override: | +-----------+-----------------+-----------+-----------+----------+----------------+----------------------------+ | 20 | 192.168.20.1/24 | Ethernet0 | untagged | disabled | | Source Interface: | | | | | | | | Link Selection: | | | | | | | | Server Vrf: | | | | | | | | Server ID Override: | +-----------+-----------------+-----------+-----------+----------+----------------+----------------------------+
DHCP relay on SAG
Tested model & firmware version:
- Switch model name:
EPS202 (AS4630-54PE)
- Edgecore SONiC version:
202111.3~202111.8
Topology:
Pre-configuration:
-
VLAN configuration is as topology. (refer to VLAN & Inter-VLAN Routing)
admin@sonic:~$ show vlan brief
+-----------+-----------------+-----------+-----------+----------+---------------+----------------------------+
| VLAN ID | IP Address | Ports | Port | Proxy | DHCP Helper | DHCP Relay Configuration |
| | | | Tagging | ARP | Address | |
+===========+=================+===========+===========+==========+===============+============================+
| 10 | | Ethernet4 | untagged | disabled | | Source Interface: |
| | | | | | | Link Selection: |
| | | | | | | Server Vrf: |
| | | | | | | Server ID Override: |
+-----------+-----------------+-----------+-----------+----------+---------------+----------------------------+
| 20 | 192.168.20.1/24 | Ethernet0 | untagged | disabled | | Source Interface: |
| | | | | | | Link Selection: |
| | | | | | | Server Vrf: |
| | | | | | | Server ID Override: |
+-----------+-----------------+-----------+-----------+----------+---------------+----------------------------+
-
SAG configuration is as topology. (refer to SAG(static anycast gateway) step8 )
admin@sonic:~$ show sag
Static Anycast Gateway Information
MacAddress IPv4 IPv6
----------------- ------ ------
00:11:22:33:44:55 enable N/A
-
IP binding is as topology.(refer to Management and front port IPv4/IPv6 Address)
admin@sonic:~$ show ip int
Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP
----------- -------- ------------------- ------------ -------------- -------------
Sag10 192.168.10.254/24 up/up N/A N/A
Vlan20 192.168.20.1/24 up/up N/A N/A
docker0 240.127.1.1/24 up/down N/A N/A
eth0 188.188.9.11/16 up/up N/A N/A
lo 127.0.0.1/16 up/up N/A N/A
Procedure:
Step 1. Enable DHCP relay on SAG10
admin@sonic:~$ sudo config sag dhcp_relay add 10 192.168.20.100
Added DHCP relay destination addresses ['192.168.20.1'] to Sag10
Restarting DHCP relay service...
Step 2. Check sag ip
admin@sonic:~$ show sag ip Vlan Interface Name IPv4 address/mask DHCP Helper DHCP Source DHCP Link DHCP Hepler DHCP Server ID Address Interface Selection Vrf Override --------------------- ------------------- ------------- ------------- ----------- ------------- ---------------- Vlan10 192.168.10.254/24 192.168.20.1
Step 3. Check switch can reach to DHCP server and the arp table has been correctly learned.
admin@sonic:~$ show vlan brief
+-----------+-----------------+-----------+-----------+----------+---------------+----------------------------+
| VLAN ID | IP Address | Ports | Port | Proxy | DHCP Helper | DHCP Relay Configuration |
| | | | Tagging | ARP | Address | |
+===========+=================+===========+===========+==========+===============+============================+
| 10 | | Ethernet4 | untagged | disabled | | Source Interface: |
| | | | | | | Link Selection: |
| | | | | | | Server Vrf: |
| | | | | | | Server ID Override: |
+-----------+-----------------+-----------+-----------+----------+---------------+----------------------------+
| 20 | 192.168.20.1/24 | Ethernet0 | untagged | disabled | | Source Interface: |
| | | | | | | Link Selection: |
| | | | | | | Server Vrf: |
| | | | | | | Server ID Override: |
+-----------+-----------------+-----------+-----------+----------+---------------+----------------------------+
admin@sonic:~$ show arp
Address MacAddress Iface Vlan
--------------- ----------------- --------- ------
192.168.20.100 3c:fd:fe:ed:bf:bd Ethernet0 20
Total number of entries 1
Result:
Comments
0 comments
Please sign in to leave a comment.