Step by step
- Exclude the addresses you will set by hand (the router, servers, printers):
ip dhcp excluded-address FIRST LAST. - Create a pool:
ip dhcp pool NAME. The prompt changes to(dhcp-config)#. network192.168.10.0 255.255.255.0: which addresses the pool hands out.default-router192.168.10.1: the gateway clients use (the router's LAN address).dns-server, and optionallydomain-nameandleaseDAYS [HOURS [MINUTES]] (default one day).
In NetLab
▶ R1 R1>enable R1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. R1(config)#ip dhcp excluded-address 192.168.10.1 192.168.10.9 R1(config)#ip dhcp pool LAN10 R1(dhcp-config)#network 192.168.10.0 255.255.255.0 R1(dhcp-config)#default-router 192.168.10.1 R1(dhcp-config)#dns-server 192.168.10.5 R1(dhcp-config)#domain-name corp.local R1(dhcp-config)#lease 2 R1(dhcp-config)#end *Mar 1 00:00:34.000: %SYS-5-CONFIG_I: Configured from console by console ▶ PC2 student@PC2:~$ sudo dhclient eth0 student@PC2:~$ ip addr show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:1a:f2:3a:a4:ee brd ff:ff:ff:ff:ff:ff inet 192.168.10.10/24 brd 192.168.10.255 scope global dynamic eth0 valid_lft 172799sec preferred_lft 172799sec inet6 fe80::21a:f2ff:fe3a:a4ee/64 scope link valid_lft forever preferred_lft forever student@PC2:~$ ip route default via 192.168.10.1 dev eth0 proto dhcp src 192.168.10.10 metric 100 192.168.10.0/24 dev eth0 proto dhcp scope link src 192.168.10.10 metric 100 ▶ R1 R1#show ip dhcp pool Pool LAN10 : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 254 Leased addresses : 1 Excluded addresses : 9 Pending event : none 1 subnet is currently in the pool : Current index IP address range Leased/Excluded/Total 192.168.10.11 192.168.10.1 - 192.168.10.254 1 / 9 / 254 R1#show ip dhcp binding Bindings from all pools not associated with VRF: IP address Client-ID/ Lease expiration Type Hardware address/ User name 192.168.10.10 0100.1af2.3aa4.ee Mar 03 1993 12:00 AM Automatic
PC2 got 192.168.10.10: the first address that isn't excluded. On Linux the dynamic word and the valid_lft countdown show the address came from DHCP.
Common mistake: The excluded-address command is global, not inside the pool. And the pool's
default-routermust be the router's address on that LAN: a typo there gives every client a gateway that doesn't exist.
Tip:
show running-config | section dhcpshows the whole DHCP configuration at once.