Original address: http://www.xzbu.com/8/view-7133510.htm
1 DHCP Simple review
1.1 What is DHCP
The DHCP (Dynamic Host configuration Protocol) is a dynamic protocol that provides IP addresses, gateways, DNS, and other configuration parameters to the terminal. The DHCP protocol is developed by the BOOTP (Bootstrap Protocol) protocol, which is designed to reduce the problem of large-scale network, such as human configuration and address conflict. Achieve the purpose of centralized IP address management by simplifying IP address configuration. DHCP is based on the UDP protocol, the client port number is the 68,DHCP server port number is 67.
1.2 The allocation order of IP addresses
The order in which DHCP server assigns IP addresses to the client is as follows:
1, the allocation administrator configured with the client MAC address static binding IP address;
2, the allocation of the client has used the IP address;
3, in the address pool in order to find the IP address can be allocated, and then assigned to the client.
Whether an administrator manually assigns an IP address or is automatically assigned via DHCP, it is important that an address assignment conflict cannot occur.
2 IP Address allocation conflict avoidance
2.1 IP Address application and distribution case
The following experiment gives the DHCP protocol how to ensure that there is no address conflict when assigning IP addresses dynamically.
2.1.1 Test Cases
R1, R2, R3 are in a broadcast network, where R1 as DHCP server,r2 configuration static IP address 100.1.1.2,R3 as a client, dynamically obtain IP address through DHCP.
The following is a detailed analysis of how DHCP server and client ensure that the assigned address does not conflict, and the experiment does not consider the scenario of static IP address binding.
2.1.2 Implementation of DHCP server
According to the agreement, when the client applies for an IP address, it broadcasts a DHCPDISCOVER message on its local physical subnet to find an available DHCP Server. DHCP server responds to the client with a DHCPOFFER message and carries an available IP address. Before sending the DHCPOFFER message, DHCP Server is obligated to ensure that the IP address is not occupied by other devices on the network, resulting in an IP address conflict. DHCP server sends an ICMP echo request message to the IP address to verify that the IP is occupied (that is, the process of initiating a ping). If occupied, reassign in the order of IP address assignments mentioned earlier and repeat IP address conflict detection again. DHCP Server (r1:100.1.1.1) sends the ICMP Echo request message to 100.1.1.2 before sending the DHCPOFFER message because the address is already configured on R2, so R2 to DHCP The server replied to the ICMP Echo reply message. After DHCP server continues to send ICMP echo request to 100.1.1.3, two consecutive ICMP echo Request messages do not receive a reply to the end, it is considered that this address is not occupied, The client (R3) is provided with 100.1.1.3 for its choice by Dhcpoffer.
implementation of the 2.1.3 client
A real-world network is often more complex than a test environment, and in the previous procedure, if the R2 configured an ACL to prohibit ICMP echo request access, it would not respond to a ping request from DHCP server.
However, in this process, because the DHCP server does not check out 100.1.1.2 this address has been occupied by the network R2, if the client finally chooses to use the 100.1.1.2 this IP address, it will appear with the R2 address conflict, this obviously cannot satisfy the demand.
In the final confirmation phase, when the client receives the DHCPACK message sent by the DHCP server, it does not immediately use the address assigned by the server, but instead sends an ARP request message with the destination address for the server assigned address for final confirmation (i.e., free ARP).
If no conflict is detected, bind this address to itself. If a conflict is detected, a dhcpdecline message is sent to the DHCP server, which is populated with the conflicting IP address provided by the server in the Request IP address (option 50) field.
After the send is complete, wait for some time before you start requesting the IP address again until you request an available IP address.
3 Summary
From the above analysis, in the DHCP protocol, DHCP server and the client respectively in different ways, in the respective process phase of IP address collision detection, to ensure that the real available IP address allocation.