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.

../../../_images/toplogy.svg

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 1
Show 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.245 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.245/0.245/0.245/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:6c30/64  up     up
eth0.200  20.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c30/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 1
Show 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.235 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.235/0.235/0.235/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:6c30/64  up     up
eth0.200  20.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c30/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.3
Show output
Jul 03 16:31:07.277938 osdx systemd-journald[1553]: Runtime Journal (/run/log/journal/831aeca402c6428e9ad074105f874d77) is 2.4M, max 9.7M, 7.3M free.
Jul 03 16:31:07.280942 osdx systemd-journald[1553]: Received client request to rotate journal, rotating.
Jul 03 16:31:07.281000 osdx systemd-journald[1553]: Vacuuming done, freed 0B of archived journals from /run/log/journal/831aeca402c6428e9ad074105f874d77.
Jul 03 16:31:07.290839 osdx OSDxCLI[51782]: User 'admin' executed a new command: 'system journal clear'.
Jul 03 16:31:07.755880 osdx osdx-coredump[142689]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Jul 03 16:31:07.763737 osdx OSDxCLI[51782]: User 'admin' executed a new command: 'system coredump delete all'.
Jul 03 16:31:09.236811 osdx OSDxCLI[51782]: User 'admin' entered the configuration menu.
Jul 03 16:31:09.416617 osdx OSDxCLI[51782]: User 'admin' added a new cfg line: 'set interfaces eth0.100 address 10.0.0.1/24'.
Jul 03 16:31:09.514859 osdx OSDxCLI[51782]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network dummy subnet 10.0.0.1/32'.
Jul 03 16:31:09.597995 osdx OSDxCLI[51782]: 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'.
Jul 03 16:31:09.716144 osdx OSDxCLI[51782]: User 'admin' added a new cfg line: 'set protocols static route 0.0.0.0/0 next-hop 10.0.0.2'.
Jul 03 16:31:09.853408 osdx OSDxCLI[51782]: User 'admin' added a new cfg line: 'show working'.
Jul 03 16:31:09.949665 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
Jul 03 16:31:09.962020 osdx (udev-worker)[142734]: Network interface NamePolicy= disabled on kernel command line.
Jul 03 16:31:10.217233 osdx systemd[1]: Started dhcpd@main.service - "DHCP Server Service instance main".
Jul 03 16:31:10.219785 osdx cfgd[1223]: [51782]Completed change to active configuration
Jul 03 16:31:10.224102 osdx dhcpd[142755]: Wrote 0 leases to leases file.
Jul 03 16:31:10.245910 osdx dhcpd[142755]:
Jul 03 16:31:10.245915 osdx dhcpd[142755]: No subnet declaration for eth0 (no IPv4 addresses).
Jul 03 16:31:10.245918 osdx dhcpd[142755]: ** Ignoring requests on eth0.  If this is not what
Jul 03 16:31:10.245920 osdx dhcpd[142755]:    you want, please write a subnet declaration
Jul 03 16:31:10.245922 osdx dhcpd[142755]:    in your dhcpd.conf file for the network segment
Jul 03 16:31:10.245924 osdx dhcpd[142755]:    to which interface eth0 is attached. **
Jul 03 16:31:10.245926 osdx dhcpd[142755]:
Jul 03 16:31:10.250660 osdx OSDxCLI[51782]: User 'admin' committed the configuration.
Jul 03 16:31:10.253742 osdx dhcpd[142755]: Server starting service.
Jul 03 16:31:10.279372 osdx OSDxCLI[51782]: User 'admin' left the configuration menu.
Jul 03 16:31:10.900091 osdx dhcpd[142755]: DHCPDISCOVER from de:ad:be:ef:6c:30 via 20.0.0.3
Jul 03 16:31:11.901111 osdx dhcpd[142755]: DHCPOFFER on 20.0.0.50 to de:ad:be:ef:6c:30 (osdx) via 20.0.0.3
Jul 03 16:31:11.902260 osdx dhcpd[142755]: DHCPREQUEST for 20.0.0.50 (10.0.0.1) from de:ad:be:ef:6c:30 (osdx) via 20.0.0.3
Jul 03 16:31:11.937078 osdx dhcpd[142755]: DHCPACK on 20.0.0.50 to de:ad:be:ef:6c:30 (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 1
Show 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.238 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.238/0.238/0.238/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 1
Show 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.255 ms

--- 1.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.255/0.255/0.255/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:6c30/64  up     up
eth0.200  20.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c30/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 1
Show 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.404 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.404/0.404/0.404/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:6c30/64  up     up
eth0.200  20.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c30/64
eth0.300  30.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c30/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:6c30/64  up     up
eth0.200  20.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c30/64
eth0.300  30.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c30/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.2
Show output
Jul 03 16:31:29.276050 osdx systemd-journald[1553]: Runtime Journal (/run/log/journal/831aeca402c6428e9ad074105f874d77) is 2.4M, max 9.7M, 7.3M free.
Jul 03 16:31:29.277560 osdx systemd-journald[1553]: Received client request to rotate journal, rotating.
Jul 03 16:31:29.277620 osdx systemd-journald[1553]: Vacuuming done, freed 0B of archived journals from /run/log/journal/831aeca402c6428e9ad074105f874d77.
Jul 03 16:31:29.288607 osdx OSDxCLI[51782]: User 'admin' executed a new command: 'system journal clear'.
Jul 03 16:31:29.723835 osdx osdx-coredump[143277]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Jul 03 16:31:29.731728 osdx OSDxCLI[51782]: User 'admin' executed a new command: 'system coredump delete all'.
Jul 03 16:31:31.187975 osdx OSDxCLI[51782]: User 'admin' entered the configuration menu.
Jul 03 16:31:31.251116 osdx OSDxCLI[51782]: User 'admin' added a new cfg line: 'set interfaces eth0.100 address 10.0.0.1/24'.
Jul 03 16:31:31.350362 osdx OSDxCLI[51782]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network dummy subnet 10.0.0.1/32'.
Jul 03 16:31:31.406151 osdx OSDxCLI[51782]: 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'.
Jul 03 16:31:31.502818 osdx OSDxCLI[51782]: User 'admin' added a new cfg line: 'set protocols static route 0.0.0.0/0 next-hop 10.0.0.2'.
Jul 03 16:31:31.571594 osdx OSDxCLI[51782]: 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'.
Jul 03 16:31:31.700344 osdx OSDxCLI[51782]: User 'admin' added a new cfg line: 'show working'.
Jul 03 16:31:31.805484 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
Jul 03 16:31:31.820205 osdx (udev-worker)[143325]: Network interface NamePolicy= disabled on kernel command line.
Jul 03 16:31:31.949415 osdx systemd[1]: Started dhcpd@main.service - "DHCP Server Service instance main".
Jul 03 16:31:31.952045 osdx cfgd[1223]: [51782]Completed change to active configuration
Jul 03 16:31:31.956000 osdx dhcpd[143346]: Wrote 0 leases to leases file.
Jul 03 16:31:31.980410 osdx OSDxCLI[51782]: User 'admin' committed the configuration.
Jul 03 16:31:31.982531 osdx dhcpd[143346]:
Jul 03 16:31:31.982536 osdx dhcpd[143346]: No subnet declaration for eth0 (no IPv4 addresses).
Jul 03 16:31:31.982538 osdx dhcpd[143346]: ** Ignoring requests on eth0.  If this is not what
Jul 03 16:31:31.982540 osdx dhcpd[143346]:    you want, please write a subnet declaration
Jul 03 16:31:31.982543 osdx dhcpd[143346]:    in your dhcpd.conf file for the network segment
Jul 03 16:31:31.982545 osdx dhcpd[143346]:    to which interface eth0 is attached. **
Jul 03 16:31:31.982547 osdx dhcpd[143346]:
Jul 03 16:31:31.989137 osdx dhcpd[143346]: Server starting service.
Jul 03 16:31:31.994835 osdx OSDxCLI[51782]: User 'admin' left the configuration menu.
Jul 03 16:31:32.608023 osdx dhcpd[143346]: DHCPDISCOVER from de:ad:be:ef:6c:30 via 20.0.0.2
Jul 03 16:31:32.711978 osdx dhcpd[143346]: DHCPDISCOVER from de:ad:be:ef:6c:30 via 30.0.0.2
Jul 03 16:31:33.609042 osdx dhcpd[143346]: DHCPOFFER on 20.0.0.50 to de:ad:be:ef:6c:30 (osdx) via 20.0.0.2
Jul 03 16:31:33.610621 osdx dhcpd[143346]: DHCPREQUEST for 20.0.0.50 (10.0.0.1) from de:ad:be:ef:6c:30 (osdx) via 20.0.0.2
Jul 03 16:31:33.648403 osdx dhcpd[143346]: DHCPACK on 20.0.0.50 to de:ad:be:ef:6c:30 (osdx) via 20.0.0.2
Jul 03 16:31:33.712253 osdx dhcpd[143346]: DHCPOFFER on 30.0.0.50 to de:ad:be:ef:6c:30 (osdx) via 30.0.0.2
Jul 03 16:31:33.713292 osdx dhcpd[143346]: DHCPREQUEST for 30.0.0.50 (10.0.0.1) from de:ad:be:ef:6c:30 (osdx) via 30.0.0.2
Jul 03 16:31:33.722681 osdx dhcpd[143346]: DHCPACK on 30.0.0.50 to de:ad:be:ef:6c:30 (osdx) via 30.0.0.2