[Zero-based Xiaobai] Take you to a detailed understanding of the DHCP protocol from beginning to end

[Reminder] Need information or need to enter the deduction group communication to the bottom

Basic background of DHCP

1.1. Introduction

Insert picture description here

  1. DHCP protocol

2.1. Introduction to DHCP

DHCP: Dynamic Host Configure Protocol, dynamic host configuration protocol

Developed from BOOTP (bootstrap Protocol) protocol

UDP encapsulation, server=67, client=68

Dynamically allocate TCP/IP information (IP address, subnet mask, default gateway, DNS server, etc.)

The information allocated is leased.
Insert picture description here
2.2. The DHCP system is composed of
Insert picture description here
DHCP Client (client): a device that requests to obtain network parameters such as an IP address through the DHCP protocol.

DHCP Server: server or network device that can provide DHCP function

DHCP Relay: A device responsible for forwarding DHCP messages between a DHCP server and a DHCP client, and assisting the DHCP server in dynamically assigning network parameters to the DHCP client

2.3. DHCP message type
Insert picture description here
2.4. DHCP working process

2.4.1. Discovery phase
Insert picture description here

The DHCP client sends a DHCP Discover message to discover the DHCP server. Since the client does not know the IP address of the DHCP server, the client sends a DHCP Discover message by broadcast (the destination IP is 255.255.255.255), and all DHCP servers or relays on the same network segment can receive the message .

2.4.2. Offer stage

The DHCP servers on the same network segment will receive the DHCP Discover message, and the server that receives the DHCP Discover will send a unicast DHCP Offer to the DHCP client to allocate IP addresses.

2.4.3. Selection phase

Because the DHCP Discover message is sent in broadcast mode, if there are multiple DHCP servers in the same network segment, the server that receives the DHCP Discover message will respond to the DHCP Offer message, and the DHCP client generally chooses the first DHCP Offer message received. And then send the DHCP Request message by broadcast

Sending the DHCP Request message in broadcast mode is to notify all DHCP servers that he will select the IP address provided by a certain DHCP server, and other DHCP servers can re-assign the IP address once assigned to the client to another client.

2.4.4. Confirmation phase

When the DHCP server receives the DHCP Request message sent by the DHCP client, the DHCP server responds with a DHCP Ack message, indicating that the IP address requested in the DHCP Request message is allocated to the client.

2.5. DHCP lease

2.5.1. Introduction to DHCP lease

When the DHCP server uses a dynamic allocation mechanism to allocate IP addresses to clients, the allocated IP addresses are subject to lease period restrictions. The DHCP client can carry the expected lease period when applying for an address from the server. The server can compare the client's expected lease period with the lease period in the address pool when assigning the lease period, and allocate one of the shorter lease periods to the client. After the lease time expires, the server will withdraw the IP address, and the recovered IP address can continue to be allocated to other clients. This mechanism can improve the utilization of the IP address and prevent the IP address from continuing to be occupied after the client goes offline. If the DHCP client wants to continue to use the address, it needs to renew the IP address lease

2.5.2. DHCP lease renewal
Insert picture description here

When the lease period reaches 50% (T1), the DHCP client will automatically unicast a DHCP Request message to the DHCP server to request an updated IP address lease period.

If a DHCP ACK message is received from the DHCP server, the lease renewal is successful (that is, the lease period starts from 0)

If it receives a DHCP NAK message from the DHCP server, it will resend the DHCP Discover message to request a new IP address

2.5.3. DHCP rebinding
Insert picture description here

When the lease period reaches 87.5% (T2), if it still does not receive a response from the DHCP server, the DHCP client will automatically broadcast a DHCP Request message to the DHCP server to request a renewed IP address lease.

If a DHCP ACK message is received from the DHCP server, the lease renewal is successful (that is, the lease period starts from 0)

If it receives a DHCP NAK message from the DHCP server, it will resend the DHCP Discover message to request a new IP address

2.5.4. Lease expires

If the lease time expires and does not receive a response from the server, the client stops using this IP address and resends a DHCP Discover message to request a new IP address

2.5.5. Suggestions for Lease Setting

Set shorter

Increase network burden

More applicable clients

Mobile places (airports, railway stations, hotels, KTV, shopping centers, etc.)

Set longer

Reduce the burden on the network

Wait longer

Fixed place (home, business)

2.6. DHCP extension

2.6.1. Address release

Before the lease time expires, if the user does not want to use the assigned IP address (for example, the client's network location needs to be changed), the DHCP client will be triggered to send a DHCP Release message to the DHCP server to notify the DHCP server to release the lease of the IP address .

The DHCP server will retain the configuration information of this DHCP client, and list the IP address as one of the previously assigned IP addresses for subsequent reallocation to this client or other clients

The client can request the server to update configuration information by sending a DHCP Inform message

2.6.2. DHCP address reuse

When the DHCP client is not connected to the network for the first time, it can reuse the previously used address
Insert picture description here

  1. The client broadcasts a DHCP Request message containing the IP address assigned last time. The Option 50 (requested IP address option) field in the message is filled with the IP address that has been used before.

  2. After the DHCP server receives the DHCP Request message, it searches for the corresponding lease record according to the MAC address carried in the DHCP Request message, and returns a DHCP Ack if there is one to notify the DHCP client to continue using this IP address. Otherwise, keep silent and wait for the DHCP client to resend the DHCP Discover message to request a new IP address

2.6.3. DHCP address pool

Collection of assigned addresses

​The priority of the interface address pool is higher than that of the global address pool

Insert picture description here

2.7. DHCP configuration

2.7.1. Configuration commands
Insert picture description here
Insert picture description here

  1. Control the allocated address range

  2. Prevent conflicts with important equipment

2.7.2. Interface Address Pool
Insert picture description here

2.7.3. Global address pool
Insert picture description here
Of course, I still have a lot of organized data files and video files, [click here] to get more data files in the past teaching videos, mainly to give novice Xiaobai some detours.
I still have a lot of organized data files and video files, and get more data files and teaching videos in the past, mainly because I want to make some detours for the novice Xiaobai. I want a full set of videos, materials, Q&A, or Huawei, H3C, related certification learning materials + Q group: 519345103 There are
a lot of materials, I will not list them all, first write here, if you have any questions, please leave a message or private message to discuss~

Guess you like

Origin blog.csdn.net/ZYJY2020/article/details/113989486