DHCP (Dynamic Host Configuration Protocol) is a protocol that is used to provide fast, automatic and central administration for the distribution of IP addresses within a network.
DHCP is also used to configure the subnet mask, default gateway and DNS server information on the device.
How DHCP Works
A DHCP server is used to issue unique IP addresses and automatically configure other network information. In most homes and small businesses, the router or router acts as the DHCP server. In large networks, a single computer can act as the DHCP server.
In summary, the process is as follows: a device (the client) requests an IP address from a router (the host), after which the host assigns an available IP address to allow the client to communicate on the network. A little more detail below …
Once a device is turned on and connected to a network that has a DHCP server, it will send a request to the server, called DHCPDISCOVER request.
Once the DISCOVER packet arrives at the DHCP server, the server tries to maintain an IP address that the device can use, and then offers the client the address with a DHCPOFFER packet.
Once the offer for the chosen IP address has been made, the device responds to the DHCP server with a DHCPREQUEST packet to accept it, after which the server sends an ACK that is used to confirm that the device has that specific IP address and to define the amount of time the device can use the address before obtaining a new one.
If the server decides that the device cannot have the IP address, it will send a NACK.
All this, of course, happens very quickly and you don’t need to know any of the technical details you just read to get an IP address from a DHCP server.
PROS And CONS Of Using DHCP
A computer, or any other device that connects to a network (local or internet), must be properly configured to communicate on that network. Since DHCP allows the configuration to be done automatically, it is used on almost all devices that connect to a network, including computers, switches, smartphones, game consoles, etc.
Due to this dynamic assignment of IP addresses, there is less chance of two devices having the same IP address, which is very easy to find when using manually assigned static IP addresses.
Using DHCP also makes a network much easier to manage. From an administrative point of view, each device on the network can obtain an IP address with nothing more than its default network configuration, which is configured to obtain an address automatically. The only other alternative is to manually assign addresses to each and every device on the network.
Because these devices can obtain an IP address automatically, they can move freely from one network to another (since all are configured with DHCP) and receive an IP address automatically, which is very useful for mobile devices.
In most cases, when a device has an IP address assigned by a DHCP server, that IP address will change every time the device joins the network. If IP addresses are assigned manually, it means that the administration should not only provide a specific address to each new client, but that existing addresses that are already assigned must be manually deallocated for any other device to use that same address. This not only consumes a lot of time, but the manual configuration of each device also increases the possibility of man-made errors.
While there are many advantages to using DHCP, there are also some disadvantages. Changing and dynamic IP addresses should not be used for stationary devices that need constant access, such as printers and file servers.
While devices of this type exist primarily in office environments, it is not practical to assign them a constantly changing IP address. For example, if a network printer has an IP address that will change at some time in the future, each computer that is connected to that printer will have to update its settings regularly so that their computers understand how to communicate with the printer.
This type of configuration is extremely unnecessary and can easily be avoided by not using DHCP for those types of devices, and instead assigning them a static IP address.
The same idea comes into play if you need to have permanent remote access to a computer in your home network. If DHCP is enabled, that computer will obtain a new IP address at some time, which means that the one you registered as the one with that computer will not be accurate for a long time. If you are using remote access software that relies on access based on IP addresses, you must use a static IP address for that device.
More information about DHCP
A DHCP server defines a range, or range, of IP addresses that it uses to serve devices with an address. This set of addresses is the only way a device can obtain a valid network connection.
This is another reason why DHCP is so useful, as it allows many devices to connect to a network for a period of time without the need for a massive set of available addresses. For example, even if only the DHCP server defines 20 addresses, 30, 50 or even 200 devices (or more) can connect to the network as long as no more than 20 are using one of the available IP addresses simultaneously.
Because DHCP assigns IP addresses for a specific period of time (a grant period), using commands such as ipconfig to find the IP address of your computer will produce different results over time.
Although DHCP is used to deliver dynamic IP addresses to its customers, it does not mean that static IP addresses cannot be used at the same time. A combination of devices that obtain dynamic addresses and devices that have their manually assigned IP addresses can exist on the same network.
Even an ISP uses DHCP to assign IP addresses. This can be seen by identifying your public IP address. It is likely to change over time unless your home network has a static IP address, which is generally only the case for companies that have publicly accessible web services.
On Windows, APIPA assigns a special temporary IP address when the DHCP server cannot deliver a functional one to a device, and uses this address until it can obtain one that works.
The Dynamic Host Configuration Working Group of the Internet Engineering Working Group created DHCP.