An IP address is the identity of a host or a computer device while connected to any network. When you connect your computer to a LAN or internet, the IP address and other information like subnet mask etc are assigned to your computer automatically.
DHCP is used to control the network configuration of a host through a remote server. It is an excellent alternative to the time-consuming manual configuration of network settings on a host or a network device.
How it works?
DHCP works on a client-server model. Being a protocol, it has it’s own set of messages that are exchanged between client and server.
- When the client computer (or device) boots up or is connected to a network, a
DHCPDISCOVERmessage is sent from the client to the server. As there is no network configuration information on the client so the message is sent with
0.0.0.0as source address and
255.255.255.255as destination address. The transport protocol used for this message is UDP and the port number used is 67. The client enters the initializing stage during this step.
- When the DHCP server receives the
DHCPDISCOVERrequest message then it replies with a
DHCPOFFERmessage. This message contains all the network configuration settings required by the client. This message is sent as a broadcast (
255.255.255.255) message for the client to receive it. UDP protocol is used at the transport layer with destination port as 68.
- The client forms a
DHCPREQUESTmessage in reply to
DHCPOFFERmessage and sends it to the server indicating it wants to accept the network configuration sent in the
DHCPREQUESTmessage will still contain the source address as
0.0.0.0as the client is still not allowed to use the IP address passed to it through
- Once the server receives
DHCPREQUESTfrom the client, it sends the
DHCPACKmessage indicating that now the client is allowed to use the IP address assigned to it.
A DHCP lease is the amount of time that the DHCP server grants to the DHCP client permission to use a particular IP address. A typical server allows its administrator to set the lease time.