Linux DHCP principles and configuration

Source: Internet
Author: User

DHCP Role

DHCP (Dynamic Host Configuration Protocol) is a LAN protocol that uses UDP protocol to work with two main purposes: to automatically assign IP addresses, subnet masks to internal network or network service providers, Gateway and DNS, (Network batch installation) and other TCP/IP information, to the user or internal network administrator as a method of central management of all computers.

DHCP principle

DHCP lease four section

A: Client makes IP requests

When a DHCP client is started, its IP address is automatically configured to 0.0.0.0, because the use of 0.0.0.0 cannot communicate normally, so the client must pass the DHCP server to obtain a legitimate address. Because the client does not know the IP address of the DHCP server, it Use the 0.0.0.0 address as the source address, use the UDP68 port as the source port, use 255.255.255.255 as the destination address, and use the UDP67 port as the destination port to broadcast the request IP address information . The broadcast information contains the MAC address and computer name of the DHCP client so that the DHCP server can determine which client sent the request.

B: Server response

When the DHCP server receives information from the client requesting the IP address, it looks in its own IP address pool for a legitimate IP address to provide to the client. If so, the DHCP server marks the IP address and joins it in the DHCPOFFER message, and the DHCP server broadcasts a DHCPOFFER message that includes the following information: The MAC address of the DHCP client; the legitimate IP address provided by the DHCP server; subnet mask ; default gateway (route); the duration of the lease; the IP address of the DHCP server. Because the DHCP client does not yet have an IP address, the DHCP server uses its own IP address as the source address, using the UDP67 port as the source port. Use 255.255.255.255 as the destination address to broadcast Dhcpoffer information using the UDP68 port as the destination port.

C: Client Select IP

The DHCP client selects the IP address from the first Dhcpoffer message received, and the DHCP server that issued the IP address retains the address so that the address is not available to another DHCP client. The third process of a DHCP lease occurs when a client receives dhcpoffer from the first DHCP server and chooses an IP address. The client broadcasts the DHCPREQUEST message to all DHCP servers, indicating that it accepts the provided content. The DHCPREQUEST message includes the service identifier (IP address) of the server that provides the IP configuration for the client. The DHCP server looks at the server identifier field to determine whether it is selected to provide an IP address for the specified client, and if those dhcpoffer are rejected, the DHCP server cancels the supply and retains its IP address for the next IP lease request.

While the client chooses IP, the client chooses an IP address, but there is no IP address configured, and there may be several DHCP servers in a network, so The client still uses the 0.0.0.0 address as the source address, uses the UDP68 port as the source port, uses the 255.255.255.255 as the destination address, and uses the UDP67 port as the destination port to broadcast the DHCPREQUEST information.

D: Server confirms lease

After the DHCP server receives the DHCPREQUEST message, it broadcasts a successful acknowledgment to the client as a DHCPACK message that contains a valid lease with an IP address and other potentially configured information. Although the server confirms the client's lease request, but the client has not yet received the server's DHCPAck message, the server still uses its own IP address as the source address, using the UDP67 port as the source port. Use 255.255.255.255 as the destination address to broadcast DHCPAck information using the UDP68 port as the destination port. when the client receives the DHCPACK message, it configures the IP address and completes the initialization of TCP/IP.

Server confirmed Lease: Dhcpnack (DHCPNAK)

If the dhcprequest is unsuccessful, such as when the client attempts to lease the previous IP address, but the IP address is no longer available, or because the client is moved to a different subnet, the IP server broadcasts a negative acknowledgment message dhcpnack when it is invalid. When the client receives an unsuccessful acknowledgment, it restarts the DHCP lease process.

DHCP Lease Renewal

The DHCP client sends a DHCPREQUEST message packet directly to the DHCP server for which the IP address is provided when the lease is over 50%. If the client receives the DHCPACK message packet that the server responds to, the client updates its configuration according to the new lease period provided in the package and other TCP/IP parameters that have been updated, and the lease update is complete. If you do not receive a reply from the server, the client continues to use the existing IP address because the current lease period is 50%.

If there is no update at the last 50% of the lease, the DHCP client will contact the DHCP server that provided the IP address again at the last 75% of the lease period. If it is not successful, the DHCP client must discard the IP address and reapply for the lease at 100%. If no DHCP server is available at this time, the DHCP client uses one of the random addresses in 169.254.0.0/16 and tries again every 5 minutes.

  

Linux DHCP principles and configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.