Você está na página 1de 9

DHCP discovery

The client broadcasts messages on the physical subnet to discover available DHCP servers.
Network administrators can configure a local router to forward DHCP packets to a DHCP
server from a different subnet. This client-implementation creates a User Datagram
Protocol (UDP) packet with the broadcast destination of 255.255.255.255 or the specific
subnet broadcast address.

A DHCP client can also request its last-known IP address (in the example below,
192.168.1.100). If the client remains connected to a network for which this IP is valid, the
server might grant the request. Otherwise, it depends whether the server is set up as
authoritative or not. An authoritative server will deny the request, making the client ask for
a new IP address immediately. A non-authoritative server simply ignores the request,
leading to an implementation-dependent timeout for the client to give up on the request and
ask for a new IP address.

DHCPDISCOVER
UDP Src=0.0.0.0 sPort=68
Dest=255.255.255.255 dPort=67
OP HTYPE HLEN HOPS
0x01 0x01 0x06 0x00
XID
0x3903F326
SECS FLAGS
0x0000 0x0000
CIADDR (Client IP Address)
0x00000000
YIADDR (Your IP Address)
0x00000000
SIADDR (Server IP Address)
0x00000000
GIADDR (Gateway IP Address)
0x00000000
CHADDR (Client Hardware Address)
0x00053C04
0x8D590000
0x00000000
0x00000000
192 octets of 0s. BOOTP legacy
Magic Cookie
0x63825363
DHCP Options
DHCP option 53: DHCP Discover
DHCP option 50: 192.168.1.100 requested
DHCP option 55: Parameter Request List:
Request Subnet Mask (1), Router (3), Domain Name (15),

Domain Name Server (6)

[edit] DHCP offer

When a DHCP server receives an IP lease request from a client, it reserves an IP address
for the client and extends an IP lease offer by sending a DHCPOFFER message to the
client. This message contains the client's MAC address, the IP address that the server is
offering, the subnet mask, the lease duration, and the IP address of the DHCP server
making the offer.

The server determines the configuration based on the client's hardware address as specified
in the CHADDR (Client Hardware Address) field. Here the server, 192.168.1.1, specifies
the IP address in the YIADDR (Your IP Address) field.

DHCPOFFER
UDP Src=192.168.1.1 sPort=67
Dest=255.255.255.255 dPort=68
OP HTYPE HLEN HOPS
0x02 0x01 0x06 0x00
XID
0x3903F326
SECS FLAGS
0x0000 0x0000
CIADDR
0x00000000
YIADDR
0xC0A80164
SIADDR
0xC0A80101
GIADDR
0x00000000
CHADDR
0x00053C04
0x8D590000
0x00000000
0x00000000
192 octets of 0s. BOOTP legacy
Magic Cookie
0x63825363
DHCP Options
DHCP option 53: DHCP Offer
DHCP option 1: 255.255.255.0 subnet mask
DHCP option 3: 192.168.1.1 router
DHCP option 51: 86400s (1 day) IP lease time
DHCP option 54: 192.168.1.1 DHCP server
DHCP option 6: DNS servers 9.7.10.15, 9.7.10.16, 9.7.10.18

[edit] DHCP request

A client can receive DHCP offers from multiple servers, but it will accept only one DHCP
offer and broadcast a DHCP request message. Based on the Transaction ID field in the
request, servers are informed whose offer the client has accepted. When other DHCP
servers receive this message, they withdraw any offers that they might have made to the
client and return the offered address to the pool of available addresses. The DHCP request
message is broadcast, instead of being unicast to a particular DHCP server, because the
DHCP client has still not received an IP address. Also, this way one message can let all
other DHCP servers know that another server will be supplying the IP address without
missing any of the servers with a series of unicast messages.

DHCPREQUEST
UDP Src=0.0.0.0 sPort=68
Dest=255.255.255.255 dPort=67
OP HTYPE HLEN HOPS
0x01 0x01 0x06 0x00
XID
0x3903F326
SECS FLAGS
0x0000 0x0000
CIADDR
0x00000000
YIADDR
0x00000000
SIADDR
0xC0A80101
GIADDR
0x00000000
CHADDR
0x00053C04
0x8D590000
0x00000000
0x00000000
192 octets of 0s. BOOTP legacy
Magic Cookie
0x63825363
DHCP Options
DHCP option 53: DHCP Request
DHCP option 50: 192.168.1.100 requested
DHCP option 54: 192.168.1.1 DHCP
server.

[edit] DHCP acknowledgement

When the DHCP server receives the DHCPREQUEST message from the client, the
configuration process enters its final phase. The acknowledgement phase involves sending
a DHCPACK packet to the client. This packet includes the lease duration and any other
configuration information that the client might have requested. At this point, the IP
configuration process is completed.

The protocol expects the DHCP client to configure its network interface with the negotiated
parameters.

DHCPACK
UDP Src=192.168.1.1 sPort=67
Dest=255.255.255.255 dPort=68
OP HTYPE HLEN HOPS
0x02 0x01 0x06 0x00
XID
0x3903F326
SECS FLAGS
0x0000 0x0000
CIADDR (Client IP Address)
0x00000000
YIADDR (Your IP Address)
0xC0A80164
SIADDR (Server IP Address)
0xC0A80101
GIADDR (Gateway IP Address switched by relay)
0x00000000
CHADDR (Client Hardware Address)
0x00053C04
0x8D590000
0x00000000
0x00000000
192 octets of 0s. BOOTP legacy
Magic Cookie
0x63825363
DHCP Options
DHCP option 53: DHCP ACK
DHCP option 1: 255.255.255.0 subnet mask
DHCP option 3: 192.168.1.1 router
DHCP option 51: 86400s (1 day) IP lease time
DHCP option 54: 192.168.1.1 DHCP server
DHCP option 6: DNS servers 9.7.10.15, 9.7.10.16, 9.7.10.18

After the client obtains an IP address, the client may use the Address Resolution Protocol
(ARP) to prevent IP conflicts caused by overlapping address pools of DHCP servers.
Dynamic Host Configuration Protocol (DHCP) Message Options
0Share

Dynamic Host Configuration Protocol (DHCP) message's options section carries additional
configuration information between Dynamic Host Configuration Protocol (DHCP) client
and the Dynamic Host Configuration Protocol (DHCP) server. The first four bytes of the
field carry the "magic cookie" value 99, 130, 83, 99 in decimals (63, 82, 53, 63 in
hexadecimals) to identify the information as vendor-independent option fields. Dynamic
Host Configuration Protocol (DHCP) message's options contains an option code, option
length, and option data. The option code identifies Dynamic Host Configuration Protocol
(DHCP) option, option length is the length of the option data field (in bytes) and the option
data is the information required.

Some of the important DHCP options are listed below.

The Dynamic Host Configuration Protocol (DHCP) message type Option

A Dynamic Host Configuration Protocol (DHCP) client and server exchanges different
messages during the lease process. The DHCP message type option includes the DHCP
message type option code (53), the length of the data field (1), and the message type (single
byte) can be one of the following values.

Message Type indicates the DHCP message and can contain any of the following values.

1 = Dynamic Host Configuration Protocol (DHCP) Discover message (DHCPDiscover).


2 = Dynamic Host Configuration Protocol (DHCP) Offer message (DHCPOffer).

3 = Dynamic Host Configuration Protocol (DHCP) Request message (DHCPRequest).

4 = Dynamic Host Configuration Protocol (DHCP) Decline message (DHCPDecline).

5 = Dynamic Host Configuration Protocol (DHCP) Acknowledgment message


(DHCPAck).

6 = Dynamic Host Configuration Protocol (DHCP) Negative Acknowledgment message


(DHCPNak).

7 = Dynamic Host Configuration Protocol (DHCP) Release message (DHCPRelease).

8 = Dynamic Host Configuration Protocol (DHCP) Informational message (DHCPInform)

The subnet mask Option

The subnet mask option carries the subnet mask that the client should use. The client’s IP
address is in the ciaddr field in the fixed format section of the DHCP message, but the
subnet mask is carried as an option. The subnet mask option has an option code of 1, a
length of 4, and 32-bit mask.

The DNS Server Option

The Domain Name System is used for name resolution. A human friendly device name is
resolved to an IP address using DNS. The DNS server option carries a list of addresses of
DNS servers that the client can use. The DNS server option code is 6, the length (the
number of DNS Servers listed in the option multiplied by four), and the IP addresses of the
DNS servers.
The router Option

If the client needs to communicate to another network segment, it needs to know the default
gateway (router). The router option has an option code of 3, a variable length (the number
of routers listed in the option multiplied by four), and the IP addresses of the routers.

The requested IP address Option

When Dynamic Host Configuration Protocol (DHCP) clients send a DHCPDiscover


message to find a Dynamic Host Configuration Protocol (DHCP) server, it can request a
specific IP address be assigned by the DHCP server. The requested IP address Option is
used for requesting a specific IP address from a Dynamic Host Configuration Protocol
(DHCP) server.

The DNS Domain Name Option

The DNS Domain Name Option specifies the domain name the client should use.
The end Option

The end option is used to indicate the end of the options in the options section of a DHCP
message. The end option has a fixed length. There is no length field and data field. The end
option is a is a single byte set to the value 255.

In this lesson, we have learned some important Dynamic Host Configuration Protocol
(DHCP) message options and the Dynamic Host Configuration Protocol (DHCP) message
option formats. Click "Next" to continue.

Related Topics...

Você também pode gostar