分享
 
 
 

DHCP(动态主机配置协议)基本信息

王朝other·作者佚名  2006-04-12
窄屏简体版  字體: |||超大  

概要

动态主机配置协议 (DHCP) 是 RFC 1541(已被 RFC 2131 取代)定义的标准协议,该协议允许服务器向客户端动态分配 IP 地址和配置信息。通常,DHCP 服务器至少向客户端提供以下基本信息:

IP 地址

子网掩码

默认网关

它还可以提供其他信息,如域名服务 (DNS) 服务器的地址和 Windows Internet 名称服务 (WINS) 服务器的地址。系统管理员配置 DHCP 服务器分配给客户端的选项。

当客户端被配置为接收 DHCP 信息后首次初始化时,它将启动与服务器的对话。

以下是客户端和服务器之间对话的摘要表,最后一列是数据包级的过程说明:

Source Dest Source Dest Packet

MAC addr MAC addr IP addr IP addr Description

-----------------------------------------------------------------

Client Broadcast 0.0.0.0 255.255.255.255 DHCP Discover

DHCPsrvr Broadcast DHCPsrvr 255.255.255.255 DHCP Offer

Client Broadcast 0.0.0.0 255.255.255.255 DHCP Request

DHCPsrvr Broadcast DHCPsrvr 255.255.255.255 DHCP ACK

DHCP 客户端和 DHCP 服务器之间的详细对话如下:

DHCPDISCOVER

客户端发送 DHCPDISCOVER 数据包。以下内容摘自网络监视器的捕获信息,显示了 DHCPDISCOVER 数据包中的 IP 和 DHCP 部分。在 IP 部分,可以看到 Destination 地址是 255.255.255.255,而 Source 地址是 0.0.0.0。DHCP 部分将数据包标识为 Discover 数据包,并使用网卡的物理地址在两处标识客户端。注意 CHADDR 字段和 DHCP 中的值:Client Identifier 字段是相同的。

IP:ID = 0x0; Proto = UDP; Len: 328

IP:Version = 4 (0x4)

IP:Header Length = 20 (0x14)

IP:Service Type = 0 (0x0)

IP:Precedence = Routine

IP:...0.... = Normal Delay

IP:....0... = Normal Throughput

IP:.....0.. = Normal Reliability

IP:Total Length = 328 (0x148)

IP:Identification = 0 (0x0)

IP:Flags Summary = 0 (0x0)

IP:.......0 = Last fragment in datagram

IP:......0. = May fragment datagram if necessary

IP:Fragment Offset = 0 (0x0) bytes

IP:Time to Live = 128 (0x80)

IP:Protocol = UDP - User Datagram

IP:Checksum = 0x39A6

IP:Source Address = 0.0.0.0

IP:Destination Address = 255.255.255.255

IP:Data:Number of data bytes remaining = 308 (0x0134)

DHCP:Discover (xid=21274A1D)

DHCP:Op Code (op) = 1 (0x1)

DHCP:Hardware Type (htype) = 1 (0x1) 10Mb Ethernet

DHCP:Hardware Address Length (hlen) = 6 (0x6)

DHCP:Hops (hops) = 0 (0x0)

DHCP:Transaction ID (xid) = 556223005 (0x21274A1D)

DHCP:Seconds (secs) = 0 (0x0)

DHCP:Flags (flags) = 0 (0x0)

DHCP:0............... = No Broadcast

DHCP:Client IP Address (ciaddr) = 0.0.0.0

DHCP:Your IP Address (yiaddr) = 0.0.0.0

DHCP:Server IP Address (siaddr) = 0.0.0.0

DHCP:Relay IP Address (giaddr) = 0.0.0.0

DHCP:Client Ethernet Address (chaddr) = 08002B2ED85E

DHCP:Server Host Name (sname) = <Blank>

DHCP:Boot File Name (file) = <Blank>

DHCP:Magic Cookie = [OK]

DHCP:Option Field (options)

DHCP:DHCP Message Type = DHCP Discover

DHCP:Client-identifier = (Type:1) 08 00 2b 2e d8 5e

DHCP:Host Name = JUMBO-WS

DHCP:Parameter Request List = (Length:7) 01 0f 03 2c 2e 2f 06

DHCP:End of this option field

DHCPOFFER

DHCP 服务器通过发送 DHCPOFFER 数据包作出响应。在以下摘录捕获信息的 IP 部分中,Source 地址现在是 DHCP 服务器 IP 地址,而 Destination 地址是广播地址 255.255.255.255。DHCP 部分将数据包标识为 Offer。YIADDR 字段用服务器提供给客户端的 IP 地址填充。注意,CHADDR 字段仍然包含发出请求的客户端的物理地址。另外,在 DHCP Option Field 部分,可以看到由服务器随 IP 地址一起发送的各种选项。在这种情况下,服务器发送的是子网掩码、默认网关(路由器)、租约时间、WINS 服务器地址(NetBIOS 名称服务)和 NetBIOS 节点类型。

IP:ID = 0x3C30; Proto = UDP; Len: 328

IP:Version = 4 (0x4)

IP:Header Length = 20 (0x14)

IP:Service Type = 0 (0x0)

IP:Precedence = Routine

IP:...0.... = Normal Delay

IP:....0... = Normal Throughput

IP:.....0.. = Normal Reliability

IP:Total Length = 328 (0x148)

IP:Identification = 15408 (0x3C30)

IP:Flags Summary = 0 (0x0)

IP:.......0 = Last fragment in datagram

IP:......0. = May fragment datagram if necessary

IP:Fragment Offset = 0 (0x0) bytes

IP:Time to Live = 128 (0x80)

IP:Protocol = UDP - User Datagram

IP:Checksum = 0x2FA8

IP:Source Address = 157.54.48.151

IP:Destination Address = 255.255.255.255

IP:Data:Number of data bytes remaining = 308 (0x0134)

DHCP:Offer (xid=21274A1D)

DHCP:Op Code (op) = 2 (0x2)

DHCP:Hardware Type (htype) = 1 (0x1) 10Mb Ethernet

DHCP:Hardware Address Length (hlen) = 6 (0x6)

DHCP:Hops (hops) = 0 (0x0)

DHCP:Transaction ID (xid) = 556223005 (0x21274A1D)

DHCP:Seconds (secs) = 0 (0x0)

DHCP:Flags (flags) = 0 (0x0)

DHCP:0............... = No Broadcast

DHCP:Client IP Address (ciaddr) = 0.0.0.0

DHCP:Your IP Address (yiaddr) = 157.54.50.5

DHCP:Server IP Address (siaddr) = 0.0.0.0

DHCP:Relay IP Address (giaddr) = 0.0.0.0

DHCP:Client Ethernet Address (chaddr) = 08002B2ED85E

DHCP:Server Host Name (sname) = <Blank>

DHCP:Boot File Name (file) = <Blank>

DHCP:Magic Cookie = [OK]

DHCP:Option Field (options)

DHCP:DHCP Message Type = DHCP Offer

DHCP:Subnet Mask = 255.255.240.0

DHCP:Renewal Time Value (T1) = 8 Days, 0:00:00

DHCP:Rebinding Time Value (T2) = 14 Days, 0:00:00

DHCP:IP Address Lease Time = 16 Days, 0:00:00

DHCP:Server Identifier = 157.54.48.151

DHCP:Router = 157.54.48.1

DHCP:NetBIOS Name Service = 157.54.16.154

DHCP:NetBIOS Node Type = (Length: 1) 04

DHCP:End of this option field

DHCPREQUEST

客户端通过发送 DHCPREQUEST 响应 DHCPOFFER。在以下捕获信息的 IP 部分中,客户端的 Source 地址仍然是 0.0.0.0,数据包的 Destination 仍然是 255.255.255.255。由于客户端还没有从服务器收到可以开始使用所提供地址的确认,所以客户端仍然保留 0.0.0.0。由于可能有多个 DHCP 服务器已经作出响应,并可能预订了为客户端产生的 Offer,所以 Destination 地址仍然被广播出去。这使得其他 DHCP 服务器知道:它们可以释放已提供的地址,并将这些地址返回到可用地址池中。DHCP 部分将数据包标识为 Request,并使用 DHCP:Requested Address 字段确认所提供的地址。DHCP:Server Identifier 字段显示提供租约的 DHCP 服务器的 IP 地址。

IP:ID = 0x100; Proto = UDP; Len: 328

IP:Version = 4 (0x4)

IP:Header Length = 20 (0x14)

IP:Service Type = 0 (0x0)

IP:Precedence = Routine

IP:...0.... = Normal Delay

IP:....0... = Normal Throughput

IP:.....0.. = Normal Reliability

IP:Total Length = 328 (0x148)

IP:Identification = 256 (0x100)

IP:Flags Summary = 0 (0x0)

IP:.......0 = Last fragment in datagram

IP:......0. = May fragment datagram if necessary

IP:Fragment Offset = 0 (0x0) bytes

IP:Time to Live = 128 (0x80)

IP:Protocol = UDP - User Datagram

IP:Checksum = 0x38A6

IP:Source Address = 0.0.0.0

IP:Destination Address = 255.255.255.255

IP:Data:Number of data bytes remaining = 308 (0x0134)

DHCP:Request (xid=21274A1D)

DHCP:Op Code (op) = 1 (0x1)

DHCP:Hardware Type (htype) = 1 (0x1) 10Mb Ethernet

DHCP:Hardware Address Length (hlen) = 6 (0x6)

DHCP:Hops (hops) = 0 (0x0)

DHCP:Transaction ID (xid) = 556223005 (0x21274A1D)

DHCP:Seconds (secs) = 0 (0x0)

DHCP:Flags (flags) = 0 (0x0)

DHCP:0............... = No Broadcast

DHCP:Client IP Address (ciaddr) = 0.0.0.0

DHCP:Your IP Address (yiaddr) = 0.0.0.0

DHCP:Server IP Address (siaddr) = 0.0.0.0

DHCP:Relay IP Address (giaddr) = 0.0.0.0

DHCP:Client Ethernet Address (chaddr) = 08002B2ED85E

DHCP:Server Host Name (sname) = <Blank>

DHCP:Boot File Name (file) = <Blank>

DHCP:Magic Cookie = [OK]

DHCP:Option Field (options)

DHCP:DHCP Message Type = DHCP Request

DHCP:Client-identifier = (Type:1) 08 00 2b 2e d8 5e

DHCP:Requested Address = 157.54.50.5

DHCP:Server Identifier = 157.54.48.151

DHCP:Host Name = JUMBO-WS

DHCP:Parameter Request List = (Length:7) 01 0f 03 2c 2e 2f 06

DHCP:End of this option field

DHCPACK

DHCP 服务器用 DHCPACK 响应 DHCPREQUEST,以此完成初始化周期。Source 地址是 DHCP 服务器 IP 地址,Destination 地址仍然是 255.255.255.255。YIADDR 字段包含客户端的地址,而 CHADDR 和 DHCP:Client Identifier 字段是发出请求的客户端中网卡的物理地址。DHCP Option 部分将数据包标识为 ACK。

IP:ID = 0x3D30; Proto = UDP; Len: 328

IP:Version = 4 (0x4)

IP:Header Length = 20 (0x14)

IP:Service Type = 0 (0x0)

IP:Precedence = Routine

IP:...0.... = Normal Delay

IP:....0... = Normal Throughput

IP:.....0.. = Normal Reliability

IP:Total Length = 328 (0x148)

IP:Identification = 15664 (0x3D30)

IP:Flags Summary = 0 (0x0)

IP:.......0 = Last fragment in datagram

IP:......0. = May fragment datagram if necessary

IP:Fragment Offset = 0 (0x0) bytes

IP:Time to Live = 128 (0x80)

IP:Protocol = UDP - User Datagram

IP:Checksum = 0x2EA8

IP:Source Address = 157.54.48.151

IP:Destination Address = 255.255.255.255

IP:Data:Number of data bytes remaining = 308 (0x0134)

DHCP:ACK (xid=21274A1D)

DHCP:Op Code (op) = 2 (0x2)

DHCP:Hardware Type (htype) = 1 (0x1) 10Mb Ethernet

DHCP:Hardware Address Length (hlen) = 6 (0x6)

DHCP:Hops (hops) = 0 (0x0)

DHCP:Transaction ID (xid) = 556223005 (0x21274A1D)

DHCP:Seconds (secs) = 0 (0x0)

DHCP:Flags (flags) = 0 (0x0)

DHCP:0............... = No Broadcast

DHCP:Client IP Address (ciaddr) = 0.0.0.0

DHCP:Your IP Address (yiaddr) = 157.54.50.5

DHCP:Server IP Address (siaddr) = 0.0.0.0

DHCP:Relay IP Address (giaddr) = 0.0.0.0

DHCP:Client Ethernet Address (chaddr) = 08002B2ED85E

DHCP:Server Host Name (sname) = <Blank>

DHCP:Boot File Name (file) = <Blank>

DHCP:Magic Cookie = [OK]

DHCP:Option Field (options)

DHCP:DHCP Message Type = DHCP ACK

DHCP:Renewal Time Value (T1) = 8 Days, 0:00:00

DHCP:Rebinding Time Value (T2) = 14 Days, 0:00:00

DHCP:IP Address Lease Time = 16 Days, 0:00:00

DHCP:Server Identifier = 157.54.48.151

DHCP:Subnet Mask = 255.255.240.0

DHCP:Router = 157.54.48.1

DHCP:NetBIOS Name Service = 157.54.16.154

DHCP:NetBIOS Node Type = (Length: 1) 04

DHCP:End of this option field

如果客户端以前有 DHCP 分配的 IP 地址并且客户端被重新启动,则客户端将在特殊的 DHCPREQUEST 数据包中特定地请求以前租用过的 IP 地址。Source 地址是 0.0.0.0,Destination 地址是广播地址 255.255.255.255。Microsoft 客户端将用以前分配的地址填充 DHCP Option Field DHCP:Requested Address 字段。严格符合 RFC 的客户端将用请求的地址填充 CIADDR Field。对这两种情况 Microsoft DHCP 服务器都将接受。

IP:ID = 0x0; Proto = UDP; Len: 328

IP:Version = 4 (0x4)

IP:Header Length = 20 (0x14)

IP:Service Type = 0 (0x0)

IP:Precedence = Routine

IP:...0.... = Normal Delay

IP:....0... = Normal Throughput

IP:.....0.. = Normal Reliability

IP:Total Length = 328 (0x148)

IP:Identification = 0 (0x0)

IP:Flags Summary = 0 (0x0)

IP:.......0 = Last fragment in datagram

IP:......0. = May fragment datagram if necessary

IP:Fragment Offset = 0 (0x0) bytes

IP:Time to Live = 128 (0x80)

IP:Protocol = UDP - User Datagram

IP:Checksum = 0x39A6

IP:Source Address = 0.0.0.0

IP:Destination Address = 255.255.255.255

IP:Data:Number of data bytes remaining = 308 (0x0134)

DHCP:Request (xid=2757554E)

DHCP:Op Code (op) = 1 (0x1)

DHCP:Hardware Type (htype) = 1 (0x1) 10Mb Ethernet

DHCP:Hardware Address Length (hlen) = 6 (0x6)

DHCP:Hops (hops) = 0 (0x0)

DHCP:Transaction ID (xid) = 660034894 (0x2757554E)

DHCP:Seconds (secs) = 0 (0x0)

DHCP:Flags (flags) = 0 (0x0)

DHCP:0............... = No Broadcast

DHCP:Client IP Address (ciaddr) = 0.0.0.0

DHCP:Your IP Address (yiaddr) = 0.0.0.0

DHCP:Server IP Address (siaddr) = 0.0.0.0

DHCP:Relay IP Address (giaddr) = 0.0.0.0

DHCP:Client Ethernet Address (chaddr) = 08002B2ED85E

DHCP:Server Host Name (sname) = <Blank>

DHCP:Boot File Name (file) = <Blank>

DHCP:Magic Cookie = [OK]

DHCP:Option Field (options)

DHCP:DHCP Message Type = DHCP Request

DHCP:Client-identifier = (Type:1) 08 00 2b 2e d8 5e

DHCP:Requested Address = 157.54.50.5

DHCP:Host Name = JUMBO-WS

DHCP:Parameter Request List = (Length:7) 01 0f 03 2c 2e 2f 06

DHCP:End of this option field

这时,服务器可能响应,也可能不响应。Windows NT DHCP 服务器的行为取决于所使用的操作系统版本以及其他因素,如超级作用域。如果服务器决定客户端仍然可以使用该地址,它将保持静默或对 DHCPREQUEST 发出 ACK。如果服务器决定客户端不能拥有该地址,它将发送 NACK。

IP:ID = 0x3F1A; Proto = UDP; Len: 328

IP:Version = 4 (0x4)

IP:Header Length = 20 (0x14)

IP:Service Type = 0 (0x0)

IP:Precedence = Routine

IP:...0.... = Normal Delay

IP:....0... = Normal Throughput

IP:.....0.. = Normal Reliability

IP:Total Length = 328 (0x148)

IP:Identification = 16154 (0x3F1A)

IP:Flags Summary = 0 (0x0)

IP:.......0 = Last fragment in datagram

IP:......0. = May fragment datagram if necessary

IP:Fragment Offset = 0 (0x0) bytes

IP:Time to Live = 128 (0x80)

IP:Protocol = UDP - User Datagram

IP:Checksum = 0x2CBE

IP:Source Address = 157.54.48.151

IP:Destination Address = 255.255.255.255

IP:Data:Number of data bytes remaining = 308 (0x0134)

DHCP:NACK (xid=74A005CE)

DHCP:Op Code (op) = 2 (0x2)

DHCP:Hardware Type (htype) = 1 (0x1) 10Mb Ethernet

DHCP:Hardware Address Length (hlen) = 6 (0x6)

DHCP:Hops (hops) = 0 (0x0)

DHCP:Transaction ID (xid) = 1956644302 (0x74A005CE)

DHCP:Seconds (secs) = 0 (0x0)

DHCP:Flags (flags) = 0 (0x0)

DHCP:0............... = No Broadcast

DHCP:Client IP Address (ciaddr) = 0.0.0.0

DHCP:Your IP Address (yiaddr) = 0.0.0.0

DHCP:Server IP Address (siaddr) = 0.0.0.0

DHCP:Relay IP Address (giaddr) = 0.0.0.0

DHCP:Client Ethernet Address (chaddr) = 08002B2ED85E

DHCP:Server Host Name (sname) = <Blank>

DHCP:Boot File Name (file) = <Blank>

DHCP:Magic Cookie = [OK]

DHCP:Option Field (options)

DHCP:DHCP Message Type = DHCP NACK

DHCP:Server Identifier = 157.54.48.151

DHCP:End of this option field

然后,客户端将开始发现进程,但 DHCPDISCOVER 数据包仍然尝试租用相同的地址。在许多情况下,tth 客户端将得到相同的地址,但也可能得不到。

IP:ID = 0x100; Proto = UDP; Len: 328

IP:Version = 4 (0x4)

IP:Header Length = 20 (0x14)

IP:Service Type = 0 (0x0)

IP:Precedence = Routine

IP:...0.... = Normal Delay

IP:....0... = Normal Throughput

IP:.....0.. = Normal Reliability

IP:Total Length = 328 (0x148)

IP:Identification = 256 (0x100)

IP:Flags Summary = 0 (0x0)

IP:.......0 = Last fragment in datagram

IP:......0. = May fragment datagram if necessary

IP:Fragment Offset = 0 (0x0) bytes

IP:Time to Live = 128 (0x80)

IP:Protocol = UDP - User Datagram

IP:Checksum = 0x38A6

IP:Source Address = 0.0.0.0

IP:Destination Address = 255.255.255.255

IP:Data:Number of data bytes remaining = 308 (0x0134)

DHCP:Discover (xid=3ED14752)

DHCP:Op Code (op) = 1 (0x1)

DHCP:Hardware Type (htype) = 1 (0x1) 10Mb Ethernet

DHCP:Hardware Address Length (hlen) = 6 (0x6)

DHCP:Hops (hops) = 0 (0x0)

DHCP:Transaction ID (xid) = 1053902674 (0x3ED14752)

DHCP:Seconds (secs) = 0 (0x0)

DHCP:Flags (flags) = 0 (0x0)

DHCP:0............... = No Broadcast

DHCP:Client IP Address (ciaddr) = 0.0.0.0

DHCP:Your IP Address (yiaddr) = 0.0.0.0

DHCP:Server IP Address (siaddr) = 0.0.0.0

DHCP:Relay IP Address (giaddr) = 0.0.0.0

DHCP:Client Ethernet Address (chaddr) = 08002B2ED85E

DHCP:Server Host Name (sname) = <Blank>

DHCP:Boot File Name (file) = <Blank>

DHCP:Magic Cookie = [OK]

DHCP:Option Field (options)

DHCP:DHCP Message Type = DHCP Discover

DHCP:Client-identifier = (Type:1) 08 00 2b 2e d8 5e

DHCP:Requested Address = 157.54.51.5

DHCP:Host Name = JUMBO-WS

DHCP:Parameter Request List = (Length:7) 01 0f 03 2c 2e 2f 06

DHCP:End of this option field

客户端从 DHCP 服务器获得的 DHCP 信息中将有与该信息关联的租约时间。租约时间定义了对于 DHCP 分配的信息,客户端可以使用多久。当租约时间达到某个特殊时刻时,客户端将尝试更新其 DHCP 信息。

要在 Windows 或 Windows for Workgroups 客户端上查看 IP 信息,请使用 IPCONFIG 实用工具。如果客户端是 Windows 95,请使用 WINIPCFG。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有