Dynamic Host Configuration Protocol DHCP (Dynamic Host Configration Protocol)

First, the concept

DHCP (Dynamic Host Configuration Protocol): server-client model, the port number: server is 67, client 68

Second, the message

** DHCP Discover **: DHCP client requests an IP address in the DHCP server does not know the location, so the client sends a DHCP Discover request packet to discover the network DHCP server in the local network to broadcast. Discover receive all of the DHCP server will send a reply message, DHCP client thus can know the network DHCP server exists in the location of the
DHCP Offer : Discover the DHCP server receives the message, it will address in the configured pool find a suitable IP address, together with the corresponding lease period and other configuration information (e.g., gateway, DNS server, etc.), a construct offer message is sent to the DHCP client, the server can inform the user to provide this IP address. But this message simply tells the DHCP client can provide the IP address, and the eventual need for a client to detect the IP address is repeated by ARP.
Request the DHCP : the DHCP client may receive a lot of Offer request packet, it is necessary to choose one of these responses. Select the server is usually the first response message Offer as its target server, and sends a broadcast request to the server's Request messages, select the server announcement, hoping to get an IP address assigned. In addition, DHCP clients after successfully obtain an IP address, use 50% of the lease, the DHCP server sends unicast Request request message request to renew the lease at the address, if there is no ACK packet is received, the lease reached when 87.5%, will be broadcast again sent a request request message to request the renewal of the lease.
ACK the DHCP : Request the DHCP server receives the request message, according to a user Request message carries the MAC to find the lease has no corresponding record, an ACK is sent if a response packet to notify the user may use the assigned IP address.
DHCP NAK: If the DHCP server receives a request Request packet did not find a corresponding lease record or for some reason can not be assigned IP addresses correctly, send NAK reply message to the DHCP client, inform users can not assign the appropriate IP address.
Release DHCP : When a DHCP client is no longer need to assign IP addresses to the DHCP server will automatically send RELEASE request message, the user no longer needs to inform the server assigns an IP address, the DHCP server a request to release the corresponding IP address.
DHCP Decline : When the client discovers the server assigned IP address can not be used (such as IP address conflicts) will be sent to the DHCP server Decline the request packet to notify the server assigned IP address is not available, in order to obtain a new IP address.
Inform DHCP : DHCP Client If you need to get from the DHCP server more detailed configuration information, send an Inform request message to the DHCP server; now largely been abandoned.
All packets based on UDP encapsulation

Ethernet IP UDP DHCP

NOTE: unreliable transport is accomplished reliably effect 1, 2 there is an acknowledgment mechanism, the transmission period

Third, the working process

Here Insert Picture Description
Provided that there is DHCPServer address, address pool, gateway address, DNS address
1, when the DHCP client accesses the network for the first time, the computer found no IP address setting on the machine, it will send DHCP discover broadcast information to discovery Looking DHCP server, send specific broadcast information ie Each network will be installed in the host TCP / IP protocol to receive the broadcast information, but only a DHCP server will respond.
Here Insert Picture Description
2, receiving the DHCP discover the network information will discover a DHCP server to respond, which is assigned to the selection of a DHCP client has not been allocated from the pool of IP addresses comprises transmitting an IP address assigned to the DHCP client and other DHCP offer settings to provide information.
Here Insert Picture Description
. 3, after the DHCP client receives DHCP offer to provide information, selection information first received, and then by broadcasting a DHCP request to answer a request for information, the information containing the IP address to request the DHCP server it selected content.
Here Insert Picture Description
4, when the DHCP server receives the client to answer DHCP request after request information, it would send a DHCP client it provides IP address and other settings confirm the information contained in the DHCP ack, told DHCP client can use it provides IP addresses. Then, they put their DHCP client TCP / IP protocol and NIC teaming, in addition, in addition to the selected DHCP client DHCP server, DHCP server will recover the other IP address has been provided.
Here Insert Picture Description
5, each time after the DHCP client log back into the network, you do not need to send DHCP discover discovery information, but rather sent directly DHCP request contains the previous assigned IP address request information. When the DHCP server receives this information, it will try to get DHCP client continues to use the original IP address, and answer a DHCP ack confirmation. If this IP address can not be allocated to the original client to use DHCP, the DHCP server to the DHCP client to answer a DHCP nack deny information. When the original DHCP client receives this DHCP nack denied the information, it must resend DHCP discover discovery information to request a new IP address.

Fourth, the configuration

1, the definition excludes address

R2(config)#ip dhcp excluded-address

2. Create an address pool

R2(config)#ip dhcp pool cisco

3, the definition of lease

R2(dhcp-config)#lease 10

4, client configuration

R1(config)#interface fastEthernet 1/1
R1(config-if)#ip address dhcp 
R1(config-if)#no sh

Guess you like

Origin blog.csdn.net/qq_43344642/article/details/88998776