Default Router

This scenario shows how to configure an Ethernet interface with DHCP and manage default route options. (Dynamic Host Configuration Protocol).

../../../../_images/dhcp3.svg

Test DHCP client disable default route

Description

This example show how to configure the client to avoid installing the default route via the default gateway provided by DHCP server.

Scenario

Step 1: Set the following configuration in DUT1 :

set interfaces dummy dum0 address 10.0.0.1/24
set interfaces ethernet eth0 address 192.168.100.1/24
set service dhcp-server shared-network dhcpserver subnet 192.168.100.0/24 options default-router 192.168.100.1
set service dhcp-server shared-network dhcpserver subnet 192.168.100.0/24 start 192.168.100.50 stop 192.168.100.50
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT0 :

set interfaces ethernet eth0 address dhcp
set interfaces ethernet eth0 dhcp client receive default-router disable
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Run command interfaces ethernet show at DUT0 and check if output contains the following tokens:

192.168.100.50/24
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
eth0  192.168.100.50/24             up     up
      fe80::dcad:beff:feef:6c00/64
eth1                                down   down

Step 4: Run command service dhcp-client show leases interface eth0 at DUT0 and check if output contains the following tokens:

192.168.100.50
Show output
Interface:     eth0
IP address:    192.168.100.50
Subnet mask:   255.255.255.0
Routers:       192.168.100.1
Name-servers:
Domain-name:
NTP servers:
DHCP server:   192.168.100.1
Lease time:    43200
Expiry date:   Sat Oct 11 07:58:21 2025
Reason:        BOUND

Step 5: Run command protocols ip show route at DUT0 and expect this output:

Show output
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
C>* 192.168.100.0/24 is directly connected, eth0, weight 1, 00:00:01
K * 192.168.100.0/24 [0/0] is directly connected, eth0, weight 1, 00:00:01
L>* 192.168.100.50/32 is directly connected, eth0, weight 1, 00:00:01
L>  192.168.100.100/32 is directly connected, eth0 inactive, weight 1, 00:00:11

Step 6: Ping IP address 192.168.100.1 from DUT0:

admin@DUT0$ ping 192.168.100.1 count 1 size 56 timeout 1
Show output
PING 192.168.100.1 (192.168.100.1) 56(84) bytes of data.
64 bytes from 192.168.100.1: icmp_seq=1 ttl=64 time=0.225 ms

--- 192.168.100.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.225/0.225/0.225/0.000 ms

Step 7: Expect a failure in the following command: 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: connect: Network is unreachable

Test DHCP client disable default route VRF

Description

This example show how to configure the client to avoid installing the default route via the default gateway provided by DHCP server in a VRF.

Scenario

Step 1: Set the following configuration in DUT1 :

set interfaces dummy dum0 address 10.0.0.1/24
set interfaces dummy dum0 vrf VRF
set interfaces ethernet eth0 address 192.168.100.1/24
set interfaces ethernet eth0 vrf VRF
set service dhcp-server shared-network dhcpserver local-vrf VRF
set service dhcp-server shared-network dhcpserver subnet 192.168.100.0/24 options default-router 192.168.100.1
set service dhcp-server shared-network dhcpserver subnet 192.168.100.0/24 start 192.168.100.50 stop 192.168.100.50
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
set system vrf VRF

Step 2: Set the following configuration in DUT0 :

set interfaces ethernet eth0 address dhcp
set interfaces ethernet eth0 dhcp client receive default-router disable
set interfaces ethernet eth0 vrf VRF
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
set system vrf VRF

Step 3: Run command interfaces ethernet show at DUT0 and check if output contains the following tokens:

192.168.100.50/24
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
eth0  192.168.100.50/24             up     up    VRF
      fe80::dcad:beff:feef:6c00/64
eth1                                down   down

Step 4: Run command service dhcp-client show leases interface eth0 at DUT0 and check if output contains the following tokens:

192.168.100.50
Show output
Interface:     eth0
IP address:    192.168.100.50
Subnet mask:   255.255.255.0
Routers:       192.168.100.1
Name-servers:
Domain-name:
NTP servers:
DHCP server:   192.168.100.1
Lease time:    43200
Expiry date:   Sat Oct 11 07:58:30 2025
Reason:        BOUND

Step 5: Run command protocols vrf VRF ip show route at DUT0 and expect this output:

Show output
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF VRF:
K>* 0.0.0.0/0 [255/8192] unreachable (ICMP unreachable), weight 1, 00:00:03
C>* 192.168.100.0/24 is directly connected, eth0, weight 1, 00:00:02
K * 192.168.100.0/24 [0/0] is directly connected, eth0, weight 1, 00:00:02
L>* 192.168.100.50/32 is directly connected, eth0, weight 1, 00:00:02

Step 6: Ping IP address 192.168.100.1 from DUT0:

admin@DUT0$ ping 192.168.100.1 vrf VRF count 1 size 56 timeout 1
Show output
ping: Warning: source address might be selected on device other than: VRF
PING 192.168.100.1 (192.168.100.1) from 192.168.100.50 VRF: 56(84) bytes of data.
64 bytes from 192.168.100.1: icmp_seq=1 ttl=64 time=0.220 ms

--- 192.168.100.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.220/0.220/0.220/0.000 ms

Step 7: Expect a failure in the following command: Ping IP address 10.0.0.1 from DUT0:

admin@DUT0$ ping 10.0.0.1 vrf VRF count 1 size 56 timeout 1
Show output
ping: connect: No route to host

Test DHCP client set default route distance

Description

This example show how to configure the client to avoid installing the default route with a weight of 1 via the default gateway provided by DHCP server.

Scenario

Step 1: Set the following configuration in DUT1 :

set interfaces dummy dum0 address 10.0.0.1/24
set interfaces ethernet eth0 address 192.168.100.1/24
set service dhcp-server shared-network dhcpserver subnet 192.168.100.0/24 options default-router 192.168.100.1
set service dhcp-server shared-network dhcpserver subnet 192.168.100.0/24 start 192.168.100.50 stop 192.168.100.50
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT0 :

set interfaces ethernet eth0 address dhcp
set interfaces ethernet eth0 dhcp client receive default-router distance 200
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Run command interfaces ethernet show at DUT0 and check if output contains the following tokens:

192.168.100.50/24
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
eth0  192.168.100.50/24             up     up
      fe80::dcad:beff:feef:6c00/64
eth1                                down   down

Step 4: Run command service dhcp-client show leases interface eth0 at DUT0 and check if output contains the following tokens:

192.168.100.50
Show output
Interface:     eth0
IP address:    192.168.100.50
Subnet mask:   255.255.255.0
Routers:       192.168.100.1
Name-servers:
Domain-name:
NTP servers:
DHCP server:   192.168.100.1
Lease time:    43200
Expiry date:   Sat Oct 11 07:58:41 2025
Reason:        BOUND

Step 5: Run command protocols ip show route at DUT0 and expect this output:

Show output
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
S>* 0.0.0.0/0 [200/0] via 192.168.100.1, eth0, weight 1, 00:00:02
C>* 192.168.100.0/24 is directly connected, eth0, weight 1, 00:00:02
K * 192.168.100.0/24 [0/0] is directly connected, eth0, weight 1, 00:00:02
L>* 192.168.100.50/32 is directly connected, eth0, weight 1, 00:00:02
L>  192.168.100.100/32 is directly connected, eth0 inactive, weight 1, 00:00:31

Step 6: Ping IP address 192.168.100.1 from DUT0:

admin@DUT0$ ping 192.168.100.1 count 1 size 56 timeout 1
Show output
PING 192.168.100.1 (192.168.100.1) 56(84) bytes of data.
64 bytes from 192.168.100.1: icmp_seq=1 ttl=64 time=0.247 ms

--- 192.168.100.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.247/0.247/0.247/0.000 ms

Step 7: 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.236 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.236/0.236/0.236/0.000 ms

Test DHCP client set default route distance VRF

Description

This example show how to configure the client to avoid installing the default route with a weight of 1 via the default gateway provided by DHCP server in a VRF.

Scenario

Step 1: Set the following configuration in DUT1 :

set interfaces dummy dum0 address 10.0.0.1/24
set interfaces dummy dum0 vrf VRF
set interfaces ethernet eth0 address 192.168.100.1/24
set interfaces ethernet eth0 vrf VRF
set service dhcp-server shared-network dhcpserver local-vrf VRF
set service dhcp-server shared-network dhcpserver subnet 192.168.100.0/24 options default-router 192.168.100.1
set service dhcp-server shared-network dhcpserver subnet 192.168.100.0/24 start 192.168.100.50 stop 192.168.100.50
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
set system vrf VRF

Step 2: Set the following configuration in DUT0 :

set interfaces ethernet eth0 address dhcp
set interfaces ethernet eth0 dhcp client receive default-router distance 200
set interfaces ethernet eth0 vrf VRF
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
set system vrf VRF

Step 3: Run command interfaces ethernet show at DUT0 and check if output contains the following tokens:

192.168.100.50/24
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
eth0  192.168.100.50/24             up     up    VRF
      fe80::dcad:beff:feef:6c00/64
eth1                                down   down

Step 4: Run command service dhcp-client show leases interface eth0 at DUT0 and check if output contains the following tokens:

192.168.100.50
Show output
Interface:     eth0
IP address:    192.168.100.50
Subnet mask:   255.255.255.0
Routers:       192.168.100.1
Name-servers:
Domain-name:
NTP servers:
DHCP server:   192.168.100.1
Lease time:    43200
Expiry date:   Sat Oct 11 07:58:51 2025
Reason:        BOUND

Step 5: Run command protocols vrf VRF ip show route at DUT0 and expect this output:

Show output
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF VRF:
S>* 0.0.0.0/0 [200/0] via 192.168.100.1, eth0, weight 1, 00:00:02
K * 0.0.0.0/0 [255/8192] unreachable (ICMP unreachable), weight 1, 00:00:03
C>* 192.168.100.0/24 is directly connected, eth0, weight 1, 00:00:02
K * 192.168.100.0/24 [0/0] is directly connected, eth0, weight 1, 00:00:02
L>* 192.168.100.50/32 is directly connected, eth0, weight 1, 00:00:02

Step 6: Ping IP address 192.168.100.1 from DUT0:

admin@DUT0$ ping 192.168.100.1 vrf VRF count 1 size 56 timeout 1
Show output
ping: Warning: source address might be selected on device other than: VRF
PING 192.168.100.1 (192.168.100.1) from 192.168.100.50 VRF: 56(84) bytes of data.
64 bytes from 192.168.100.1: icmp_seq=1 ttl=64 time=0.240 ms

--- 192.168.100.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.240/0.240/0.240/0.000 ms

Step 7: Ping IP address 10.0.0.1 from DUT0:

admin@DUT0$ ping 10.0.0.1 vrf VRF count 1 size 56 timeout 1
Show output
ping: Warning: source address might be selected on device other than: VRF
PING 10.0.0.1 (10.0.0.1) from 192.168.100.50 VRF: 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.247 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.247/0.247/0.247/0.000 ms