当前位置:网站首页>DHCP服务
DHCP服务
2022-07-17 00:16:00 【韵晟】
DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议,使用UDP协议工作, 主要有两个用途:给内部网络或网络服务供应商自动分配IP地址,给用户或者内部网络管理员作为对所有计算机作中央管理的手段,在RFC 2131中有详细的描述。DHCP有3个端口,其中UDP67和UDP68为正常的DHCP服务端口,分别作为DHCP Server和DHCP Client的服务端口;546号端口用于DHCPv6 Client,而不用于DHCPv4,是为DHCP failover服务,这是需要特别开启的服务,DHCP failover是用来做"双机热备"的。
分配形式
首先﹐必须至少有一台DHCP工作在网路上面﹐它会监听网路的DHCP请求﹐并与客户端搓商TCP/IP的设定环境。它提供两种IP定位方式﹕
AutomaticAllocation
自动分配﹕一旦DHCP客户端第一次成功的从DHCP伺服器端租用到IP位址之后﹐就永远使用这个位址。
DynamicAllocation
动态分配:当DHCP第一次从HDCP伺服器端租用到IP位址之后﹐并非永久的使用该位址﹐只要租约到期﹐客户端就得释放(release)这个IP位址﹐以给其它工作站使用。当然﹐客户端可以比其它主机更优先的延续(renew)租约﹐或是租用其它的IP位址。
工作原理
第一次登录的时候﹕
1.寻找Server。当DHCP客户端第一次登录网路的时候﹐也就是客户发现本机上没有任何IP资料设定﹐它会向网路发出一个DHCPDISCOVER封包。因为客户端还不知道自己属于哪一个网路﹐所以封包的来源位址会为0.0.0.0﹐而目的位址则为255.255.255.255﹐然后再附上Dhcpdiscover的信息﹐向网路进行广播。
在Windows的预设情形下,Dhcpdiscover的等待时间预设为1秒﹐也就是当客户端将第一个Dhcpdiscover封包送出去之后﹐在1秒之内没有得到回应的话﹐就会进行第二次Dhcpdiscover广播。若一直得不到回应的情况下﹐客户端一共会有四次Dhcpdiscover广播(包括第一次在内)﹐除了第一次会等待1秒之外﹐其余三次的等待时间分别是9﹑13﹑16秒。如果都没有得到DHCP伺服器的回应﹐客户端则会显示错误信息﹐宣告Dhcpdiscover的失败。之后﹐基于使用者的选择﹐系统会继续在5分钟之后再重复一次Dhcpdiscover的过程。
2.提供IP租用位址。当DHCP伺服器监听到客户端发出的Dhcpdiscover广播后﹐它会从那些还没有租出的位址范围内﹐选择最前面的的空置IP,连同其它TCP/IP设定,回应给客户端一个DHCPOFFER封包。
由于客户端在开始的时候还没有IP位址﹐所以在其Dhcpdiscover封包内会带有其MAC位址信息﹐并且有一个XID编号来辨别该封包﹐DHCP伺服器回应的Dhcpoffer封包则会根据这些资料传递给要求租约的客户。根据伺服器端的设定﹐Dhcpoffer封包会包含一个租约期限的信息。
3.接受IP租约。如果客户端收到网路上多台DHCP伺服器的回应﹐只会挑选其中一个Dhcpoffer而已(通常是最先抵达的那个)﹐并且会向网路发送一个Dhcprequest广播封包﹐告诉所有DHCP伺服器它将指定接受哪一台伺服器提供的IP位址。
同时﹐客户端还会向网路发送一个ARP封包﹐查询网路上面有没有其它机器使用该IP位址﹔如果发现该IP已经被占用﹐客户端则会送出一个DHCPDECLINE封包给DHCP伺服器﹐拒绝接受其Dhcpoffer﹐并重新发送Dhcpdiscover信息。
事实上﹐并不是所有DHCP客户端都会无条件接受DHCP伺服器的offer﹐尤其这些主机安装有其它TCP/IP相关的客户软体。客户端也可以用Dhcprequest向伺服器提出DHCP选择﹐而这些选择会以不同的号码填写在DHCPOptionField里面﹕
换一句话说﹐在DHCP伺服器上面的设定﹐未必是客户端全都接受﹐客户端可以保留自己的一些TCP/IP设定。而主动权永远在客户端这边。
4.租约确认。当DHCP伺服器接收到客户端的Dhcprequest之后﹐会向客户端发出一个DHCPACK回应﹐以确认IP租约的正式生效﹐也就结束了一个完整的DHCP工作过程。
边栏推荐
- The difference between cookies and sessions
- HCIP第一天_HCIA复习
- HCIA_NAT实验
- 数组、冒泡的认识
- Known preorder traversal, preorder traversal, find the sequence traversal of the tree
- Metersphere is based on JMeter distributed performance pressure testing platform
- Circular statements and functions of shell scripts
- HCIA_OSPF实验
- Common English business mail phrases
- After unity imports the FBX model, the rotation and position of the object will change automatically at runtime
猜你喜欢
![[solved] after referring to the local MySQL and forgetting the password, [server] --initialize specified but the data directory has files in it Aborti](/img/a8/2daa2c0d834f1986c8421bf5138c7e.png)
[solved] after referring to the local MySQL and forgetting the password, [server] --initialize specified but the data directory has files in it Aborti

SSH远程控制与访问

LAMP平台部署及应用

NAT综合实验

In depth performance test data analysis

Static routing (detailed)

HCIA_RIP实验

Circular statements and functions of shell scripts

Method of JMeter connecting to database

OSPF综合实验
随机推荐
Flask template injection
数组、冒泡的认识
In depth performance test data analysis
[unity Editor Extension] displays the memory size of all files in the resource directory
[hsjframework] unity time management timemanger timer
InnoDB, MySQL structure, and the difference between the three kinds of deletion
D - parity game discretization + weighted union search set
Reprint: SQL injection common bypass
[unity Editor Extension] find all objects of a script attached in the scene and resources
[solved] after referring to the local MySQL and forgetting the password, [server] --initialize specified but the data directory has files in it Aborti
PowerStor500T报错0x01806803
多层数据包结构及TCP三次握手
Keep two decimal places and take values upward
WINRAR命令拷贝指定文件夹为压缩文件,调用计划任务进行备份。
Various development tools
Dynamic programming - 01 knapsack problem
Use of sqlmap
Conditional statement of shell script
Post man JSON script to JMX script of JMeter
For solopi app performance test