Protokół DHCP (Dynamic Host Configuration Protocol) jest standardowym protokołem zdefiniowanym w specyfikacji RFC 1541 (zastąpionej przez specyfikację RFC 2131), który zezwala serwerowi na dynamiczną dystrybucję adresów IP i informacji konfiguracyjnych do klientów. Na ogół serwer DHCP dostarcza klientowi przynajmniej następujące podstawowe informacje:
| • | Adres IP
|
| • | Maskę podsieci
|
| • | Bramę domyślną |
Mogą być również dostarczane inne informacje, takie jak adresy serwerów DNS (Domain Name Service) oraz serwerów WINS (Windows Internet Name Service). Administrator systemu konfiguruje serwer DHCP za pomocą opcji przydzielonych klientowi.
Następujące produkty firmy Microsoft oferują funkcjonalność klienta protokołu DHCP:
| • | System Windows NT Server w wersji 3.5, 3.51 oraz 4.0
|
| • | System Windows NT Workstation w wersji 3.5, 3.51 oraz 4.0
|
| • | System Windows 95
|
| • | Klient sieci Microsoft Network w wersji 3.0 dla systemu MS-DOS
|
| • | Klient sieci Microsoft LAN Manager w wersji 2.2c dla systemu MS-DOS
|
| • | Microsoft TCP/IP-32 dla systemu Windows for Workgroups w wersji 3.11, 3.11a oraz 3.11b
|
Różni klienci protokołu DHCP obsługują różne opcje, które mogą otrzymać z serwera DHCP. Aby uzyskać informacje o konkretnych opcjach DHCP obsługiwanych przez klientów protokołu DHCP firmy Microsoft, zobacz następujący artykuł z bazy wiedzy Microsoft Knowledge Base:
Następujące serwerowe systemy operacyjne firmy Microsoft oferują funkcjonalność serwera DHCP:
| • | Windows NT Server w wersji 3.5
|
| • | Windows NT Server w wersji 3.51
|
| • | Windows NT Server w wersji 4.0
|
Podczas inicjowania klienta po skonfigurowaniu go do odbierania informacji protokołu DHCP klient rozpoczyna konwersację z serwerem.
Poniżej przedstawiono tabelę podsumowującą konwersację między serwerem a klientem, po której następuje opis procesu na poziomie pakietu:
Źródłowy Docelowy Źródłowy Docelowy Opis
adres MAC adres MAC adres IP adres IP pakietu
-----------------------------------------------------------------
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
Szczegóły konwersacji między klientem protokołu DHCP i serwerem DHCP są następujące:
DHCPDISCOVER
Klient wysyła pakiet DHCPDISCOVER. Poniżej znajduje się fragment danych przechwyconych przez monitor sieci, pokazujący części IP oraz DHCP pakietu DHCPDISCOVER. W sekcji IP można zobaczyć, że adres docelowy to 255.255.255.255, a adres źródłowy to 0.0.0.0. Sekcja DHCP identyfikuje pakiet jako Discover oraz identyfikuje klienta w dwóch miejscach przy użyciu fizycznego adresu karty sieciowej. Należy zwrócić uwagę, że wartości w polach CHADDR oraz DHCP: Client Identifier są identyczne.
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
Serwer DHCP odpowiada, wysyłając pakiet DHCPOFFER. W sekcji IP przechwyconego fragmentu poniżej adres źródłowy jest teraz adresem IP serwera DHCP, a adres docelowy jest adresem emisji 255.255.255.255. Sekcja DHCP identyfikuje pakiet jako Offer. Pole YIADDR jest wypełnione adresem IP oferowanym klientowi przez serwer. Należy zauważyć, że pole CHADDR nadal zawiera fizyczny adres klienta, który wysłał żądanie. W sekcji DHCP Option Field widać także różne opcje wysyłane przez serwer wraz z adresem IP. W tym wypadku serwer wysyła maskę podsieci, bramę domyślną (router), czas dzierżawy, adres serwera WINS (usługa nazw NetBIOS) oraz typ węzła 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
W odpowiedzi na pakiet DHCPOFFER klient wysyła pakiet DHCPREQUEST. W sekcji IP przechwyconych danych poniżej adres źródłowy klienta to nadal 0.0.0.0, a adres docelowy pakietu to nadal 255.255.255.255. Klient zachowuje adres 0.0.0.0, ponieważ nie odebrał z serwera potwierdzenia, że może zacząć korzystać z oferowanego adresu. Adres docelowy to nadal adres emisji, ponieważ więcej niż jeden serwer DHCP mógł odpowiedzieć lub przetrzymywać rezerwację oferty przedstawionej klientowi. Dzięki temu inne serwery DHCP wiedzą, że mogą zwolnić swoje oferowane adresy i zwrócić je do pul dostępnych adresów. Sekcja DHCP identyfikuje pakiet jako Request i weryfikuje oferowane adresy przy użyciu pola DHCP: Requested Address. W polu DHCP: Server Identifier widoczny jest adres IP serwera DHCP oferującego dzierżawę.
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) =
DHCP: Boot File Name (file) =
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
Serwer DHCP odpowiada na pakiet DHCPREQUEST za pomocą pakietu DHCPACK, który kończy cykl inicjowania. Adres źródłowy jest adresem IP serwera DHCP, a adres docelowy to nadal 255.255.255.255. Pole YIADDR zawiera adres klienta, a pola CHADDR i DHCP: Client Identifier są fizycznym adresem karty sieciowej klienta wysyłającego żądanie. Sekcja DHCP Option identyfikuje pakiet jako 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) =
DHCP: Boot File Name (file) =
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
Klient, który miał wcześniej adres IP przydzielony przez serwer DHCP i został ponownie uruchomiony, będzie żądał poprzednio dzierżawionego adresu IP w specjalnym pakiecie DHCPREQUEST. Adres źródłowy to 0.0.0.0, a adres docelowy jest adresem emisji 255.255.255.255. Klienci firmy Microsoft będą wypełniać pole DHCP: Requested Address w sekcji DHCP Option Field poprzednio przydzielonym adresem. Klienci w pełni zgodni ze specyfikacją RFC będą wypełniać pole CIADDR żądanym adresem. Serwer Microsoft DHCP będzie akceptować oba wpisy.
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) =
DHCP: Boot File Name (file) =
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
W tym momencie serwer mógł odpowiedzieć lub nie. Zachowanie serwera DHCP systemu Windows NT zależy od wersji używanego systemu operacyjnego i innych czynników, takich jak tworzenie superzakresów. Jeśli serwer stwierdzi, że klient nadal może używać adresu, milczy albo wysyła pakiet ACK w odpowiedzi na pakiet DHCPREQUEST. Jeśli serwer stwierdzi, że klient nie może korzystać z adresu, wysyła pakiet 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) =
DHCP: Boot File Name (file) =
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
Klient może następnie rozpocząć proces discover, ale pakiet DHCPDISCOVER nadal będzie próbować dzierżawić ten sam adres. W wielu wypadkach klient otrzyma ten sam adres, ale nie musi to nastąpić.
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) =
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: 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
Informacje protokołu DHCP uzyskane przez klienta z serwera DHCP będą zawierały skojarzony z nim czas dzierżawy. Czas dzierżawy definiuje, jak długo klient może używać przydzielonych informacji DHCP. Po upływie pewnego czasu dzierżawy klient będzie próbował odnowić swoje informacje DHCP.
Aby wyświetlić informacje IP na kliencie z systemem Windows lub Windows for Workgroups, należy użyć narzędzia IPCONFIG. W wypadku klienta z systemem Windows 95 należy użyć narzędzia WINIPCFG.