■ 概要
动态主机配置协议 (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
Microsoft Network Client 3.0 for MS-DOS
Microsoft LAN Manager Client 2.2c for MS-DOS
Microsoft TCP/IP-32 for Windows for Workgroups 3.11、3.11a 和 3.11b
DHCP 客户端可以接收来自 DHCP 服务器的选项,而不同的 DHCP 客户端支持不同的这些选项。 有关 Microsoft DHCP 客户端所支持的特定 DHCP 选项的信息,请参见 Microsoft Knowledge Base 中以下文章:
Q121005 受客户端支持的 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 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) =
DHCP: Boot File Name (file) =
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) =
DHCP: Boot File Name (file) =
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。 由于