Sie sind auf Seite 1von 7

How DHCP Works

Contributed by: Vijayalakshmi Mariyappan

Introduction
Every host on a TCP/IP network must have a unique IP address. Each host must be properly configured so it knows its IP address. When a new host comes online, it must be assigned an IP address within the correct range of addresses for the subnet one thats not already in use. Although you can manually assign IP addresses to each computer on your network, that task quickly becomes overwhelming if the network has more than a few computers.

What Is DHCP
The DHCP, Dynamic Host Configuration Protocol, comes into play. DHCP automatically configures the IP address for every host on a network, thus assuring that each host has a valid unique IP address. DHCP even automatically reconfigures IP addresses as hosts come and go. As you can imagine, DHCP can save a network administrator many hours of tedious configuration work.

How DHCP works

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.

Page 1 of 7

How DHCP Works

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 Client uses port 67 as its own port for communicating DHCP Server.

DHCP Server uses port 68 as its own port for communicating DHCP Client.

DHCP Client and DHCP Server use UDP (User Datagram Protocol) to send and receive messages between each other.

The following figure shows an overview of this process when the DHCP server and DHCP client are on the same subnet

Page 2 of 7

How DHCP Works

Figure: 1 Communications between DHCP Client and DHCP Server

As shown in above figure, this process requires only four steps as follows:

1) The DHCP client asks for an IP address (a DHCP Discover message).

2) The DHCP Server offers an address (a DHCP Offer message).

3) The DHCP client accepts the offer and requests the address (a DHCP Request message).

4) The DHCP Server officially assigns the address to the client (a DHCP Acknowledge message).

Page 3 of 7

How DHCP Works

Figure: 2 DHCP Client Receives IP Address

Server, Clients, and Relay Agents


1 Three basic components make up DHCP in Windows Server 2003:

1) DHCP Servers 2) DHCP Clients 3) DHCP/BOOTP Relay Agents

The DHCP server can assign the following TCP/IP configuration parameters:

1) IP addresses for each network adapter in a client computer. 2) Subnet masks to identify the IP network portion from the host portion of the IP address. 3) Default gateways (routers), which connect a single network segment to others segments. 4) Additional configuration parameters, optionally assigned to DHCP clients (such as IP addresses for DNS or WINS servers that a client might use).

Page 4 of 7

How DHCP Works


DHCP Clients

Many low-cost industry standard platforms can act as DHCP clients. The four steps required for a DHCP client to acquire a lease from a DHCP server initiate automatically when the computer starts.

DHCP Relay Agent

BOOTP and DHCP rely on network broadcasts to perform their work. Routers in normal routed environments do not automatically forward broadcasts from one interface to another. A relay agent must forward these messages. A router or a host computer configured to listen for DHCP BOOTP broadcast messages and direct them to a specific server running DHCP can act as a DHCP relay agent. Using relay agents eliminates the necessity of having a server running DHCP on each physical network segment. Relay agents direct local DHCP client requests to remote DHCP servers and also return remote DHCP server responses to the DHCP clients.

Windows Server 2003 includes a DHCP relay agent routing protocol component with the Routing and Remote Access service. A DHCP relay agent service also comes with Windows Server 2003.

When the client receives acknowledgment, it configures its TCP/IP properties by using the DHCP option information in the reply, and completes its initialization of TCP/IP.

Page 5 of 7

How DHCP Works


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.

Figure: 3 DHCP Relay Agent

Page 6 of 7

How DHCP Works


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 clients 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 clients 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 fulfil 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.

Page 7 of 7