Dynamic Host Configuration Protocol
To create a DHCP pool in a router:
# create pool
R1(config)# ip dhcp pool POOL1
.
# give it network range
R1(config-dhcp)# network 192.168.1.0 /24
.
# default gateway for clients
R1(config-dhcp)# default-router 192.168.1.1
.
# state DNS server
R1(config-dhcp)# dns-server 1.1.1.1
.
# state Netbios DNS server
R1(config-dhcp)# netbios-name-server 192.168.2.5
.
# state domain
R1(config-dhcp)# domain-name company.com
.
# lease IPs for 23 hours, 59 minutes and 59 seconds
R1(config-dhcp)# lease 23 59 59
.
# lease IPs forever
R1(config-dhcp)# lease infinite
R1(config-dhcp)# exit
.
# exclude IPs from dhcp pool
R1(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.9
.
# enable DHCP and relay service
R1(config)# service dhcp
To get dhcp provided IP adddress on an interface:
R1(config)# int gigabitethernet 0/0
R1(config-if)# ip address dhcp
To troubleshoot:
# binding info for all served IPs
R1# show ip dhcp binding
.
# binding info related to this IP
R1# show ip dhcp binding 192.168.1.15
.
# all dhcp conflicts
R1# show ip dhcp conflict
.
# dhcp conflicts related to this IP
R1# show ip dhcp conflict 192.168.1.15
.
# dhcp configuration
R1# show ip dhcp database
.
# settings for all dhcp pools
R1# show ip dhcp pool
.
# settings for dhcp POOL1
R1# show ip dhcp pool POOL1
.
# dhcp statistics
R1# show ip dhcp server statistics
To debug:
R1# clear ip dhcp server statistics
R1# clear ip dhcp conflict
R1# clear ip dhcp conflict *
R1# clear ip dhcp binding
R1# clear ip dhcp binding *
R1# debug ip dhcp server events
R1# debug ip dhcp server packet
R1# debug ip dhcp server linkage
R1# debug ip dhcp server class
To enable the DHCP relay service:
# choose interface facing dhcp clients
R1(config)# int gigabitethernet 0/0
.
# enable dhcp relay to given IP
R1(config-if)# ip helper-address 172.16.24.5
By default the command above forwards broadcast packets as unicast to 8 UDP ports:
- Network service UDP port
- TFTP 69
- DNS 53
- Time service 37
- NetBIOS DNS 137
- NetBIOS datagram server 138
- BOOTP client & server datagrams 67/68
- TACACS 49
We can prevent that by stopping some of those broadcasts as follows: