- DHCP is Dynamic Host Configuration Protocol for assigning IP addresses to devices on a network, a device can have different IP address every time it connects to the network.
- The DHCP has been devised to provide static and dynamic address allocation.
- To provide dynamic address allocation, the DHCP client acts as a state machine that performs transitions from one state to another depending on the messages it receives or sends. Figure shows the transition diagram with main states.
INIT State: When the DHCP client first starts, it is in the INIT state (initializing state). The client broadcasts a DHCPDISCOVER message (a request message with the DHCPDISCOVER option), using port 67.
SELECTING State: After sending the DHCPDISCOVER message, the client goes to the selecting state. Those servers that can provide this type of service respond with a DHCPOFFER message. In these messages, the servers offer an IP address. They can also offer the lease duration. The default is 1 hour. The server that sends a DHCPOFFER locks the offered IP address so that it is not available to any other clients. The client chooses one of the offers and sends a DHCPREQUEST message to the selected server. It then goes to the requesting state. However, if the client receives no DHCPOFFER message, it tries four more times, each with a span of 2 seconds. If there is no reply to any of these DHCPDISCOVERs, the client sleeps for 5 minutes before trying again.
REQUESTING State: The client remains in the requesting state until it receives a DHCPACK message from the server that creates the binding between the client physical address and its IP address. After receipt of the DHCPACK, the client goes to the bound state.
BOUND State: In this state, the client can use the IP address until the lease expires. When 50 percent of the lease period is reached, the client sends another DHCPREQUEST to ask for renewal. It then goes to the renewing state. When in the bound state, the client can also cancel the lease and go to the initializing state.
RENEWING State: The client remains in the renewing state until one of two events happens. It can receive a DHCPACK, which renews the lease agreement. In this case, the client resets its timer and goes back to the bound state. Or, if a DHCPACK is not received, and 87.5 percent of the lease time expires, the client goes to the rebinding state.
REBINDING State: The client remains in the rebinding state until one of three events happens. If the client receives a DHCPNACK or the lease expires, it goes back to the initializing state and tries to get another IP address. If the client receives a DHCPACK, it goes to the bound state and resets the timer.
DHCP is dynamic host configuration protocol for assigning IP addresses to devices on a network, a device can have different IP address every time it connects to the network.
DHCP assign IP address to the device in three way
1) Static allocation
2) Dynamic allocation
3) Lease time allocation
Static allocation: This method entails using DHCP to identify the unique hardware addresses of each network card connected to the network and then continually supplying a constant configuration each time the DHCP client makes a request to the DHCP server using that network device this ensures that a particular address is assigned automatically to that network card based on its MAC address.
Using this method DHCP automatically assign an IP address permanently to a device selecting it from a pool of available addresses usually DHCP is used to assign temporary addresses to client but DHCP server can allow an infinite lease time.
Lease Time Allocation:
In this method DHCP server will assign an IP address from a pool of address for a period of time or lease that is configured on the server or until the client informs the server that it doesn’t need the address anymore, the clients will be receiving their configuration properties dynamically and on first come first serve basis.