Relay
This scenario shows how to configure service dhcp-relay
. The
relay agent must be used when the DHCP server and the DHCP
clients are not connected to the same layer 2 domain.
Test DHCP Relay
Description
This example demonstrates how to configure a DHCP relay instance in DUT0 to forward DHCP requests from DUT2 to DUT1.
Scenario
Step 1: Set the following configuration in DUT0
:
set interfaces ethernet eth0 vif 100 address 10.0.0.2/24 set interfaces ethernet eth1 vif 200 address 20.0.0.2/24 set service dhcp-relay INS downstream-interface eth1.200 set service dhcp-relay INS server 10.0.0.1 set service dhcp-relay INS upstream-interface eth0.100 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 2: Set the following configuration in DUT1
:
set interfaces ethernet eth0 vif 100 address 10.0.0.1/24 set protocols static route 0.0.0.0/0 next-hop 10.0.0.2 set service dhcp-server shared-network dummy subnet 10.0.0.1/32 set service dhcp-server shared-network remote subnet 20.0.0.0/24 start 20.0.0.50 stop 20.0.0.50 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Set the following configuration in DUT2
:
set interfaces ethernet eth0 vif 200 address dhcp set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 4: Ping IP address 10.0.0.1
from DUT0
:
admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=1.28 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 1.284/1.284/1.284/0.000 ms
Step 5: Run command interfaces ethernet show
at DUT2
and check if output contains the following tokens:
20.0.0.50
Show output
--------------------------------------------------------------------- Name IP Address Admin Oper Vrf Description --------------------------------------------------------------------- eth0 fe80::dcad:beff:feef:6c20/64 up up eth0.200 20.0.0.50/24 up up fe80::dcad:beff:feef:6c20/64 eth1 down down
Test DHCP Relay With Giaddr
Description
This example demonstrates how to set the gateway IP address (giaddr) in the IP address. This value must be set in an IP address that the DHCP server can reach.
Scenario
Step 1: Set the following configuration in DUT0
:
set interfaces ethernet eth0 vif 100 address 10.0.0.2/24 set interfaces ethernet eth1 vif 200 address 20.0.0.2/24 set interfaces ethernet eth1 vif 200 address 20.0.0.3/24 set service dhcp-relay INS downstream-interface eth1.200 set service dhcp-relay INS server 10.0.0.1 giaddr 20.0.0.3 set service dhcp-relay INS upstream-interface eth0.100 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 2: Set the following configuration in DUT1
:
set interfaces ethernet eth0 vif 100 address 10.0.0.1/24 set protocols static route 0.0.0.0/0 next-hop 10.0.0.2 set service dhcp-server shared-network dummy subnet 10.0.0.1/32 set service dhcp-server shared-network remote subnet 20.0.0.0/24 start 20.0.0.50 stop 20.0.0.50 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Set the following configuration in DUT2
:
set interfaces ethernet eth0 vif 200 address dhcp set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 4: Ping IP address 10.0.0.1
from DUT0
:
admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.296 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.296/0.296/0.296/0.000 ms
Step 5: Run command interfaces ethernet show
at DUT2
and check if output contains the following tokens:
20.0.0.50
Show output
--------------------------------------------------------------------- Name IP Address Admin Oper Vrf Description --------------------------------------------------------------------- eth0 fe80::dcad:beff:feef:6c20/64 up up eth0.200 20.0.0.50/24 up up fe80::dcad:beff:feef:6c20/64 eth1 down down
Step 6: Run command system journal show | cat
at DUT1
and check if output matches the following regular expressions:
DHCPACK on 20.0.0.50 to [^\)]+\) via 20.0.0.3Show output
Feb 19 16:44:25.373141 osdx systemd-journald[1553]: Runtime Journal (/run/log/journal/4ae5be8e493042ac8988aa43cad7f38b) is 1.0M, max 7.2M, 6.2M free. Feb 19 16:44:25.376376 osdx systemd-journald[1553]: Received client request to rotate journal, rotating. Feb 19 16:44:25.376471 osdx systemd-journald[1553]: Vacuuming done, freed 0B of archived journals from /run/log/journal/4ae5be8e493042ac8988aa43cad7f38b. Feb 19 16:44:25.391483 osdx OSDxCLI[1795]: User 'admin' executed a new command: 'system journal clear'. Feb 19 16:44:26.102707 osdx osdx-coredump[86285]: Deleting all coredumps in /opt/vyatta/etc/config/coredump... Feb 19 16:44:26.118296 osdx OSDxCLI[1795]: User 'admin' executed a new command: 'system coredump delete all'. Feb 19 16:44:28.595810 osdx OSDxCLI[1795]: User 'admin' entered the configuration menu. Feb 19 16:44:28.732611 osdx OSDxCLI[1795]: User 'admin' added a new cfg line: 'set interfaces eth0.100 address 10.0.0.1/24'. Feb 19 16:44:28.878682 osdx OSDxCLI[1795]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network dummy subnet 10.0.0.1/32'. Feb 19 16:44:29.000293 osdx OSDxCLI[1795]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network remote subnet 20.0.0.0/24 start 20.0.0.50 stop 20.0.0.50'. Feb 19 16:44:29.119465 osdx OSDxCLI[1795]: User 'admin' added a new cfg line: 'set protocols static route 0.0.0.0/0 next-hop 10.0.0.2'. Feb 19 16:44:29.261157 osdx OSDxCLI[1795]: User 'admin' added a new cfg line: 'show working'. Feb 19 16:44:29.406978 osdx INFO[86313]: FRR daemons did not change Feb 19 16:44:29.436377 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0 Feb 19 16:44:29.493152 osdx (udev-worker)[86367]: Network interface NamePolicy= disabled on kernel command line. Feb 19 16:44:29.712906 osdx systemd[1]: Started dhcpd@main.service - "DHCP Server Service instance main". Feb 19 16:44:29.715052 osdx cfgd[1253]: [1795]Completed change to active configuration Feb 19 16:44:29.741633 osdx dhcpd[86386]: Wrote 0 leases to leases file. Feb 19 16:44:29.763718 osdx OSDxCLI[1795]: User 'admin' committed the configuration. Feb 19 16:44:29.787451 osdx dhcpd[86386]: Feb 19 16:44:29.787462 osdx dhcpd[86386]: No subnet declaration for eth0 (no IPv4 addresses). Feb 19 16:44:29.787465 osdx dhcpd[86386]: ** Ignoring requests on eth0. If this is not what Feb 19 16:44:29.787468 osdx dhcpd[86386]: you want, please write a subnet declaration Feb 19 16:44:29.787471 osdx dhcpd[86386]: in your dhcpd.conf file for the network segment Feb 19 16:44:29.787474 osdx dhcpd[86386]: to which interface eth0 is attached. ** Feb 19 16:44:29.787476 osdx dhcpd[86386]: Feb 19 16:44:29.793462 osdx OSDxCLI[1795]: User 'admin' left the configuration menu. Feb 19 16:44:29.796649 osdx dhcpd[86386]: Server starting service. Feb 19 16:44:30.793418 osdx dhcpd[86386]: DHCPDISCOVER from de:ad:be:ef:6c:20 via 20.0.0.3 Feb 19 16:44:31.793778 osdx dhcpd[86386]: DHCPOFFER on 20.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 20.0.0.3 Feb 19 16:44:31.794766 osdx dhcpd[86386]: DHCPREQUEST for 20.0.0.50 (10.0.0.1) from de:ad:be:ef:6c:20 (osdx) via 20.0.0.3 Feb 19 16:44:31.902344 osdx dhcpd[86386]: DHCPACK on 20.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 20.0.0.3
Test DHCP Relay With GRE Tunnel
Description
This example demonstrates how to configure a DHCP relay that forwards DHCP requests to the DHCP server through a GRE tunnel (upstream).
Scenario
Step 1: Set the following configuration in DUT0
:
set interfaces ethernet eth0 vif 100 address 10.0.0.2/24 set interfaces ethernet eth1 vif 200 address 20.0.0.2/24 set interfaces tunnel tun1 address 1.0.0.2/32 set interfaces tunnel tun1 encapsulation gre set interfaces tunnel tun1 local-address 10.0.0.2 set interfaces tunnel tun1 local-interface eth0.100 set interfaces tunnel tun1 nhrp holdtime 5 set interfaces tunnel tun1 nhrp nhs 1.0.0.1 nbma 10.0.0.1 set service dhcp-relay INS downstream-interface eth1.200 set service dhcp-relay INS server 1.0.0.1 set service dhcp-relay INS upstream-interface eth0.100 set service dhcp-relay INS upstream-interface tun1 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 2: Set the following configuration in DUT1
:
set interfaces ethernet eth0 vif 100 address 10.0.0.1/24 set interfaces tunnel tun1 address 1.0.0.1/32 set interfaces tunnel tun1 encapsulation gre set interfaces tunnel tun1 local-address 10.0.0.1 set interfaces tunnel tun1 local-interface eth0.100 set interfaces tunnel tun1 nhrp set protocols static route 0.0.0.0/0 next-hop 10.0.0.2 set protocols static route 20.0.0.0/24 next-hop 1.0.0.2 set service dhcp-server shared-network dummy subnet 1.0.0.1/32 set service dhcp-server shared-network remote subnet 20.0.0.0/24 start 20.0.0.50 stop 20.0.0.50 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Set the following configuration in DUT2
:
set interfaces ethernet eth0 vif 200 address dhcp set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 4: Ping IP address 10.0.0.1
from DUT0
:
admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=1.67 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 1.672/1.672/1.672/0.000 ms
Step 5: Ping IP address 1.0.0.1
from DUT0
:
admin@DUT0$ ping 1.0.0.1 count 1 size 56 timeout 1Show output
PING 1.0.0.1 (1.0.0.1) 56(84) bytes of data. 64 bytes from 1.0.0.1: icmp_seq=1 ttl=64 time=0.353 ms --- 1.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.353/0.353/0.353/0.000 ms
Step 6: Run command interfaces ethernet show
at DUT2
and check if output contains the following tokens:
20.0.0.50
Show output
--------------------------------------------------------------------- Name IP Address Admin Oper Vrf Description --------------------------------------------------------------------- eth0 fe80::dcad:beff:feef:6c20/64 up up eth0.200 20.0.0.50/24 up up fe80::dcad:beff:feef:6c20/64 eth1 down down
Test DHCP Relay With Multiple Instances
Description
This example demonstrates how to configure multiple DHCP relay instances.
Scenario
Step 1: Set the following configuration in DUT0
:
set interfaces ethernet eth0 vif 100 address 10.0.0.2/24 set interfaces ethernet eth1 vif 200 address 20.0.0.2/24 set interfaces ethernet eth1 vif 300 address 30.0.0.2/24 set service dhcp-relay INS downstream-interface eth1.200 set service dhcp-relay INS server 10.0.0.1 set service dhcp-relay INS upstream-interface eth0.100 set service dhcp-relay INS2 downstream-interface eth1.300 set service dhcp-relay INS2 server 10.0.0.1 set service dhcp-relay INS2 upstream-interface eth0.100 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 2: Set the following configuration in DUT1
:
set interfaces ethernet eth0 vif 100 address 10.0.0.1/24 set protocols static route 0.0.0.0/0 next-hop 10.0.0.2 set service dhcp-server shared-network dummy subnet 10.0.0.1/32 set service dhcp-server shared-network remote subnet 20.0.0.0/24 start 20.0.0.50 stop 20.0.0.50 set service dhcp-server shared-network remote2 subnet 30.0.0.0/24 start 30.0.0.50 stop 30.0.0.50 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Set the following configuration in DUT2
:
set interfaces ethernet eth0 vif 200 address dhcp set interfaces ethernet eth0 vif 300 address dhcp set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 4: Ping IP address 10.0.0.1
from DUT0
:
admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.462 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.462/0.462/0.462/0.000 ms
Step 5: Run command interfaces ethernet show
at DUT2
and check if output contains the following tokens:
20.0.0.50
Show output
--------------------------------------------------------------------- Name IP Address Admin Oper Vrf Description --------------------------------------------------------------------- eth0 fe80::dcad:beff:feef:6c20/64 up up eth0.200 20.0.0.50/24 up up fe80::dcad:beff:feef:6c20/64 eth0.300 30.0.0.50/24 up up fe80::dcad:beff:feef:6c20/64 eth1 down down
Step 6: Run command interfaces ethernet show
at DUT2
and check if output contains the following tokens:
30.0.0.50
Show output
--------------------------------------------------------------------- Name IP Address Admin Oper Vrf Description --------------------------------------------------------------------- eth0 fe80::dcad:beff:feef:6c20/64 up up eth0.200 20.0.0.50/24 up up fe80::dcad:beff:feef:6c20/64 eth0.300 30.0.0.50/24 up up fe80::dcad:beff:feef:6c20/64 eth1 down down
Step 7: Run command system journal show | cat
at DUT1
and check if output matches the following regular expressions:
DHCPACK on 20.0.0.50 to [^\)]+\) via 20.0.0.2 DHCPACK on 30.0.0.50 to [^\)]+\) via 30.0.0.2Show output
Feb 19 16:45:14.000476 osdx systemd-timedated[86969]: Changed local time to Wed 2025-02-19 16:45:14 UTC Feb 19 16:45:14.003876 osdx OSDxCLI[1795]: User 'admin' executed a new command: 'set date 2025-02-19 16:45:14'. Feb 19 16:45:14.004493 osdx systemd-journald[1553]: Time jumped backwards, rotating. Feb 19 16:45:14.528319 osdx systemd-journald[1553]: Runtime Journal (/run/log/journal/4ae5be8e493042ac8988aa43cad7f38b) is 1.0M, max 7.2M, 6.2M free. Feb 19 16:45:14.529099 osdx systemd-journald[1553]: Received client request to rotate journal, rotating. Feb 19 16:45:14.529172 osdx systemd-journald[1553]: Vacuuming done, freed 0B of archived journals from /run/log/journal/4ae5be8e493042ac8988aa43cad7f38b. Feb 19 16:45:14.550737 osdx OSDxCLI[1795]: User 'admin' executed a new command: 'system journal clear'. Feb 19 16:45:15.392960 osdx osdx-coredump[86987]: Deleting all coredumps in /opt/vyatta/etc/config/coredump... Feb 19 16:45:15.406498 osdx OSDxCLI[1795]: User 'admin' executed a new command: 'system coredump delete all'. Feb 19 16:45:18.418765 osdx OSDxCLI[1795]: User 'admin' entered the configuration menu. Feb 19 16:45:18.558270 osdx OSDxCLI[1795]: User 'admin' added a new cfg line: 'set interfaces eth0.100 address 10.0.0.1/24'. Feb 19 16:45:18.661934 osdx OSDxCLI[1795]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network dummy subnet 10.0.0.1/32'. Feb 19 16:45:18.775192 osdx OSDxCLI[1795]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network remote subnet 20.0.0.0/24 start 20.0.0.50 stop 20.0.0.50'. Feb 19 16:45:18.875713 osdx OSDxCLI[1795]: User 'admin' added a new cfg line: 'set protocols static route 0.0.0.0/0 next-hop 10.0.0.2'. Feb 19 16:45:19.000701 osdx OSDxCLI[1795]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network remote2 subnet 30.0.0.0/24 start 30.0.0.50 stop 30.0.0.50'. Feb 19 16:45:19.159766 osdx OSDxCLI[1795]: User 'admin' added a new cfg line: 'show working'. Feb 19 16:45:19.349250 osdx INFO[87018]: FRR daemons did not change Feb 19 16:45:19.384506 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0 Feb 19 16:45:19.438127 osdx (udev-worker)[87067]: Network interface NamePolicy= disabled on kernel command line. Feb 19 16:45:19.649353 osdx systemd[1]: Started dhcpd@main.service - "DHCP Server Service instance main". Feb 19 16:45:19.653942 osdx dhcpd[87091]: Wrote 0 leases to leases file. Feb 19 16:45:19.654075 osdx cfgd[1253]: [1795]Completed change to active configuration Feb 19 16:45:19.698100 osdx dhcpd[87091]: Feb 19 16:45:19.698110 osdx dhcpd[87091]: No subnet declaration for eth0 (no IPv4 addresses). Feb 19 16:45:19.698115 osdx dhcpd[87091]: ** Ignoring requests on eth0. If this is not what Feb 19 16:45:19.698119 osdx dhcpd[87091]: you want, please write a subnet declaration Feb 19 16:45:19.698123 osdx dhcpd[87091]: in your dhcpd.conf file for the network segment Feb 19 16:45:19.698127 osdx dhcpd[87091]: to which interface eth0 is attached. ** Feb 19 16:45:19.698130 osdx dhcpd[87091]: Feb 19 16:45:19.709584 osdx OSDxCLI[1795]: User 'admin' committed the configuration. Feb 19 16:45:19.720782 osdx dhcpd[87091]: Server starting service. Feb 19 16:45:19.749068 osdx OSDxCLI[1795]: User 'admin' left the configuration menu. Feb 19 16:45:21.174625 osdx dhcpd[87091]: DHCPDISCOVER from de:ad:be:ef:6c:20 via 20.0.0.2 Feb 19 16:45:21.523179 osdx dhcpd[87091]: DHCPDISCOVER from de:ad:be:ef:6c:20 via 30.0.0.2 Feb 19 16:45:22.175135 osdx dhcpd[87091]: DHCPOFFER on 20.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 20.0.0.2 Feb 19 16:45:22.176642 osdx dhcpd[87091]: DHCPREQUEST for 20.0.0.50 (10.0.0.1) from de:ad:be:ef:6c:20 (osdx) via 20.0.0.2 Feb 19 16:45:22.222273 osdx dhcpd[87091]: DHCPACK on 20.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 20.0.0.2 Feb 19 16:45:22.523621 osdx dhcpd[87091]: DHCPOFFER on 30.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 30.0.0.2 Feb 19 16:45:22.524595 osdx dhcpd[87091]: DHCPREQUEST for 30.0.0.50 (10.0.0.1) from de:ad:be:ef:6c:20 (osdx) via 30.0.0.2 Feb 19 16:45:22.545173 osdx dhcpd[87091]: DHCPACK on 30.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 30.0.0.2