DHCP clients: PCs and router interfaces

PCs

OSUse DHCPReleaseRenew
Windowsnetsh interface ip set address "Ethernet" dhcpipconfig /releaseipconfig /renew
Linuxsudo dhclient eth0sudo dhclient -r eth0sudo dhclient eth0
macOSsudo ipconfig set en0 DHCP(System Settings)sudo ipconfig set en0 DHCP

A PC that can't reach a DHCP server behaves differently on each OS. Windows and macOS give themselves an APIPA address from 169.254.0.0/16 so they can at least talk on the local link; Linux stays without an IPv4 address.

In NetLab

▶ PC1
NetLab Windows-style command prompt. Type help to see the commands.
C:\Users\student>ipconfig /renew

Windows IP Configuration

An error occurred while renewing interface Ethernet : unable to contact your DHCP server. Request has
timed out.
C:\Users\student>ipconfig

Windows IP Configuration


Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . : 
   Link-local IPv6 Address . . . . . : fe80::11db:99de:fbce:36d1%12
   Autoconfiguration IPv4 Address. . : 169.254.141.80
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . : 
▶ PC2
student@PC2:~$ sudo dhclient eth0
No DHCPOFFERS received.
No working leases in persistent database - sleeping.

Remember: 169.254.x.x on a PC means "I asked for DHCP and nobody answered". Check the cable, the switch port's VLAN, the helper address, and the server.

A router as a DHCP client

Internet providers often hand the customer's router its WAN address by DHCP. The interface command is ip address dhcp. The router also installs a default route towards the gateway the server gave it (shown as S* with administrative distance 254).

In NetLab

▶ R1
R1>enable
R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#interface g0/2
R1(config-if)#ip address dhcp
*Mar  1 00:00:28.000: %DHCP-6-ADDRESS_ASSIGN: Interface GigabitEthernet0/2 assigned DHCP address 203.0.113.10, mask 255.255.255.0, hostname R1
R1(config-if)#end
*Mar  1 00:00:29.000: %SYS-5-CONFIG_I: Configured from console by console
R1#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol
GigabitEthernet0/0     192.168.10.1    YES manual up                    up
GigabitEthernet0/1     10.0.0.1        YES manual up                    up
GigabitEthernet0/2     203.0.113.10    YES DHCP   up                    up
R1#show ip route | begin Gateway
Gateway of last resort is 203.0.113.1 to network 0.0.0.0

S*    0.0.0.0/0 [254/0] via 203.0.113.1
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/30 is directly connected, GigabitEthernet0/1
L        10.0.0.1/32 is directly connected, GigabitEthernet0/1
      192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.10.0/24 is directly connected, GigabitEthernet0/0
L        192.168.10.1/32 is directly connected, GigabitEthernet0/0
      203.0.113.0/24 is variably subnetted, 2 subnets, 2 masks
C        203.0.113.0/24 is directly connected, GigabitEthernet0/2
L        203.0.113.10/32 is directly connected, GigabitEthernet0/2

Tip: The Method column of show ip interface brief says DHCP for an address learned this way and manual for one you typed.

HOME LABS COMMUNITY DASHBOARD