Dhcp Address
This scenario shows how to obtain an IP address over DHCP (Dynamic Host Configuration Protocol).
Test DHCP client
Description
DUT0 is configured to obtain an IP address over DHCP.
Scenario
Step 1: Set the following configuration in DUT1
:
set interfaces ethernet eth0 address 192.168.100.1/24 set interfaces dummy dum0 address 10.0.0.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
Step 2: Set the following configuration in DUT0
:
set interfaces ethernet eth0 address dhcp
Step 3: Run command interfaces ethernet show
at DUT0
and check if output contains the following tokens:
192.168.100.50/24Show output
----------------------------------------------------------------- Name IP Address Admin Oper Vrf Description ----------------------------------------------------------------- eth0 192.168.100.50/24 up up fe80::dcad:beff:feef:6c10/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: Thu Jan 25 13:19:53 2024 Reason: BOUND
Step 5: Run command protocols ip show route
at DUT0
and check if output matches the following regular expressions:
S>.*0\.0\.0\.0\/0.*via 192.168.100.1, 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.1, eth0, weight 1, 00:00:01 C>* 192.168.100.0/24 is directly connected, eth0, 00:00:01
Step 6: Ping IP address 192.168.100.1
from DUT0
:
admin@DUT0$ ping 192.168.100.1 count 1 size 56 timeout 1Show 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.621 ms --- 192.168.100.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.621/0.621/0.621/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 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.372 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.372/0.372/0.372/0.000 ms