How DHCP works

Source: Internet
Author: User

For the DHCP protocol, we have a general understanding of some of its work. However, some friends may not know how it works. Next, we will explain how DHCP works in three aspects. Hope to help you.

How DHCP works

DHCP works differently depending on whether the client logs on to the network for the first time. When logging on for the first time:

How DHCP Works 1. Find the Server

When the DHCP client logs on to the network for the first time, that is, the client finds that there is no IP data set on the local machine, and it sends a DHCPDISCOVER packet to the network. Because the client does not know which network it belongs to, the source address of the packet will be 0.0.0.0, And the destination address will be 255.255.255.255, and then the DHCPdiscover information will be attached to broadcast to the network.

In Windows, the waiting time of DHCPdiscover is set to 1 second, that is, if the client does not receive a response within 1 second after sending the first DHCPdiscover packet, the second DHCPdiscover broadcast is performed. If no response is received, the client will broadcast DHCPdiscover four times (including the first time), except for waiting for one second for the first time, the remaining three waiting times are 9, 13, and 16 seconds. If no response is received from the DHCP server, the client displays an error message indicating DHCPdiscover failure. Then, based on the user's choice, the system will repeat the DHCPdiscover process five minutes later.

How DHCP Works 2: IP address lease

When the DHCP server listens to the DHCPdiscover broadcast sent by the client, it selects the first vacant IP address from the address range that has not been rented out, along with other TCP/IP Settings, returns a DHCPOFFER packet to the client.

Because the client does not have an IP address at the beginning, its DHCPdiscover packet contains its MAC address information and an XID number to identify the packet, the DHCPoffer packet responded by the DHCP server will be transmitted to the customer requesting the lease based on the information. According to the server settings, the DHCPoffer package contains information about the lease term.

How DHCP Works 3. Accept IP lease

If the client receives responses from Multiple DHCP servers on the network, it selects only one DHCPoffer (usually the one that arrived first) and sends a DHCPrequest broadcast packet to the network, tells all DHCP servers that will specify the IP address provided by the server to be accepted.

At the same time, the client sends an ARP packet to the network to check whether other machines on the network use the IP address. If the IP address is occupied, the client sends a DHCPDECLIENT packet to the DHCP server, rejects the DHCPoffer, and resends the DHCPdiscover information.

In fact, not all DHCP clients accept the DHCP server's offer unconditionally. In particular, these hosts are installed with client software related to TCP/IP. The client can also use DHCPrequest to propose DHCP options to the server, which will be written in DHCPOption Field with different numbers: in other words, the settings on the DHCP server, the client may not accept all of them. The client can retain some of its own TCP/IP Settings. The initiative is always on the client side.

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.