DHCP:
DHCP Servers leases IP addresses to clients and offer a seamless user experience.
DHCP Depends on 4 types of packets and uses UDP port 67/68 (UDP port number 67 is the destination port of a server, and UDP port number 68 is used by the client.)
DHCP Packets:
- DHCP DISCOVERY: Sent by the client to find available DHCP Servers.
- DHCP OFFER: Once the server sees a DHCP Discovery packet it will send a packet offering an IP Address that can be used by the client.
- DHCP REQUEST: Once the client receives an offer (noting that it can get multiple offers from multiple server in the same network), it will send a packet requesting the IP from the DHCP server and accepting the given lease.
- DHCP ACK: The DHCP Server will acknowledge the request. And once it is acknowledged the client will start using the given IP address.
To configure DHCP on Cisco Layer-3 Device, use the below commands:
R1(conf)#ip dhcp pool [Pool Name]
R1(dhcp-conf)#Network [Network ID] [Subnet Mask]
R1(dhcp-conf)#default-router [Gateway IP]
R1(dhcp-conf)#dns-server [First DNS Server IP] [Second DNS Server IP]
To exclude an IP or a range of IPs from getting offered through DHCP:
R1(conf)#ip dhcp excluded-address [IP address]
or:
R1(conf)#ip dhcp excluded-address [Start IP address] [End IP address]
Note: Exclusion commands are done from the Config Mode not the DHCP Config mode