Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Dynamic Host Configuration Protocol
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Operation== [[File:DHCP session.svg|thumb|right|upright=1.2|An illustration of a typical non-renewing DHCP session; each message may be either a broadcast or a [[unicast]], depending on the DHCP client capabilities.{{Ref RFC|2131}}]] The DHCP employs a [[connectionless]] service model, using the [[User Datagram Protocol]] (UDP). It is implemented with two UDP port numbers for its operations which are the same as for the bootstrap protocol ([[BOOTP]]). The server listens on UDP port number 67, and the client listens on UDP port number 68. DHCP operations fall into four phases: server discovery, IP lease offer, IP lease request, and IP lease acknowledgement. These stages are often abbreviated as DORA for discovery, offer, request, and acknowledgement. The DHCP operation begins with clients broadcasting a request. If the client and server are in different [[Broadcast domain|Broadcast Domains]], a [[#Relaying|DHCP Helper or DHCP Relay Agent]] may be used. Clients requesting renewal of an existing lease may communicate directly via UDP [[unicast]], since the client already has an established IP address at that point. Additionally, there is a BROADCAST flag (1 bit in 2 byte flags field, where all other bits are reserved and so are set to 0) the client can use to indicate in which way (broadcast or unicast) it can receive the DHCPOFFER: 0x8000 for broadcast, 0x0000 for unicast.{{Ref RFC|2131}} Usually, the DHCPOFFER is sent through unicast. For those hosts which cannot accept unicast packets before IP addresses are configured, this flag can be used to work around this issue. ===Discovery=== The DHCP client [[Broadcasting (networking)|broadcasts]] a DHCPDISCOVER message on the network subnet using the destination address {{IPaddr|255.255.255.255}} (limited broadcast) or the specific subnet broadcast address (directed broadcast). A DHCP client may also request an IP address in the DHCPDISCOVER, which the server may take into account when selecting an address to offer. For example, if HTYPE is set to 1, to specify that the medium used is [[Ethernet]], HLEN is set to 6 because an Ethernet address (MAC address) is 6 octets long. The CHADDR is set to the MAC address used by the client. Some options are set as well. {{APHD|start|title=Example Ethernet frame with a DHCPDISCOVER message}} {{APHD|0|bits1=32|border1=bottom|field1=Source MAC|value1={{MACaddr|00:05:3c:04:8d:59}}}} {{APHD|4|bits1=16|border1=top|field1={{nbsp}}|bits2=16|border2=bottom|field2={{nbsp}}}} {{APHD|8|bits1=32|border1=top|field1=Destination MAC|value1={{MACaddr|ff:ff:ff:ff:ff:ff}}}} {{APHD|12|bits1=16|field1=EtherType|value1={{Mono|0x0800}}|hint1=0x0800 indicates IPv4|bits2=16|border2=bottom|background2=mistyrose|field2={{nbsp}}}} {{APHD|16|bits1=0|border1=top|background1=mistyrose|field1=IPv4 packet, containing a UDP PDU with DHCP payload...}} {{APHD|999|bits1=32|field1=Frame Check Sequence|short1=FCS}} {{APHD|end}} {{APHD|start|header=yew|title=IPv4 Header}} {{APHD|0|bits1=64|field1=IPv4 header start}} {{APHD|8|bits1=8|bits2=8|bits3=16|field1=TTL|field2=Protocol|value2={{Mono|17}} UDP|field3=Header Checksum}} {{APHD|end}} {{APHD|start|header=no|title=UDP Header}} {{APHD|12|bits1=32|field1=Source Address|value1={{IPaddr|0.0.0.0}}}} {{APHD|16|bits1=32|field1=Destination Address|value11={{IPaddr|255.255.255.255}}}} {{APHD|20|bits1=16|bits2=16|field1=Source Port|value1=68|field2=Destination Port|value2=67}} {{APHD|24|bits1=16|bits2=16|field1=Length|field2=Checksum}} {{APHD|end}} {{APHD|start|header=no|title=DHCP Payload: DHCPDISCOVER}} {{APHD|28|bits1=8|bits2=8|bits3=8|bits4=8|field1=OP|value1={{Mono|0x01}}|hint1=BOOTREQUEST|field2=HTYPE|value2={{Mono|0x01}}|hint2=Ethernet|field3=HLEN|value3={{Mono|0x06}}|hint3=MAC addresses are 6 octets|field4=HOPS|value4={{Mono|0x00}}}} {{APHD|32|bits1=32|field1=XID|value1={{Mono|0x3903F326}}}} {{APHD|36|bits1=16|bits2=16|field1=SECS|value1={{Mono|0x0000}}|field2=FLAGS|value2={{Mono|0x0000}}}} {{APHD|40|bits1=32|field1=CIADDR|value1=Client IP address: {{Mono|0x00000000}}}} {{APHD|44|bits1=32|field1=YIADDR| value1=Your IP address: {{Mono|0x00000000}}}} {{APHD|48|bits1=32|field1=SIADDR|value1=Server IP address: {{Mono|0x00000000}}}} {{APHD|52|bits1=32|field1=GIADDR|value1=Gateway IP address: {{Mono|0x00000000}}|hint1=A zero GIADDR means client and DHCP server are on the same subnet.}} {{APHD|56|bits1=128|field1=CHADDR|value1=Client Hardware address: {{Mono|0x00053C04<br>0x8D590000<br>0x00000000<br>0x00000000}}}} {{APHD|72|bits1=1536|field1=192 octets of 0s, or overflow space for additional options; BOOTP legacy.}} {{APHD|264|bits1=32|field1=[[Magic Cookie]]|value1={{Mono|0x63825363}}}} {{APHD|end}} {{APHD|start|header=no|title=DHCP Options (in [[Type-length-value|TLV]] format)}} {{APHD|268|bits1=24|background1=linen|field1=First option: {{Mono|0x350101}}: Option 53 (DHCP Message Type) 1 octet (containing DHCPDISCOVER)|bits2=8|background2=linen|border2=right|field2=Second option:}} {{APHD|272|bits1=32|background1=linen|border1=left|field1={{Mono|0x3204c0a80164}}: Option 50 (Request IP address) 4 octets (containing {{IPaddr|192.168.1.100}})}} {{APHD|276|bits1=32|background1=linen|field1=Third option: {{Mono|0x370401030f06}}: Option: 55 (Parameter Request List) 4 octets|hint1=0x01: Request Subnet Mask; 0x03: Router; 0x0f: Domain Name|border1=right}} {{APHD|280|bits1=8|background1=linen|border1=left|field1=PRL cont...|hint1=0x06: Domain Name Server|bits2=1|field2=<small>{{Mono|ff}}</small>|hint2=0xff Option end mark}} {{APHD|end}} ===Offer=== When a DHCP server receives a DHCPDISCOVER message from a client, which is an IP address lease request, the DHCP server reserves an IP address for the client and makes a lease offer by sending a DHCPOFFER message to the client. This message may contain the client's ''Client ID'' (Option 61, containing a unique value, traditionally a 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 DHCP server may also take notice of the hardware-level MAC address (as specified in the CHADDR field). This field must be used to identify the client, if no Client ID is provided in the DHCP packet.{{Ref RFC|2131|rsection=4.2}} The DHCP server determines the configuration based on the client's hardware address as specified in the CHADDR (client hardware address) field. In the following example the server ({{IPaddr|192.168.1.1}}) specifies the client's IP address in the YIADDR (your IP address) field. {{APHD|start|title=Example Ethernet frame with a DHCPOFFER message}} {{APHD|0|bits1=32|border1=bottom|field1=Source MAC|value1={{MACaddr|b4:0c:25:e3:7d:62}}}} {{APHD|4|bits1=16|border1=top|field1={{nbsp}}|bits2=16|border2=bottom|field2={{nbsp}}}} {{APHD|8|bits1=32|border1=top|field1=Destination MAC|value1={{MACaddr|00:05:3c:04:8d:59}}}} {{APHD|12|bits1=16|field1=EtherType|value1={{Mono|0x0800}}|hint1=0x0800 indicates IPv4|bits2=16|border2=bottom|background2=mistyrose|field2={{nbsp}}}} {{APHD|16|bits1=0|border1=top|background1=mistyrose|field1=IPv4 packet, containing a UDP PDU with DHCP payload...}} {{APHD|999|bits1=32|field1=Frame Check Sequence|short1=FCS}} {{APHD|end}} {{APHD|start|header=yew|title=IPv4 Header}} {{APHD|0|bits1=64|field1=IPv4 header start}} {{APHD|8|bits1=8|bits2=8|bits3=16|field1=TTL|field2=Protocol ({{Mono|17}} UDP)|field3=Header Checksum}} {{APHD|end}} {{APHD|start|header=no|title=UDP Header}} {{APHD|12|bits1=32|field1=Source Address ({{IPaddr|192.168.1.1}})}} {{APHD|16|bits1=32|field1=Destination Address ({{IPaddr|192.168.1.100}})}} {{APHD|20|bits1=16|bits2=16|field1=Source Port (67)|field2=Destination Port (68)}} {{APHD|24|bits1=16|bits2=16|field1=Length|field2=Checksum}} {{APHD|end}} {{APHD|start|header=no|title=DHCP Payload: DHCPOFFER}} {{APHD|28|bits1=8|bits2=8|bits3=8|bits4=8|field1=OP ({{Mono|0x02}})|hint1=BOOTREPLY|field2=HTYPE ({{Mono|0x01}})|field3=HLEN ({{Mono|0x06}})|field4=HOPS ({{Mono|0x00}})}} {{APHD|32|bits1=32|field1=XID ({{Mono|0x3903F326}})}} {{APHD|36|bits1=16|bits2=16|field1=SECS ({{Mono|0x0000}})|field2=FLAGS ({{Mono|0x0000}})}} {{APHD|40|bits1=32|field1=CIADDR (Client IP address: {{Mono|0x00000000}})}} {{APHD|44|bits1=32|field1=YIADDR (Your IP address: {{Mono|0xC0A80164}} or {{IPaddr|192.168.1.100}})}} {{APHD|48|bits1=32|field1=SIADDR (Server IP address: {{Mono|0xC0A80101}} or {{IPaddr|192.168.1.1}})}} {{APHD|52|bits1=32|field1=GIADDR (Gateway IP address: {{Mono|0x00000000}})}} {{APHD|56|bits1=128|field1=CHADDR (Client Hardware address: {{Mono|0x00053C04<br>0x8D590000<br>0x00000000<br>0x00000000}})}} {{APHD|72|bits1=1536|field1=192 octets of 0s, or overflow space for additional options; BOOTP legacy.}} {{APHD|264|bits1=32|field1=[[Magic Cookie]] ({{Mono|0x63825363}})}} {{APHD|end}} {{APHD|start|header=no|title=DHCP Options (in [[Type-length-value|TLV]] format)}} {{APHD|268|bits1=24|background1=linen|field1=First option: {{Mono|0x350102}}: Option 53 (DHCP Message Type) 1 octet (containing DHCPOFFER)|bits2=8|background2=linen|border2=right|field2=Second option:}} {{APHD|272|bits1=32|background1=linen|border1=left|field1={{Mono|0x0104ffffff00}}: Option 1 (Subnet mask) 4 octets (containing {{IPaddr|255.255.255.0}})}} {{APHD|276|bits1=32|background1=linen|field1=Third option: {{Mono|0x0304c0A80101}}: Option: 3 (Router) 4 octets (containing {{IPaddr|192.168.1.1}})|border1=right}} {{APHD|280|bits1=8|bits2=24|background1=linen|border1=left|field1=Router cont...||background2=linen|border2=right|field2=Fourth option: {{Mono|0x330400015080}}: Option 51 (Address time) 4 octets (a 86400 second lease time)}} {{APHD|284|bits1=16|background1=linen|border1=left|field1=Address time cont...|bits2=16|border2=bottom|field2=Fifth option:|background2=linen}} {{APHD|288|bits1=96|background1=linen|border1=top-bottom|field1={{Mono|0x060c09070a0f09070a1009070a13}}:{{Break}}Option 6 (Domain Server) 14 octets (containing {{IPaddr|9.7.10.15}},{{IPaddr|9.7.10.16}},{{IPaddr|9.7.10.18}})}} {{APHD|300|bits1=12|background1=linen|field1= |border1=top|field2=<small>{{Mono|ff}}</small>|hint2=0xff Option end mark}} {{APHD|end}} ===Request=== In response to the DHCP offer, the client replies with a DHCPREQUEST message, broadcast to the server,{{Efn|name="optional-unicasts"|As an optional client behavior, some broadcasts, such as those carrying DHCP discovery and request messages, may be replaced with unicasts in case the DHCP client already knows the DHCP server's IP address.{{Ref RFC|2131}}{{rp|section=4.4.4}}}} requesting the offered address. A client can receive DHCP offers from multiple servers, but it will accept only one DHCP offer. The client must send the ''server identification'' option in the DHCPREQUEST message, indicating the server whose offer the client has selected.{{Ref RFC|2131}}{{rp|Section 3.1, Item 3}} When other DHCP servers receive this message, they withdraw any offers that they have made to the client and return their offered IP address to the pool of available addresses. {{APHD|start|title=Example Ethernet frame with a DHCPREQUEST message}} {{APHD|0|bits1=32|border1=bottom|field1=Source MAC|value1={{MACaddr|00:05:3c:04:8d:59}}}} {{APHD|4|bits1=16|border1=top|field1={{nbsp}}|bits2=16|border2=bottom|field2={{nbsp}}}} {{APHD|8|bits1=32|border1=top|field1=Destination MAC|value1={{MACaddr|ff:ff:ff:ff:ff:ff}}|hint1=Destination MAC (DHCPREQUESTs are broadcast)}} {{APHD|12|bits1=16|field1=EtherType|value1={{Mono|0x0800}}|hint1=0x0800 indicates IPv4|bits2=16|border2=bottom|background2=mistyrose|field2={{nbsp}}}} {{APHD|16|bits1=0|border1=top|background1=mistyrose|field1=IPv4 packet, containing a UDP PDU with DHCP payload...}} {{APHD|999|bits1=32|field1=Frame Check Sequence|short1=FCS}} {{APHD|end}} {{APHD|start|header=yew|title=IPv4 Header}} {{APHD|0|bits1=64|field1=IPv4 header start}} {{APHD|8|bits1=8|bits2=8|bits3=16|field1=TTL|field2=Protocol ({{Mono|17}} UDP)|field3=Header Checksum}} {{APHD|end}} {{APHD|start|header=no|title=UDP Header}} {{APHD|12|bits1=32|field1=Source Address ({{IPaddr|0.0.0.0}})}} {{APHD|16|bits1=32|field1=Destination Address ({{IPaddr|255.255.255.255}})}} {{APHD|20|bits1=16|bits2=16|field1=Source Port (68)|field2=Destination Port (67)}} {{APHD|24|bits1=16|bits2=16|field1=Length|field2=Checksum}} {{APHD|end}} {{APHD|start|header=no|title=DHCP Payload: DHCPREQUEST}} {{APHD|28|bits1=8|bits2=8|bits3=8|bits4=8|field1=OP ({{Mono|0x01}})|hint1=BOOTREQUEST|field2=HTYPE ({{Mono|0x01}})|field3=HLEN ({{Mono|0x06}})|field4=HOPS ({{Mono|0x00}})}} {{APHD|32|bits1=32|field1=XID ({{Mono|0x3903F326}})}} {{APHD|36|bits1=16|bits2=16|field1=SECS ({{Mono|0x0000}})|field2=FLAGS ({{Mono|0x0000}})}} {{APHD|40|bits1=32|field1=CIADDR (Client IP address: {{Mono|0x00000000}})}} {{APHD|44|bits1=32|field1=YIADDR (Your IP address: {{Mono|0x00000000}})}} {{APHD|48|bits1=32|field1=SIADDR (Server IP address: {{Mono|0xc0a80101}} or {{IPaddr|192.168.1.1}})}} {{APHD|52|bits1=32|field1=GIADDR (Gateway IP address: {{Mono|0x00000000}})}} {{APHD|56|bits1=128|field1=CHADDR (Client Hardware address: {{Mono|0x00053C04<br>0x8D590000<br>0x00000000<br>0x00000000}})}} {{APHD|72|bits1=1536|field1=192 octets of 0s, or overflow space for additional options; BOOTP legacy.}} {{APHD|264|bits1=32|field1=[[Magic Cookie]] ({{Mono|0x63825363}})}} {{APHD|end}} {{APHD|start|header=no|title=DHCP Options (in [[Type-length-value|TLV]] format)}} {{APHD|268|bits1=24|background1=linen|field1=First option: {{Mono|0x350103}}: Option 53 (DHCP Message Type) 1 octet (containing DHCPREQUEST)|bits2=8|background2=linen|border2=right|field2=Second option:}} {{APHD|272|bits1=32|background1=linen|border1=left|field1={{Mono|0x3204c0a80164}}: Option 50 (Request IP address) 4 octets (containing {{IPaddr|192.168.1.100}})|hint1=Must match YIADDR from the DHCPOFFER packet.}} {{APHD|276|bits1=32|background1=linen|field1=Third option: {{Mono|0x3604c0a801601}}: Option: 54 (DHCP Server) 4 octets (containing {{IPaddr|192.168.1.1}})|hint1=Server Identification: tell which offer you accept.|border1=right}} {{APHD|280|bits1=8|background1=linen|border1=left|field1=DHCP Server cont...|bits2=1|field2=<small>{{Mono|ff}}</small>|hint2=0xff Option end mark}} {{APHD|end}} ===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. {{APHD|start|title=Example Ethernet frame with a DHCPACK message}} {{APHD|0|bits1=32|border1=bottom|field1=Source MAC|value1={{MACaddr|b4:0c:25:e3:7d:62}}}} {{APHD|4|bits1=16|border1=top|field1={{nbsp}}|bits2=16|border2=bottom|field2={{nbsp}}}} {{APHD|8|bits1=32|border1=top|field1=Destination MAC|value1={{MACaddr|00:05:3c:04:8d:59}}|hint1=Destination MAC (unicast to the client)}} {{APHD|12|bits1=16|field1=EtherType|value1={{Mono|0x0800}}|hint1=0x0800 indicates IPv4|bits2=16|border2=bottom|background2=mistyrose|field2={{nbsp}}}} {{APHD|16|bits1=0|border1=top|background1=mistyrose|field1=IPv4 packet, containing a UDP PDU with DHCP payload...}} {{APHD|999|bits1=32|field1=Frame Check Sequence|short1=FCS}} {{APHD|end}} {{APHD|start|header=yew|title=IPv4 Header}} {{APHD|0|bits1=64|field1=IPv4 header start}} {{APHD|8|bits1=8|bits2=8|bits3=16|field1=TTL|field2=Protocol ({{Mono|17}} UDP)|field3=Header Checksum}} {{APHD|end}} {{APHD|start|header=no|title=UDP Header}} {{APHD|12|bits1=32|field1=Source Address ({{IPaddr|192.168.1.1}})}} {{APHD|16|bits1=32|field1=Destination Address ({{IPaddr|192.168.1.100}})}} {{APHD|20|bits1=16|bits2=16|field1=Source Port (67)|field2=Destination Port (68)}} {{APHD|24|bits1=16|bits2=16|field1=Length|field2=Checksum}} {{APHD|end}} {{APHD|start|header=no|title=DHCP Payload: DHCPACK}} {{APHD|28|bits1=8|bits2=8|bits3=8|bits4=8|field1=OP ({{Mono|0x02}})|hint1=BOOTREPLY|field2=HTYPE ({{Mono|0x01}})|field3=HLEN ({{Mono|0x06}})|field4=HOPS ({{Mono|0x00}})}} {{APHD|32|bits1=32|field1=XID ({{Mono|0x3903F326}})}} {{APHD|36|bits1=16|bits2=16|field1=SECS ({{Mono|0x0000}})|field2=FLAGS ({{Mono|0x0000}})}} {{APHD|40|bits1=32|field1=CIADDR (Client IP address: {{Mono|0x00000000}})}} {{APHD|44|bits1=32|field1=YIADDR (Your IP address: {{Mono|0xC0A80164}} or {{IPaddr|192.168.1.100}})}} {{APHD|48|bits1=32|field1=SIADDR (Server IP address: {{Mono|0xC0A80101}} or {{IPaddr|192.168.1.1}})}} {{APHD|52|bits1=32|field1=GIADDR (Gateway IP address: {{Mono|0x00000000}})}} {{APHD|56|bits1=128|field1=CHADDR (Client Hardware address: {{Mono|0x00053C04<br>0x8D590000<br>0x00000000<br>0x00000000}})}} {{APHD|72|bits1=1536|field1=192 octets of 0s, or overflow space for additional options; BOOTP legacy.}} {{APHD|264|bits1=32|field1=[[Magic Cookie]] ({{Mono|0x63825363}})}} {{APHD|end}} {{APHD|start|header=no|title=DHCP Options (in [[Type-length-value|TLV]] format)}} {{APHD|268|bits1=24|background1=linen|field1=First option: {{Mono|0x350105}}: Option 53 (DHCP Message Type) 1 octet (containing DHCPACK)|bits2=8|background2=linen|border2=right|field2=Second option:}} {{APHD|272|bits1=32|background1=linen|border1=left|field1={{Mono|0x0104ffffff00}}: Option 1 (Subnet mask) 4 octets (containing {{IPaddr|255.255.255.0}})}} {{APHD|276|bits1=32|background1=linen|field1=Third option: {{Mono|0x0304c0A80101}}: Option: 3 (Router) 4 octets (containing {{IPaddr|192.168.1.1}})|border1=right}} {{APHD|280|bits1=8|bits2=24|background1=linen|border1=left|field1=Router cont...||background2=linen|border2=right|field2=Fourth option: {{Mono|0x330400015080}}: Option 51 (Address time) 4 octets (a 86400 second lease time)}} {{APHD|284|bits1=16|background1=linen|border1=left|field1=Address time cont...|bits2=16|border2=bottom|field2=Fifth option:|background2=linen}} {{APHD|288|bits1=96|background1=linen|border1=top-bottom|field1={{Mono|0x060c09070a0f09070a1009070a13}}:{{Break}}Option 6 (Domain Server) 14 octets (containing {{IPaddr|9.7.10.15}},{{IPaddr|9.7.10.16}},{{IPaddr|9.7.10.18}})}} {{APHD|300|bits1=12|background1=linen|field1= |border1=top|field2=<small>{{Mono|ff}}</small>|hint2=0xff Option end mark}} {{APHD|end}} ===Selecting and configuring IP addresses=== When the server is reusing an IP address from its pool, it may first check (using [[Ping (networking utility)|ping]]) to see if it is not taken already.{{Ref RFC|2131}}{{rp|sec. 2.2}} This may happen if a host is configured manually with an IP address that lies within the DHCP scope. Before claiming an IP address, the client should probe the newly received address (e.g. with [[Address Resolution Protocol|ARP]]), in order to find if there is another host present in the network with the proposed IP address.{{Ref RFC|2131}}{{rp|sec. 2.2}} If there is no reply, this address does not conflict with that of another host, so it is free to be used. If this probe finds another computer using that address, the client should broadcast a DHCPDECLINE to the DHCP server(s). ===Information=== A DHCP client may request more information than the server sent with the original DHCPOFFER. The client may also request repeat data for a particular application. For example, browsers use ''DHCP Inform'' to obtain web proxy settings via [[Web Proxy Auto-Discovery Protocol|WPAD]]. ===Releasing=== The client sends a request to the DHCP server to release the DHCP information and the client deactivates its IP address. As client devices usually do not know when users may unplug them from the network, the protocol does not mandate the sending of ''DHCP Release''.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)