How DHCP Technology Works
How DHCP Works
DHCP provides an automated way to distribute and update IP addresses and other configuration information on a network. A DHCP server provides this information to a DHCP client through the exchange of a series of messages, known as the DHCP conversation or the DHCP transaction. If the DHCP server and DHCP clients are located on different subnets, a DHCP relay agent is used to facilitate the conversation.
Note
Note
- It is necessary to have an understanding of basic TCP/IP concepts, including working knowledge of subnets before you can have a full understanding of DHCP. For more information about TCP/IP, see “TCP/IP Technical Reference.”
DHCP Architecture
The DHCP architecture consists of DHCP clients, DHCP servers, and DHCP relay agents on a network. The clients interact with servers using DHCP messages in a DHCP conversation to obtain and renew IP address leases.DHCP Client Functionality
A DHCP client is any network-enabled device that supports the ability to communicate with a DHCP server in compliance with RFC 2131, for the purpose of obtaining dynamic leased IP configuration and related optional information.
DHCP provides support for client computers running any of the following Microsoft operating systems:
DHCP provides support for client computers running any of the following Microsoft operating systems:
- Windows NT version 4.0
- Windows 2000
- Windows XP
- Windows Server 2003
- Windows 98
- Windows Millennium Edition
Automatic IP Configuration
DHCP supports Automatic Private IP Addressing (APIPA), which enables computers running Windows 2000, Windows XP, and Windows Server 2003 to configure an IP address and subnet mask if a DHCP server is unavailable at system startup and the Automatic private IP address Alternate Configuration setting is selected. This feature is useful for clients on small private networks, such as a small-business office or a home office.
The DHCP Client service on a computer running Windows XP and Windows Server 2003 uses the following process to auto-configure the client:
The DHCP Client service on a computer running Windows XP and Windows Server 2003 uses the following process to auto-configure the client:
- The DHCP client attempts to locate a DHCP server and obtain an IP address and configuration.
- If a DHCP server cannot be found or does not respond after one minute, the DHCP client checks the settings on the Alternate Configuration tab of the properties of the TCP/IP protocol.
If Automatic private IP address is selected, the DHCP client auto-configures its IP address and subnet mask by using a selected address from the Microsoft-reserved Class B network, 169.254.0.0, with the subnet mask 255.255.0.0. The DHCP client tests for an address conflict to ensure that the IP address is not in use on the network. If a conflict is found, the client selects another IP address. The client retries auto-configuration up to 10 times.
If User Configured is selected, the DHCP client configures a static IP address configuration. The DHCP client tests for an address conflict to ensure that the IP address is not already in use on the network. If a conflict is found, the DHCP client indicates the error condition to the user.
- When the DHCP client succeeds in self-selecting an address, it configures its network interface with the IP address. The client then continues to check for a DHCP server in the background every five minutes. If a DHCP server responds, the DHCP client abandons its self-selected IP address and uses the address offered by the DHCP server (and any other DHCP option information that the server provides) to update its IP configuration settings.
- If the ping is successful, the DHCP client assumes that it is still located on the same network where it obtained its current lease, and continues to use the lease as long as the lease is still valid. By default the client then attempts, in the background, to renew its lease when 50 percent of its assigned lease time has expired.
- If the ping fails, the DHCP client assumes that it has been moved to a network where a DHCP server is not available. The client then auto-configures its IP address by using the settings on the Alternate Configuration tab. When the client is auto-configured, it attempts to locate a DHCP server and obtain a lease every five minutes.
Local Storage
Windows Server 2003 DHCP supports local storage, which allows clients to store DHCP information on their own hard disks. Local storage is useful because it enables the client to store its last leased IP address, so that when the client starts it first attempts to renew the lease of its previous IP address. Local storage also enables a client to be shut down and restarted and it will use its previously leased address and configuration, even if the DHCP server is unreachable or offline at the time that the client computer is restarted.
DHCP Server Responsibilities
The DHCP servers maintain scopes, reservations, and options as set by the administrator.
Scopes
A scope must be properly defined and activated before DHCP clients can use the DHCP server for automatic TCP/IP configuration. A DHCP scope is an administrative collection of IP addresses and TCP/IP configuration parameters that are available for lease to DHCP clients of a specific subnet. The network administrator creates a scope for each subnet.
A scope has the following properties:
A scope has the following properties:
- A scope name, assigned when the scope is created.
- A range of possible IP addresses from which to include or exclude addresses used in DHCP lease offers.
- A unique subnet mask, which determines the network ID for an IP address in the scope.
- Lease duration values.
Lease Durations
When a scope is created, the lease duration is set to eight days by default. However there are situations when the administrator might want to change the lease duration. The following are examples of adjusting the lease duration due to individual network consideration:
Note
- An organization has a large number of IP addresses available and configurations that rarely change. The administrator increases the lease duration to reduce the frequency of lease renewal exchanges between clients and the DHCP server. Because the DHCP clients are renewing their leases less frequently, DHCP-related network traffic is reduced.
- A limited number of IP addresses are available and client configurations change frequently or clients move often in or out of the network. The administrator reduces the lease duration. This increases the rate at which unused addresses are returned to the available address pool for reassignment.
Note
- Although it is possible to configure a client with infinite lease duration, use infinite lease durations with caution. Even relatively stable environments have a certain amount of client turnover. At a minimum, computers might be added and removed, moved from one office to another, or network adapters might be replaced. If a client with an infinite lease is removed from the network without releasing its lease, the DHCP server is not notified, and the IP address is not automatically reused. Also, when using an infinite lease, options set on the DHCP server are not automatically updated on the DHCP client, because the client is never required to renew its lease and obtain the new options. It is recommended that reservations be used rather than infinite lease durations.
Exclusion Ranges
When you create a new scope, immediately exclude the addresses of existing statically configured computers from the scope. By using exclusion ranges, you can exclude specific IP address ranges within a scope so that those addresses are not offered to clients. Assign IP addresses within exclusion ranges to computers or devices that must have a static IP address, such as servers, firewalls, or routers.
You can use excluded IP addresses on your network by manually configuring these addresses at computers that do not use DHCP to obtain an address, or by configuring reservations for these addresses.
You can use excluded IP addresses on your network by manually configuring these addresses at computers that do not use DHCP to obtain an address, or by configuring reservations for these addresses.
Reservations
You can reserve IP addresses for assignment to specified computers or devices on the network. Reservations ensure that a specified hardware device on a subnet always receives the same IP address lease. Use reservations for DHCP-enabled devices that must always have the same IP address on your network, such as servers that do not support Domain Name System (DNS) dynamic update.
Note
Note
- If multiple DHCP servers are each configured with scopes that cover addresses that must be reserved, the reservations must be specified on each DHCP server. Otherwise, the client might receive an IP address from one of the DHCP servers that does not contain the reservation, and therefore might not receive the IP address reserved for the client.
Superscopes
A superscope allows a DHCP server to provide leases from more than one scope to clients on a single physical subnet. Before you can create a superscope, you must use the DHCP Microsoft Management Console (MMC) snap-in to define at least one of the scopes to be included in the superscope. Scopes added to a superscope are called member scopes. Superscopes can resolve DHCP Server service issues in several different ways; these issues include situations in which:
- Support is needed for DHCP clients on a single physical network segment — such as a single Ethernet LAN segment — where multiple logical IP networks are used. When more than one logical IP network is used on a physical network, these configurations are also known as multinets. In a situation where multinets are used, clients might not be able to communicate directly with each other, because the clients might be on different logical subnets, even if they are on the same physical network segment. In this case, routing must be enabled to allow the clients to communicate with each other. Also, a router or BOOTP/DHCP relay agent must be configured on the subnet to allow DHCP messages to travel between the logical subnets.
- Support is needed for DHCP clients that are in a multinet located on the other side of BOOTP relay agents.
- Clients need to be migrated to a new scope.
Interactions between Client and Server
DHCP servers and DHCP clients communicate through a series of DHCP messages. To obtain a lease, the DHCP client initiates a conversation with a DHCP server using a series of these DHCP messages.
DHCP Messages
The following list includes the eight types of messages that can be sent between DHCP clients and servers. For more information about the structure and specifics of each of these packets, see “DHCP Message Format” later in this section.
DHCPDiscover
Broadcast by a DHCP client when it first attempts to connect to the network. The DHCPDiscover message requests IP address information from a DHCP server.
DHCPOffer
Broadcast by each DHCP server that receives the client DHCPDiscover message and has an IP address configuration to offer to the client. The DHCPOffer message contains an unleased IP address and additional TCP/IP configuration information, such as the subnet mask and default gateway. More than one DHCP server can respond with a DHCPOffer message. The client accepts the best offer, which for a Windows DHCP client is the first DHCPOffer message that it receives.
DHCPRequest
Broadcast by a DHCP client after it selects a DHCPOffer. The DHCPRequest message contains the IP address from the DHCPOffer that it selected. If the client is renewing or rebinding to a previous lease, this packet might be unicast directly to the server.
DHCPAck
Broadcast by a DHCP server to a DHCP client acknowledging the DHCPRequest message. At this time, the server also forwards any options. Upon receipt of the DHCPAck, the client can use the leased IP address to participate in the TCP/IP network and complete its system startup. This message is typically broadcast, because the DHCP client does not officially have an IP address that it can use at this point. If the DHCPAck is in response to a DHCPInform, then the message is unicast directly to the host that sent the DHCPInform message.
DHCPNack
Broadcast by a DHCP server to a DHCP client denying the client’s DHCPRequest message. This might occur if the requested address is incorrect because the client moved to a new subnet or because the DHCP client’s lease has expired and cannot be renewed.
DHCPDecline
Broadcast by a DHCP client to a DHCP server, informing the server that the offered IP address is declined because it appears to be in use by another computer.
DHCPRelease
Sent by a DHCP client to a DHCP server, relinquishing an IP address and canceling the remaining lease. This is unicast to the server that provided the lease.
DHCPInform
Sent from a DHCP client to a DHCP server, asking only for additional local configuration parameters; the client already has a configured IP address. This message type is also used by DHCP servers running Windows Server 2003 to detect unauthorized DHCP servers.
DHCP Lease Process
A DHCP-enabled client obtains a lease for an IP address from a DHCP server. Before the lease expires, the DHCP client must renew the lease or obtain a new lease. Leases are retained in the DHCP server database for a period of time after expiration. By default, this grace period is four hours and cleanup occurs once an hour for a DHCP server running Windows Server 2003. This protects a clients lease in case the client and server are in different time zones, the internal clocks of the client and server computers are not synchronized, or the client is off the network when the lease expires.
Obtaining a New Lease
A DHCP client initiates a conversation with a DHCP server when it is seeking a new lease, renewing a lease, rebinding, or restarting. The DHCP conversation consists of a series of DHCP messages passed between the DHCP client and DHCP servers. The following figure shows an overview of this process when the DHCP server and DHCP client are on the same subnet.
DHCP Lease Process Overview
In rare cases, a DHCP server might return a negative acknowledgment to the client. This can happen if a client requests an invalid or duplicate address. If a client receives a negative acknowledgment (DHCPNack), the client must begin the entire lease process again.
When the DHCP client and the DHCP server are on the same IP broadcast subnet, the DHCPDiscover, DHCPOffer, DHCPRequest, and DHCPAck messages are sent to identify clients by means of IP-level broadcasts sent to the limited broadcast address and the media access control (MAC) broadcast address.
When the DHCP server and DHCP client are not on the same subnet either a router or a host on the DHCP client’s subnet must act as a DHCP relay agent to support the forwarding of DHCP messages between the DHCP client and the DHCP server.
DHCP Lease Process Overview
- The DHCP client requests an IP address by broadcasting a DHCPDiscover message to the local subnet.
- The client is offered an address when a DHCP server responds with a DHCPOffer message containing an IP address and configuration information for lease to the client. If no DHCP server responds to the client request, the client sends DHCPDiscover messages at intervals of 0, 4, 8, 16, and 32 seconds, plus a random interval of between -1 second and 1 second. If there is no response from a DHCP server after one minute, the client can proceed in one of two ways:
- If the client is using the Automatic Private IP Addressing (APIPA) alternate configuration, the client self-configures an IP address for its interface.
- If the client does not support alternate configuration, such as APIPA, or if IP auto-configuration has been disabled, the client network initialization fails.
- If the client is using the Automatic Private IP Addressing (APIPA) alternate configuration, the client self-configures an IP address for its interface.
- The client indicates acceptance of the offer by selecting the offered address and broadcasting a DHCPRequest message in response.
- The client is assigned the address and the DHCP server broadcasts a DHCPAck message in response, finalizing the terms of the lease.
In rare cases, a DHCP server might return a negative acknowledgment to the client. This can happen if a client requests an invalid or duplicate address. If a client receives a negative acknowledgment (DHCPNack), the client must begin the entire lease process again.
When the DHCP client and the DHCP server are on the same IP broadcast subnet, the DHCPDiscover, DHCPOffer, DHCPRequest, and DHCPAck messages are sent to identify clients by means of IP-level broadcasts sent to the limited broadcast address and the media access control (MAC) broadcast address.
When the DHCP server and DHCP client are not on the same subnet either a router or a host on the DHCP client’s subnet must act as a DHCP relay agent to support the forwarding of DHCP messages between the DHCP client and the DHCP server.
Renewing a Lease
The DHCP client first attempts to renew its lease when 50 percent of the original lease time, known as T1, has passed. At this point the DHCP client sends a unicast DHCPRequest message to the DHCP server that originally granted its lease. If the server is available, and the lease is still available, the server responds with a unicast DHCPAck message and the lease is renewed.
If the original DHCP server is available, but the client’s current lease is no longer available, the DHCP server responds with a DHCPNack message, and the client immediately starts the process to obtain a new lease. This can happen if the client has changed subnets or if the DHCP server cannot fulfill the lease request for some other reason.
If there is no response from the DHCP server, the client waits until 87.5 percent of the lease time has passed (known as T2). At T2, the client enters the rebinding state, and broadcasts a DHCPRequest message to attempt to renew the lease from any available DHCP server. If no DHCP server is available by the time the lease expires, the client immediately unbinds itself from the existing lease and starts the process to obtain a new lease, beginning with a DHCPDiscover message.
If the original DHCP server is available, but the client’s current lease is no longer available, the DHCP server responds with a DHCPNack message, and the client immediately starts the process to obtain a new lease. This can happen if the client has changed subnets or if the DHCP server cannot fulfill the lease request for some other reason.
If there is no response from the DHCP server, the client waits until 87.5 percent of the lease time has passed (known as T2). At T2, the client enters the rebinding state, and broadcasts a DHCPRequest message to attempt to renew the lease from any available DHCP server. If no DHCP server is available by the time the lease expires, the client immediately unbinds itself from the existing lease and starts the process to obtain a new lease, beginning with a DHCPDiscover message.
Preventing Address Conflicts
Windows Server 2003 DHCP has both server-side and client-side conflict detection to prevent duplicate IP addresses on your network.
Client Conflict Detection
Client computers running Windows Server 2003, Windows XP, Windows 2000, Windows NT 4.0, Windows Millennium Edition, and Windows 98 automatically check to determine if an IP address is already in use before using it.
After the DHCP client receives a lease from the DHCP server, the client sends an Address Resolution Protocol (ARP) request to the address that it has been assigned. If a reply to the ARP request is received, the client has detected a conflict and sends a DHCPDecline message to the DHCP server. The DHCP server attaches a BAD_ADDRESS value to the IP address in the scope for the length of the lease. The client then begins the lease process again, and is offered the next available address in the scope.
Note
After the DHCP client receives a lease from the DHCP server, the client sends an Address Resolution Protocol (ARP) request to the address that it has been assigned. If a reply to the ARP request is received, the client has detected a conflict and sends a DHCPDecline message to the DHCP server. The DHCP server attaches a BAD_ADDRESS value to the IP address in the scope for the length of the lease. The client then begins the lease process again, and is offered the next available address in the scope.
Note
- ARP requests do not traverse routers. Clients use ARP requests rather than pings (ICMP Echo messages) because pings require the sender to have an IP address.
Server Conflict Detection
If your network includes older DHCP clients that do not perform conflict detection themselves, you can enable conflict detection on the DHCP server. By default, the Windows Server 2003 DHCP Server service does not perform any conflict detection.
To detect conflicts, the DHCP server pings (sends an ICMP Echo message to) an IP address before offering that address to clients in a new lease. The DHCP server only pings addresses that have not been successfully and previously leased. If a client requests a lease on an IP address that it already had or is requesting a renewal, the DHCP server does not ping the IP address.
If conflict detection is enabled, an administrator-defined number of pings are sent. The server waits 1 second for a reply. Because the time required for a client to obtain a lease is equal to the number of pings used, choose this value carefully because it directly impacts the overall performance of the server. In general, one ping is sufficient.
If a response to the ping is received, a conflict is registered and that address is not offered to clients requesting a lease from the server. The DHCP server then attaches a BAD_ADDRESS value to that IP address in the scope. The DHCP server then tries to lease the next available address. If the duplicate address is removed from the network, the BAD_ADDRESS value attached to the IP address can be deleted from the scope’s list of active leases, and then the address returns to the pool. Addresses are marked as BAD_ADDRESS for the length of the lease for which the scope is configured. If the BAD_ADDRESS entry is not manually removed, it will automatically be removed after a period of time equal to the lease time for the scope.
Note
To detect conflicts, the DHCP server pings (sends an ICMP Echo message to) an IP address before offering that address to clients in a new lease. The DHCP server only pings addresses that have not been successfully and previously leased. If a client requests a lease on an IP address that it already had or is requesting a renewal, the DHCP server does not ping the IP address.
If conflict detection is enabled, an administrator-defined number of pings are sent. The server waits 1 second for a reply. Because the time required for a client to obtain a lease is equal to the number of pings used, choose this value carefully because it directly impacts the overall performance of the server. In general, one ping is sufficient.
If a response to the ping is received, a conflict is registered and that address is not offered to clients requesting a lease from the server. The DHCP server then attaches a BAD_ADDRESS value to that IP address in the scope. The DHCP server then tries to lease the next available address. If the duplicate address is removed from the network, the BAD_ADDRESS value attached to the IP address can be deleted from the scope’s list of active leases, and then the address returns to the pool. Addresses are marked as BAD_ADDRESS for the length of the lease for which the scope is configured. If the BAD_ADDRESS entry is not manually removed, it will automatically be removed after a period of time equal to the lease time for the scope.
Note
- In general, use server conflict detection only as a troubleshooting aid when you suspect that duplicate IP addresses are in use on your network. Each additional conflict detection attempt adds to the time needed to negotiate leases for DHCP clients.
DHCP Options
DHCP options are additional configuration parameters that a DHCP server assigns to clients. Options can also be used for DHCP communication between the server computer and client computers.The most specific options take precedence over the least specific options. This simplifies DHCP management and allows a flexible administration that can range from per-server default settings to common settings for a specific subnet and individualized client settings when needed for special circumstances. In most cases, the option values are specified in the Options dialog box on the DHCP server, scope, or reservation.
DHCP options can be configured for specific values and enabled for assignment and distribution to DHCP clients based on:
- Server options. These options apply globally for all scopes and classes defined at each DHCP server and any clients that it services. Configured server option values always apply unless they are overridden by options assigned to other scope, class, or client reservation.
- Scope options. These options apply to any clients that obtain a lease within that particular scope. Configured scope option values always apply to all computers obtaining a lease in a given scope unless they are overridden by options assigned to class or client reservation.
- Class options. These options apply to any clients that specify that particular DHCP Class ID value when obtaining a scope lease. Configured class option values always apply to all computers configured as members in a specified DHCP option class unless they are overridden by options assigned to a client reservation.
- Reserved client options. These options apply only to the client corresponding to the reservation. Reserved client option values override all other server, scope, or class assigned option values.
For special requirements, such as clients with special functions, assign options for specific reserved clients.
Options can also be used to separate and distribute appropriate options for clients with similar or special configuration needs. For example, DHCP clients on the same floor of a building can be configured with the same DHCP Class ID value to assign them membership in the same option class. You can then distribute additional or varied option data to that class during the lease process, overriding any scope or globally provided default options.
Note
Statically configured values on a client override any DHCP options of any type or level.
5 comments:
I'm impressed, І must saү. Ꮢarely dⲟ Ι encounter
ɑ blog that's bߋtһ educative and entertaining, ɑnd lеt me tell you, үoս һave hit
the nail on the head. Ꭲhe issue is ѕomething that not enough
folks arе speaking intelligently ɑbout.
I'm veгy һappy that Ι stumbled ɑcross tһis in my search fօr ѕomething rеgarding this.
Howdy! This is kind of off topic but I need some guidance from an established
blog. Is it difficult to set up your own blog? I'm not very techincal but I can figure things
out pretty fast. I'm thinking about making my own but I'm not sure where to begin. Do you have any ideas or suggestions?
With thanks
Thanks for some other excellent post. Where else could anyone get
that type of info in such a perfect way of writing?
I have a presentation subsequent week, and I'm on the look
for such information.
Good article! We are linking to this particularly great post on our website.
Keep up the great writing.
Spot on with this write-up, I honestly believe that this website needs a great deal more attention. I'll probably be back again to
see more, thanks for the advice!
Post a Comment