What is DHCP
- Dynamic Host Configuration Protocol.
- Automatically assigns IP addresses to connected hosts
- Usually assigned for a limited time or as long as actively using it.
- Can be “Manually Allocated” by MAC Address, so same MAC will always get the same IP.
- DHCP Servers can be server-based or router based.
- Router based more reliable, less prone to crashing
- Server based generally easier and use a GUI, thus server based tend to be common.
DHCP Process
- PC sends out a “DHCP Discover” broadcast packet.
- DHCP Server will reply with “DHCP Offer” which will contain an IP address. (Unicast)
- The PC will reply with a reply saying it accepts the IP (Unicast).
- The server replies with an acknowlegement and allocates the IP (Unicast).
Using the SDM to configure DHCP
Configure -> Additional Tasks
Setting up Command Line (cli)
r1(config)#ip dhcp pool POOL-NAME r1(dhcp-config)#network 172.30.2.0 255.255.255.0 r1(dhcp-config)#domain-name lab.local r1(dhcp-config)#dns-server 8.8.8.8 r1(dhcp-config)#default-router 172.30.2.1 r1(dhcp-config)#import all r1(dhcp-config)#lease 3 r1(dhcp-config)#exit r1(config)#ip dhcp exclude-addresses 172.30.2.1 172.30.2.19 r1(config)#ip dhcp exclude-addresses 172.30.2.101 172.30.2.254
domain-name: sets the default domain name. If you ping ‘r1’ it will automatically add .lab.local to the end of the host name.
dns-server: define the IP of the dns server
default-router: Same as default gateway.
import all: Grabs the information from the dhcp server and applies it to the server – such as the default gateway and dns servers.
lease: hours minutes seconds
ip dhcp exclude-addresses: by default dhcp will hand out all IPs in the subnet. The ‘exclude’ command reserves
dns-server: define the IP of the dns server
default-router: Same as default gateway.
import all: Grabs the information from the dhcp server and applies it to the server – such as the default gateway and dns servers.
lease: hours minutes seconds
ip dhcp exclude-addresses: by default dhcp will hand out all IPs in the subnet. The ‘exclude’ command reserves
To refresh the DHCP Address on a Windows PC
C:/> ipconfig /refresh
Show the addresses handed out
#show ip dhcp binding