How does DHCP work
Lab Topology
R1 simulates a DHCP server ,R2 simulates a client which get IP address from the R1 DHCP server
R1 configure:
1 | DHCP(config)#ip dhcp pool CCIE # define a name of address Pool |
R2 configure :
1 | R2(config)#int e1/2 |
R2 succeeds in getting an IP address ,it shows 10.1.1.2:
1 | *Mar 1 00:08:32.059: %DHCP-6-ADDRESS_ASSIGN: Interface Ethernet1/2 assigned DHCP address 10.1.1.2, mask 255.255.255.0, hostname R2 |
Now. Let’s analyse the process of HDCP :
1.Client send a DHCP Discover massage :
the destination MAC address is broadcast address ,and the destination IP address is the broadcast address too.
R1 sends a Bootstrap Protocol (discover) with the message type :Boot Request 1
2.DHCP server send an ARP request message before assing the ip address .to make sure this address is available.
3.DHCP Server send an offer message to reply the client . This offer package contains all information about the ip address
Tips: The experiment shows that the DHCP send the offer package to broadcast . But it should bu an unicast pacakage
4.Clinet send a Request massage to Server to choose an ip address (there could be more than one servers in the network )
5.DHCP server send an ACK message to make sure this IP address was accepted by Client. this is a Reply pacakge
6.At the end . Client will send a gratuitous ARP (无故ARP) to broadcast address . to inform all others about its own IP address and ARP address :
Summarize :
DHCP mainly contains below five steps :
1.Client send a Discover message to broadcast address #apply for an ip address
2.DHCP server send an ARP package to broadcast address #to see if the ip address which is gonna assign to client exists in network
3.DHCP send an offer package #assign this ip address to Client
4.Client send a Request package #to announce that it chooses the ip address (there could be more than one server in network)
5.DHCP Server sends a ACK pacckage #acknowledge this IP address was assigned to client
6.Client send an ARP to tell others about its ip and MAC addree #this is not about the DHCP process .
Tips: DHCP is transmitted by UDP protocol with 67 port
Caution: The Offer and ACK packages sometimes are sent within broadcast (in our experiment),But sometimes are unicast packages