DHCP
...way, MTU, DNS server, WINS server, etc), providing for greater flexibility than BOOTP. • DHCP allows a computer to obtain an IP address quickly and dynamically. • DHCP like BOOTP runs over UDP, utilizing ports 67 and 68. How Does DHCP Work? DHCP allows clients to obtain IP network configuration, including an IP address, from a central DHCP server. DHCP servers control whether the addresses they provide to clients are allocated permanently or leased for a specific period of time. When the server allocates a leased address, the client must periodically check with the server to revalidate the address and renew the lease. The DHCP client and server programs handle address allocation, leasing, and lease renewal. All of these processes are transparent to end users. DHCP provides configuration parameters to hosts in a TCP/IP network. It consists of two components: • A protocol for delivering host specific configuration parameters from a server to a host • A mechanism for allocation of network addresses to hosts. Configuration parameters can be mandatory: IP address, subnet mask, MTU, default TTL, Router Discovery, Link-Layer parameters (Ethernet encapsulation, ARP cache timeout, etc), and some are optional: DNS Server, DNS suffix search list, WINS servers, WINS proxy, etc; DHCP is built on a client-server model: the DHCP server allocates network addresses and deliver configuration parameters to dynamically configured hosts. DHCP supports three mechanisms for IP address allocation: 1. “automatic allocation” – DHCP server assigns a permanent IP address to a client 2. “dynamic allocation” – DHCP server assigns an IP address to a client for a limited period of time (or until client releases the address) 3. “manual allocation” – client’s IP address is assigned by the network administrator, and DHCP is used to convey the assigned IP address to the client. Dynamic allocation is the only mechanism that allows for automatic reuse of an address that is no longer needed or is no longer in use. It is useful for hosts connected to the network temporarily, or when the IP address pool is limited. It also can be beneficial for assigning an IP address to a new client being permanently connected to a network where IP addresses are sufficiently scarce that it is important to reclaim them when old clients are retired. Manual allocation allows DHCP to be used to eliminate the error-prone process of manually configuring hosts with IP address when it is desirable to manage IP address assignment outside of DHCP mechanisms. Services provided by DHCP - Configuration parameters repository First service provided by DHCP is to provide persistent storage of network parameters for network clients. DHCP stores a key-value entry for each client, where key is some unique identifier for example IP subnet number and unique identifier in that subnet – hardware address, and the value contains configuration parameters for the client. A client can query the DHCP service and retrieve its configuration parameters. Second service provided by DHCP is the allocation of temporary or permanent network (IP) addresses. A client requests the use of an address for some period. The allocation mechanism guarantees not to reallocate that address within the requested time and attempts to return the same network address each time the same client requests an IP address. The period over which a network address is allocated is referred as a “lease”; client can request to extend its lease with subsequent requests or clients can release the IP when they no longer need it. Client needing a permanent address may ask for an infinite lease. Address allocation (first time) In the Client-server interaction – allocating a network address, the following has to happen: 1. Client broadcasts a DHCPDISCOVER message on its local physical subnet to locate available servers. BOOTP relay agents may pass the message on to DHCP servers not on the same subnet. 2. Each server may respond with DHCPOFFER message that includes an available network address in the “yiaddr” field. Server need not reserve the offered IP address at this stage. Also, server should check if address is not used. Client receives one or more DHCPOFFER messages from one or more servers. 3. Client broadcasts a DHCPREQUEST that must include the “server identification” option to indicate which server has been selected. DHCPREQUEST is broadcast and relayed through DHCP/BOOTP agents. Servers receive DHCPREQUEST broadcast from client. Non selected servers use the message as notification that client has declined their offer. 4. The selected server commits the binding for the client to persistent storage and responds with DHCPACK message containing configuration parameters for the client. 5. If the selected server is unable to satisfy the DHCPREQUEST should respond with DHCPNACK message. 6. Client should check on the parameters and notes the lease duration specified. If client detects that the IP address is already in use, than it must send a DHCPDECLINE message over to the server. After that it restarts the configuration process. It must wait a minimum period of 10 seconds before restarting configuration process to avoid excessive network traffic in case of looping. If client receives DHCPACK message, the client restarts the configuration process. The client times out and retransmits if it doesn’t receive a DHCPACK. The client retransmits the DHCPREQUEST according to retransmission algorithm. It should choose to transmit enough times to give adequate probability of contacting the server without causing the client to wait for long before giving up. 7. Client might choose to release its address by sending a DHCRELEASE to the server. This figure shows address allocation (first time) Address Allocation (reuse) Client-server interaction– allocating a network address (reusing a previously allocated address). If client remembers and wished to reuse a previously allocated IP address, a client must omit some of the steps described above. 1. Client broadcasts a DHCPREQUEST message on its local subnet, including the client’s network address. BOOTP relay agents pass the message to DHCP servers not on the same subnet. 2. Servers with knowledge of the client’s configuration parameters respond with DHCPACK to the client. Server should not check that the client’s network address is already in use. If client’s address is invalid (client has moved to a different subnet), server should respond with DHCPNACK message to the client. 3. Client received DHCPACK message with configuration parameters, then performs final check on the parameters and noted the lease duration. If client detects that the IP address is already in use than it sends a DHCPDECLINE message to the server, and it restarts the configuration process. If client receives a DHCPNACK it cannot use reuse its IP address and must request a new address by restarting the configuration process. The client times out and retransmits if it doesn’t receive a DHCPACK or DHCACK. The client retransmits the DHCPREQUEST according to retransmission algorithm. It should choose to transmit enough times to give adequate probability of contacting the server without causing the client to wait for long before giving up. 4. Client might choose to release its address by sending a DHCRELEASE to the server. DHCP client-server protocol DHCP uses UDP as its transport protocol. DHCP messages from client to a server are sent to the DHCP server on port 67, and DHCP server messages from a server are sent to a DHCP client port 68. DHCP clients are res...