Dhcp Route

This scenario shows how to configure a static route with a DHCP interface.

../../../../../_images/dhcp1.svg

Test Static Route With DHCP interface

Description

A static route is configured using an Ethernet interface with DHCP.

Scenario

Step 1: Set the following configuration in DUT1:

set interfaces ethernet eth0 address 192.168.100.100/24
set service dhcp-server shared-network dhcpserver subnet 192.168.100.0/24 options default-router 192.168.100.100
set service dhcp-server shared-network dhcpserver subnet 192.168.100.0/24 start 192.168.100.50 stop 192.168.100.50

Step 2: Set the following configuration in DUT0:

set interfaces ethernet eth0 address dhcp
set protocols static route 10.0.0.0/24 dhcp-interface eth0

Step 3: Run command interfaces ethernet eth0 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:6c10/64

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.100
Name-servers:
Domain-name:
NTP servers:
DHCP server:   192.168.100.100
Lease time:    43200
Expiry date:   Fri Jun 21 04:41:59 2024
Reason:        BOUND

Step 5: Run command protocols ip show route at DUT0 and check if output matches the following regular expressions:

S>.*10.0.0.0/24.*via 192.168.100.100, eth0.*
Show output
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, F - PBR,
       f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

S>* 0.0.0.0/0 [1/0] via 192.168.100.100, eth0, weight 1, 00:00:00
S>* 10.0.0.0/24 [1/0] via 192.168.100.100, eth0, weight 1, 00:00:00
C>* 192.168.100.0/24 is directly connected, eth0, 00:00:00

Step 6: Ping IP address 192.168.100.100 from DUT0:

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

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