In the dawn of the Internet revolution, the most common way to get connected was to use a dial-up connection. With dial-up connections, each time you logged in, you initiated a new session, and you were assigned with a new IP address from your Internet Service Provider (ISP). And as you can imagine, if this had to be done by hand, it would have been a very slow process. This is why the DHCP was created.
What is DHCP?
The Domain Name System, more popular as DNS, and the Dynamic Host Configuration Protocol, also known as DHCP, represent two crucial TCP/IP areas of a Windows NT Server network. The DNS is responsible for converting hostnames into IP addresses, while the DHCP is engaged in assigning unique dynamic IP addresses and the corresponding subnet masks and default gateways to TCP/IP running computers within a particular server network.
Why would you need to use the DHCP? Thanks to the dynamic addressing executed by the DHCP, a computer can have a different IP address every time it connects to the network it belongs to, without the intervention of a UNIX administrator. Through this DHCP functionality every new computer added to a network is automatically assigned a unique IP address.
DHCP servers greatly simplify the configuration of networks and are built in the majority of the wireless access points and wired Ethernet routers.
How does the DHCP work?
In a network, a DHCP server manages a pool of IP addresses, as well as default gateway details, DNS details and other information for the clients’ network configuration. When a new computer is introduced into a DHCP server-enabled network, it will send a query to the DHCP server requesting all the necessary information. When the query reaches the DHCP server, it will grant the new computer a new IP address and a lease - a time frame for which the computer can use this IP address, as well as other configuration details. The whole process takes place immediately after the new computer boots, and to be successful, it has to be completed before initiating IP based communication with other hosts in the network.
DHCP allocation methods
Depending on its configuration, the DHCP server can work in 3 ways:
When the DHCP server is configured to use dynamic allocation, this means that it uses a lease policy. This way, when an assigned IP address from the available pool is no longer used, it will be transferred back to the pool, making it available for someone else to use. The advantage of this method is that the IP addresses are used to their maximum - as soon as they are no longer used by the client, they are instantly made available to others. The disadvantage of this method is that a client will always have a random IP address.
The automatic allocation method resembles very much the dynamic allocation method - as soon as a client connects, the DHCP server provides him with an IP address from the IP address pool. However, when automatic allocation is used, the DHCP server keeps a database of previous IP grants, and tries to give the client the same IP address he used the last time, if available.
The static allocation method is very popular in modern ISP networks, which do not use dial-up methods. With the static allocation, the DHCP sever keeps a database with all clients' LAN MAC addresses and gives them an IP address only if their MAC address is in the database. This way, the clients can be sure that they will be getting the same IP address every time.
A DHCP server can be set to work using a combination of the allocation methods. For example, in a public WiFi network, all of the known hosts and permanent clients can use the static allocation, whereas for guests, the dynamic allocation is used. This way, known hosts can always use the same IP address and the IP address pool is equally available to everyone.