Full View of DHCP protocol functions

Source: Internet
Author: User

IP is the most important support in the network. So here we will explain the DHCP protocol, so what is the relationship with the IP address? Next, let's take a look at the content about the DHCP protocol function and work form. As we have seen before, when using TCP/IP protocols, the same NetID and different hostids must be used to directly transmit information between computers. In this way, you have to set IP addresses and manage records for each computer. If you want to manage a large network or a computer node that often changes (such as a network), it can be said that it is very annoying and there are many opportunities for errors. In addition, if you re-plan the IP address, the workload is amazing. Let's unveil the mystery of DHCP.

DHCP

DHCP is the abbreviation of DynamicHostConfigurationProtocol. Its predecessor is BOOTP. BOOTP originally used BOOTROM for network hosts on a network connected to a non-disk host, instead of starting a disk and connecting to the network, BOOTP can automatically set the TCP/IP environment for those hosts.

DHCP can be said to be an enhanced version of BOOTP. It is divided into two parts: one is the server side and the other is the client side. All IP network configuration information is centrally managed by the DHCP server and is responsible for processing the HDCP requirements of the client, while the client uses the IP Environment Information allocated from the server.

DHCP protocol function

First, a DHCP server must work on the network. It listens to DHCP requests from the network. It provides two IP address locating methods.

Automatic Allocation

The situation is that the DHCP client will always use the IP address once it is successfully rented from the DHCP server for the first time.

Dynamic Allocation

Dynamic Allocation when DHCP is not permanently used after being rented from the HDCP server to an IP address for the first time, the client must be released (release) this IP address is used by other workstations. Of course, the client can also continue the (renew) Lease or lease other IP addresses.

Dynamic Allocation is obviously more flexible than automatic allocation, especially when your actual IP address is insufficient. For example, if you are an ISP, you can only provide 200 IP addresses for the customer, but it does not mean that your customer up to 200. It is necessary to know that your customers cannot access the Internet at the same time. Apart from their respective behavioral habits, they may also be limited by telephone lines. In this way, you can lease the 200 addresses in turn to the connected customers. This is also why when you use winipcfg to view your IP address, it will vary with the reason for each call (unless you apply for a fixed IP address, generally the ISP can meet of course, this requirement may be charged separately ). Of course, ISP does not necessarily use DHCP to allocate addresses, but it works the same way as IPPool.

In addition to dynamically setting IP addresses, DHCP can also retain some IP addresses for some machines for special purposes. It can also assign fixed IP addresses based on MAC addresses. This gives you a larger design. space. At the same time, DHCP can also help clients specify Network Gateway routerNetMaskDNS server WINS server and so on. In addition to checking the DHCP protocol function options, you almost do not need to set any IP environment on the client.

How DHCP works

Depending on whether the client is the first to log on to the network for DHCP.

First Login Time

IP Leasing requires that when the DHCP client logs on to the network for the first time, that is, the customer finds that there is no IP address on the local machine to set it to send 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 the network for broadcast.

The Dhcpdiscover wait time is set to 1 second by default, that is, when the client does not receive a response within 1 second after the first Dhcpdiscover packet is sent, the second Dhcpdiscover broadcast is performed. If no response is received, the client will have four Dhcpdiscover broadcasts (including the first time). The remaining three waits for one second, except the first one, will be 91316 seconds respectively. If no DHCP server responds to the client, the error message "Dhcpdiscover" is displayed. Then, based on the requirements that the user's selection system will re-launch the Dhcpdiscover five minutes later.

IP address lease address 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 yet been rented to respond to the client with a Dhcpoffer packet.

Because the client does not have an IP address at the beginning, the Dhcpoffer packet containing its MAC address information in its Dhcpdiscover package will have an XID to identify the Dhcpoffer packet responded by the DHCP server. the information is transmitted to the customer requesting the lease. The Dhcpoffer package based on the server end will contain information about the lease term.

Accept the IP lease. If the client receives responses from Multiple DHCP servers on the network, it only receives the Dhcpoffer and sends a Dhcprequest broadcast packet to the network to notify all DHCP servers that it will specify which server to accept.

At the same time, the client will also send an ARP packet to the network (AddressResolutionProtocol will be met below) check whether other machines on the network use this IP address. If the client has occupied this IP address, a Dhcpdeclient packet will be sent to the DHCP server to reject the Dhcpoffer and resend 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 Dhcp request to provide DHCP protocol options to the server. These options are written in DHCPOptionField with different numbers.

Number meaning

01Sub-netMask

03 RouterAddress

06 DNSServerAddress

0 FDomainName

2 CWINS/NBNSServerAddress

2 EWINS/NBTNodeType

2 FNetBIOSScopeID

In other words, the settings on the DHCP server may not be consistent with those on all clients. The client can retain some of its own TCP/IP Settings.

IP address lease confirmation when the DHCP server receives the client's Dhcprequest, it will send a Dhcpack response to the client to confirm that the IP address lease is effective and end a complete DHCP process.

After the First Login

Once the DHCP Client successfully obtains the DHCP lease from the server, it does not need to send the Dhcpdiscover information again unless the lease has expired and the IP address is reset back to 0.0.0.0. the DHCP server sends a Dhcprequest to the DHCP server. The DHCP server will allow the client to directly respond to Dhcpack to confirm using the original IP address. If the address has expired or is used by another server, the server will respond to a Dhcpnack packet and ask the client to execute Dhcpdiscover again.

The lease term of the IP address is very well-developed. It is not as simple as renting a house. The DHCP protocol function workstation uses NT as an example. In addition to sending a dhcprequest request at the time of power-on, the lease term is also half the time. A dhcprequest will be sent. If no confirmation from the DHCP server is obtained at this time, the workstation can continue to use the IP address and then use the IP address in the second half of the remaining lease term (that is, 75% of the lease term) if the IP address is not confirmed, the workstation cannot own the IP address. Why didn't I give up the IP address until the term of the lease was over? Sorry, the younger brother is also unskillful. I didn't go further. I only know what NT is like when you want to answer MCSE's questions. work is enough.

Of course, you can also use the command to release the DHCP lease at any time, even if your lease was obtained in the first second.

Cross-network DHCP function operation

The above situation is performed in the same network. However, if the DHCP server is set on another network, the DHCP client does not have an IP environment, so it does not know the Router address and some Router do not. we can use DHCPAgent (or DHCPProxy) to transmit DHCP broadcast packets) the host takes over the client's DHCP request and then passes the request to the real DHCP server, and then the server is overwritten to the customer. Here, the Proxy host must have its own routing Capability.

Of course, you can also install the DHCP server on each network, but in this case, the device costs will increase and the management is relatively scattered. Of course, such a balanced architecture is still desirable in a very large network.

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.