In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
DHCP Service principle and automatic acquisition experiment 1. The concept of DHCP
DHCP (Dynamic Host Configuration Protocol)-dynamic host configuration protocol, which is specially used to automatically scrap TCP/IP parameters for computers in TCP/IP networks, belongs to the application layer.
In the real scenario, the server controls a range of IP addresses, and the client can automatically obtain the IP address and subnet mask assigned by the server when the client logs in to the server.
Using DHCP service can automatically assign addresses to a large number of clients and provide centralized management, thus reducing management and maintenance costs and improving network configuration efficiency.
The address information that can be assigned mainly includes: the ip address and subnet mask of the network card; the corresponding network address and broadcast address; the default gateway address; and the DNS server address.
II. The lease process of DHCP
1. DiscoverWhile-Discovery phase, that is, when the DHCP client is looking for the DHCP server. The DHCP client broadcasts (because the IP address of the DHCP server is unknown to the client) to find the DHCP server by sending DHCP discover discovery information, that is, sending specific broadcast information to the address 255.255.255.255. Every host on the network that has installed the TCP/IP protocol will receive this broadcast message, but only the DHCP server will respond.
2. Offer IP-provide phase, that is, the stage when the DHCP server provides the IP address. The DHCP server that receives DHCP discover discovery information on the network responds by assigning to the DHCP client one of the IP addresses that have not yet been leased and sending a DHCP offer provision information to the DHCP client containing the leased IP address and other settings.
3.Request DHCP-request (select) phase, that is, the stage in which the DHCP client selects the IP address provided by a DHCP server. If multiple DHCP servers provide information to the DHCP offer sent by the DHCP client, the DHCP client accepts only the first received DHCP offer offer, and then it broadcasts a DHCP request request containing a request for an IP address from the DHCP server it has selected. The reason for the broadcast answer is to inform all DHCP servers that he will choose the IP address provided by a DHCP server.
4. ACK DHCP-confirmation phase, that is, the stage in which the IP address provided is confirmed by the ACK server. When the DHCP server receives the DHCP request request information answered by the DHCP client, it sends a DHCP ack confirmation message to the DHCP client containing the IP address and other settings it provides, telling the DHCP client that it can use the IP address it provides. The DHCP client then binds its TCP/IP protocol to the network card, and in addition, all DHCP servers except the server selected by the DHCP client will retrieve the IP address provided.
5.Reloginmuri-log in again. In the future, each time the DHCP client logs back into the network, it does not need to send DHCP discover discovery information, but directly sends the DHCP request request information containing the previously assigned IP address. When the DHCP server receives this message, it tries to keep the DHCP client using the original IP address and answers a DHCP ack confirmation message. If this IP address can no longer be assigned to the original DHCP client (such IP address has been assigned to other DHCP clients for use), the DHCP server answers an DHCP nack denial message to the DHCP client. When the original DHCP client receives this DHCP nack denial message, it must resend the DHCP discover discovery information to request a new IP address.
6. Update the lease. The IP address leased by the DHCP server to the DHCP client usually has a lease term, and when the lease period expires, the DHCP server will take back the leased IP address. If the DHCP client wants to extend its IP lease, it must renew its IP lease. When the DHCP client starts up and when the IP lease is halfway through, the DHCP client automatically sends information to the DHCP server updating its IP lease.
Third, the advantages of DHCP reduce management, avoid input errors, avoid IP address conflicts, improve IP address utilization, and facilitate client configuration. 4. Automatic allocation of DHCP: when the DHCP client successfully obtains an IP address from the DHCP server for the first time, it will be manually assigned permanently using this address: the DHCP server administrator specifically specifies the IP address Dynamic allocation: when the DHCP client successfully obtains an IP address from the DHCP server for the first time, it does not use the address permanently, but after each use, the DHCP client releases the IP address for use by other clients. (PS: when I did the experimental verification myself, I found that when the assigned IP address range is large enough and the number of hosts is small, the same IP address will be obtained regardless of whether it is released or not, and when the range is very small, for example, when there is only one, the rest cannot be obtained by a client unless another renew is released.) 5. DHCP dynamic allocation experiment
Experimental environment: Windows10 host, one win10 virtual machine for authentication and one Centos7 for server configuration.
The purpose of the experiment is to verify that DHCP dynamically allocates IP addresses. The original win10 virtual machine belongs to other network segments or 169network segments. Depending on your configuration connection mode, you can finally get the ip address within your configured network segment.
The main points to be paid attention to in the course of the experiment:
The first is the configuration of the network card. The two virtual machines need the same network card, and the host needs to be restarted to add the network card. Secondly, the firewall and SELinux enhanced security features are turned off. Finally, the corresponding service must be restarted after the configuration file.
The steps of the experiment are as follows:
(1) download the software package
(2) change and bind the network card
(3) View the package configuration file and configure the static IP address
(4) turn off firewall and SELinux, change DHCP configuration file and enable dhcpd service
(5) the ip address of the original win10 is invalid ip.
(6) replace the network card of the win10 tester for renew testing
VI. Summary
This paper mainly introduces the related concepts of DHCP and the principle of allocating ip, as well as the advantages of using DHCP services, and finally combines an experiment to verify how DHCP services dynamically allocate ip.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.