DHCPv4 (Dynamic Host Configuration Protocol version 4)
Steps to obtain a lease (DORA)
- Discover
- Broadcast with client’s MAC address to find the DHCP server
- Offer
- When the server receives the Discover message, it reserves an available IP address for the requesting client.
- Create an entry consisting of the MAC address of requesting client and the lease IP address.
- Send offer message to the client
- Request
- When the client receives the Offer message, it will broadcast Request message which contains the acceptance of the specific DHCP server.
- Acknowledge
- On receiving the DHCPREQUEST message, it will send a ICMP ping message to the address that will assign to the client to ensure it is not used.
- It will create a new ARP entry.
- Reply with a DHCPACK message which is same as the DHCPOFFER message except the message type filed.
- When the client got the DHCPACK message, it will perform an ARP lookup for the assigned address, if no response, the client knows it’s valid and starts using it.
Steps to renew a lease
- DHCP Request (DHCPREQUEST)
- Before the lease expires, the client sends a DHCPQEQUEST message directly to the DCHP server that originally offered IP address.
- DHCP Acknowledgement (DCHPACK)
- If the server receives the DHCPREQUEST message, it will send a DHCPACK message with the lease information.
- If the server does not receive the DHCPREQUEST message in a specific amount of time, the client will send a DHCPREQUEST broadcast message to lookup the other DCHP server.
Configuration of DHCP on Cisco IOS
-
Exclude IP address
(config)# ip dhcp excluded-address [low address] [high address]
-
Define a DCHP Pool Name
(config)# ip dhcp pool [pool name]
-
Configure the pool
(config)# network [network address] [netmask address] (config)# default-router [router address] (config)# dns-server [dns server address] (config)# domain-name [domain name]
Disable Cisco IOS DHCP service
(config)# no service dhcp
DHCP Relay
- configure the default router as the router does not forward the broadcast message
R1(config)# interface g0/0/0
R1(config-if)# ip helper-address [DHCP server's IP address]
R1(config-if)# end
Configure router as a DHCP client
R1(config)# interface g0/0/0
R1(config-if)# ip address dhcp
R1(config-if)# no shutdown