当前位置:网站首页>DHCP protocol detailed analysis
DHCP protocol detailed analysis
2022-07-29 02:46:00 【Li-YC】
One 、DHCP Definition
DHCP( Dynamic Host Configuration Protocol ): Is an application layer network protocol . It refers to a period of time controlled by the server IP Address range , When the client logs in to the server, it can automatically get the server assigned IP Address and subnet mask . When we will host the client ip When the address is set to dynamic access mode ,DHCP The server will be based on DHCP The protocol assigns... To the client IP, Enables clients to take advantage of this IP surf the internet .
DHCP Formerly known as BOOTP, stay Linux It can also be seen in the network card configuration of BOOTP,DHCP Introduce a bootp No concept : lease .bootp The assigned address is permanent and dhcp The assigned address can have a time limit
DHCP It is divided into two parts : A server side , The other is the client ( Usually in the network PC、 Printer and other terminal equipment ).
Two 、DHCP Function and characteristics
1、DHCP Can be automatically assigned IP、 Subnet mask 、 gateway 、DNS.
2、DHCP The port used by the client is 68, The server port is 67, The use of UDP Application layer protocol .
3、DHCP Generally, servers are not allocated IP, Because they need to be fixed IP, therefore DHCP Generally, it is only allocated to the host of the office environment IP
4、DHCP The server and client need to be in a LAN , Allocating IP You need to broadcast many times , but DHCP It can also be allocated to hosts in other network segments IP, As long as the router between the two network segments is connected, it can forward DHCP Configure the request , But this requires the router to configure the relay function .
3、 ... and 、DHCP The server IP There are three ways to allocate
1、 Automatic allocation method ,DHCP The server specifies a permanent IP Address , once DHCP The first successful client from DHCP Server side lease to IP After the address , You can use the address permanently ,
2、 Dynamic distribution mode ,DHCP The server specifies a time limited IP Address , When the time expires or the host explicitly gives up the address , This address can be used by other hosts .
3、 Manual allocation method , Client's IP The address is specified by the network administrator ,DHCP The server will only specify IP Address to client host
The third is the most common form of use , The effective use period of the address is called the lease term , Before the expiration of the lease , The client must request the server to continue renting . The server can continue to use after accepting the request , Otherwise, give up unconditionally .
Four 、DHCP relay
By default , Router isolates official blog packets , The received broadcast packets will not be sent from one subnet to another . When DHCP When the server and client are not in the same subnet , The router acting as the default gateway of the client sends broadcast packets to DHCP The subnet where you are , This function is called DHCP relay .
DHCP Relay agent , Is in the DHCP Forwarding between server and client DHCP Data packets . When DHCP The client and server are not on the same subnet , There must be DHCP Relay agent DHCP Request and reply messages ,DHCP Data forwarding of relay agent data , Different from the usual router forwarding , Generally, routing and forwarding are relatively transparent , The equipment will not be modified IP Package content , and DHCP The relay agent received DHCP After the news , Regenerate a DHCP news , Then forward it
DHCP The relay host must have its own routing capability , And the datagrams of both parties are transmitted to each other . If relay is not used , You can also install DHCP The server , But in that case , As a result, the cost of equipment will increase , And the management is also relatively decentralized , Of course , If in a large network , Such a balanced architecture is desirable .

5、 ... and 、DHCP Service workflow
First step : Search phase
When DHCP The first time a client logs on to the network , The computer found nothing on this computer IP Address setting , Will be sent by radio DHCP discover Find information to look for DHCP The server , That is to 255.255.255.255 Send a specific broadcast signal , Every one on the network has TCP/IP All hosts of the protocol will receive the broadcast information , But only DHCP The server will respond .(dhcp discover)
The second step : Provision phase
Received... In the network DHCP discover Found information DHCP The server will respond , It has never been assigned IP Choose one of the address pools to assign to DHCP The client , towards DHCP The client sends an... Containing the assignment IP Address and other settings DHCP offer Provide information , Because at this time, the client has not IP, So the return is also broadcast .(dhcp offer)
The third step : Selection stage
DHCP Client received DHCP offer After providing information , Select the first received offer , Then answer a... By radio DHCP request Request information , This information contains the DHCP Server request IP The content of the address .(DHCP REQUEST)
Step four : Confirmation stage
When DHCP Server received DHCP The client answers DHCP request After requesting information , Defecate DHCP The client sends a message containing the IP Address and other settings DHCP ack Confirmation information , Confirm lease , And specify the lease duration . tell DHCP The client can use the IP Address . then ,DHCP The client will put it TCP/IP Protocol and network card binding , in addition , except DHCP Client selected DHCP Outside the server , Other DHCP The server will take back what it provided IP Address .(DHCP ACK)

in the future DHCP Every time the client logs back on the network , You don't need to send DHCP discover Found information , Instead, send directly containing the last assigned IP Address of the DHCP request Request information . When DHCP When the server receives this message , It will try to make DHCP The client continues to use the original IP Address , And answer a DHCP ack Confirmation information . If so IP The address can no longer be assigned to the original DHCP When the client is in use , be DHCP Server to DHCP The client answers a DHCP nack Deny information . When the original DHCP The client receives this DHCP nack After denying information , It has to be resend DHCP discover Discover information to request new IP Address .
DHCP Renewal
1、 In the past of the lease period 50% At the moment , The client sends unicast to the server DHCP REQUEST Message renewal period .
2、 If you receive from the server DHCP ACK message , Then the lease term will be extended accordingly , Lease renewal succeeded . If not received DHCP ACK message , Then the client continues to use this IP Address . In the past of the lease period **87.5%** At the moment , Send a broadcast to the server DHCP REQUEST Message renewal period .
3、 If you receive from the server DHCP ACK message , Then the lease term will be extended accordingly , Lease renewal succeeded . If not received DHCP ACK message , Then the client continues to use this IP Address . Use at the expiration of the lease term , The client automatically gives up using this IP Address , And start a new DHCP The process .
边栏推荐
- Three expiration strategies
- 0728~ sorting out interview questions
- NVIDIA-VPI(Vision Programming Interface)
- Read the recent trends of okaleido tiger and tap the value and potential behind it
- C语言实现三子棋游戏
- FFmpeg+SDL+QT实现简单是视频播放器
- Multimodal unsupervised image to image translation
- 10.书写规则-文件搜寻
- Cuda-npp image and video processing
- 童年的快乐时光
猜你喜欢

XSS range (II) xss.haozi

Redis master-slave mode, sentinel cluster, fragment cluster

golang 协程的实现原理

QT compilation of IOT management platform 48 characteristic function design

QT screen adaptive automatic layout, drag the window to automatically grow larger and smaller (I)

新版海螺影视主题模板M3.1全解密版本多功能苹果CMSv10后台自适应主题开源全解密版

HTTP缓存

图书管理系统

全新UI四方聚合支付系统源码/新增USDT提现/最新更新安全升级修复XSS漏洞补单漏洞

PHP lucky draw system with background source code
随机推荐
UE4.25 Slate源码解读
ECCV 2022 | airdet: a small sample target detection method without fine tuning
架构师进阶,微服务设计与治理的 16 条常用原则
《微信小程序-进阶篇》Lin-ui组件库源码分析-Button组件(二)
远离才会思念
JMeter's BeanShell generates MD5 encrypted data and writes it to the database
Source code of Jiugongge heart puzzle Applet / source code of main wechat applet with traffic
C语言:小乐乐与进制转换
图书管理系统
Time for white horses to pass the gap
QT compilation of IOT management platform 48 characteristic function design
Master-slave replication and its principle
What are the TCP retransmission mechanisms?
QT屏幕自适应自动布局,拖动窗口自动变大变小(一)
2022/07/28 learning notes (day18) common APIs
新版海螺影视主题模板M3.1全解密版本多功能苹果CMSv10后台自适应主题开源全解密版
FFmpeg+SDL+QT实现简单是视频播放器
[error reporting] node:internal/modules/cjs/loader:936 [solution]
ECCV 2022 | AirDet:无需微调的小样本目标检测方法
Workflow of wireless vibrating wire acquisition system