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

文章翻译 文章翻译
文章编号: 169289 - 查看本文应用于的产品
本文的发布号曾为 CHS169289
展开全部 | 关闭全部

概要

动态主机配置协议 (DHCP) 是由 RFC 1541(已被 RFC 2131 取代)定义的标准协议,允许服务器将 IP 地址和配置信息动态分发给客户端。正常情况下,DHCP 服务器至少会为客户端提供以下基本信息:
  • IP 地址

  • 子网掩码

  • 默认网关
也可以提供以下信息,例如域名服务 (DNS) 服务器地址和 Windows Internet 名称服务 (WINS) 服务器地址。系统管理员会使用解析到客户端的选项配置 DHCP 服务器。

更多信息

以下 Microsoft 产品提供了 DHCP 客户端功能:
  • Windows NT Server 版本 3.5、3.51 和 4.0

  • Windows NT Workstation 版本 3.5、3.51 和 4.0

  • Windows 95

  • 用于 MS-DOS 的 Microsoft 网络客户端版本 3.0

  • 用于 MS-DOS 的 Microsoft LAN Manager 客户端版本 2.2c

  • 用于工作组 Windows 的 Microsoft TCP/IP-32 版本 3.11、3.11a 和 3.11b
不同的 DHCP 客户端支持可从 DHCP 服务器接收的不同选项。有关 Microsoft DHCP 客户端支持的特定 DHCP 选项的信息,请参阅 Microsoft 知识库中的下列文章:
121005 由客户端支持的 DHCP 选项
以下 Microsoft 服务器操作系统提供 DHCP 服务器功能:
  • Windows NT Server 3.5 版

  • Windows NT Server 3.51 版

  • Windows NT Server 4.0 版
在客户端配置为接收 DHCP 信息后首次初始化时,它将发起与服务器的对话。

以下是客户端和服务器对话的汇总表,后面是这一过程数据包级别的说明:
Source     Dest        Source     Dest              Packet
MAC addr   MAC addr    IP addr    IP addr           说明
   -----------------------------------------------------------------
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 部分,您可以看到目的地址为 255.255.255.255,源地址为 0.0.0.0。DHCP 部分将数据包识别为 Discover 包,并使用网卡的物理地址在两个位置识别了客户端。请注意 CHADDR 字段和 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: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 部分,源地址现在是 DHCP 服务器 IP 地址,而目的地址是广播地址 255.255.255.255。DHCP 部分将数据包识别为 Offer。YIADDR 字段将填充服务器提供给客户端的 IP 地址。请注意,CHADDR 字段仍包含请求客户端的物理地址。此外,在 DHCP 选项字段部分,我们可以看到服务器发送的各个选项以及 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 部分,客户端的源地址仍然为 0.0.0.0,数据包的目的地址仍然为 255.255.255.255。由于客户端未收到服务器表示可以使用提供的地址开始的确认,因此客户端保留为 0.0.0.0。由于多个 DHCP 服务器进行了响应,且可能持有对客户端 Offer 的预约,因此目的地址仍为广播。这可以让其他 DHCP 服务器知道,它们可以释放其提供的地址并将其返回到可用池中。DHCP 部分将数据包识别为 Request,并使用 DHCP 验证所提供的地址:请求的地址字段。DHCP:服务器标识符字段显示提供租用的 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,因此完成了初始化周期。源地址为 DHCP 服务器 IP 地址,而目的地址仍为 255.255.255.255。YIADDR 字段包含客户端的地址、CHADDR 和 DHCP:客户端标识符字段是请求客户端中网卡的物理地址。DHCP 选项部分将数据包识别为 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 地址。源地址为 0.0.0.0,目的地址为广播地址 255.255.255.255。Microsoft 客户端将使用之前分配的地址填充 DHCP 选项字段 DHCP:请求的地址。严格符合 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 服务器的行为取决于所用的操作系统版本以及超级作用域等其他因素。如果服务器确定客户端仍可以使用该地址,它将保持静默或 ACK DHCPREQUEST。如果服务器确定客户端无法使用该地址,它将发送 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 数据包仍然会尝试租用同一地址。在许多实例中,客户端将获取同一地址,但可能无法获得。
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 客户端的 IP 信息,请使用 IPCONFIG 实用程序。如果客户端为 Windows 95,请使用 WINIPCFG。

参考

有关 DHCP 的详细信息,请参阅 RFC1541 和 RFC2131。RFC 可通过 Internet 在众多站点获取,例如:
http://www.rfc-editor.org/
http://www.tech-nic.qc.ca/
注意:本篇“快速发布”文章是从 Microsoft 支持组织直接创建的。 文中包含的信息按原样提供,用于响应紧急问题。 由于发布仓促,材料可能包含印刷错误,并且可能随时修订,恕不另行通知。 有关其他注意事项,请参阅使用条款

属性

文章编号: 169289 - 最后修改: 2013年4月26日 - 修订: 1.0
这篇文章中的信息适用于:
  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Professional Edition
  • Microsoft Windows NT Workstation 3.5
  • Microsoft Windows NT Workstation 3.51
  • Microsoft Windows NT Workstation 4.0 开发员版
  • Microsoft Windows NT Server 3.51
  • Microsoft Windows NT Server 4.0 Standard Edition
  • Microsoft Windows 95
关键字:?
kbnetwork KB169289
Microsoft和/或其各供应商对于为任何目的而在本服务器上发布的文件及有关图形所含信息的适用性,不作任何声明。 所有该等文件及有关图形均"依样"提供,而不带任何性质的保证。Microsoft和/或其各供应商特此声明,对所有与该等信息有关的保证和条件不负任何责任,该等保证和条件包括关于适销性、符合特定用途、所有权和非侵权的所有默示保证和条件。在任何情况下,在由于使用或运行本服务器上的信息所引起的或与该等使用或运行有关的诉讼中,Microsoft和/或其各供应商就因丧失使用、数据或利润所导致的任何特别的、间接的、衍生性的损害或任何因使用而丧失所导致的之损害、数据或利润不负任何责任。

提供反馈

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com