Update cookies preferences

How DHCP works

In order for a computer to function freely on a network, it must be assigned an individual IP address. This is a set of 4 numbers separated by dots, similar to the way a postal address specifies the country, city, street and house. It is used to establish a connection to other devices on the network. Two versions are used: IPv4 and IPv6. IPv4 is written as above: As for IPv6, it is four times longer and looks something like this: 2002:0BA7:AC30:0001:0110:0000:0101:00DA. You may ask - what does this have to do with IP? Why do we need the DHCP network protocol?

What is DHCP

All hosts connected to the Internet use this protocol. Any computer, phone or gadget has two types of IP addresses. The internal address is seen only by devices in the local network, it is a limited group of devices or gadgets. And the external one gives access to the global network.
IP addresses are also divided into two types. Static - this is a permanent address, tied to one computer for a long time, it is rented. With technological development, it became insufficient such "numbers", so a system of dynamic IP addresses was developed. They change every time a device connects to the network. When disconnected, the address is released and given to another device that has just connected to the internet.
A static address can be set manually if you have administrator rights. A dynamic one is obtained automatically through DHCP (Dynamic Host Configuration Protocol) without requiring human intervention.

What the DHCP protocol does

A dynamic host configuration network protocol is a set of rules and sequential actions. They define how devices on the same network communicate with each other and exchange information.
DHCP functions within a client-server model. It automatically allocates IP addresses to devices so that they can communicate on the network.

Basic concepts in setting up

A client is a device that needs an IP address to connect to the network.It can be a cell phone, tablet, laptop or personal computer.
A server is a computer that allocates IP addresses to clients and controls that no two clients get the same IP.
DHCP not only ensures that IP addresses are automatically configured, but also simplifies the process of connection diagnostics and switching between different subnets. In addition, it leaves entries in log files so that system administrators are aware of what is happening.

A little history

It all started in 1993 when the DHCP protocol was originally described. It was documented in RFC 1531 and has undergone some changes since then. However, today the most important document that governs this protocol is RFC 2131.

Protocol peculiarities

  • A DHCP server maintains a pool of IPs and allocates them to clients. Instead of assigning static addresses, IP addresses are leased dynamically, and when they are no longer needed, they are automatically returned to the pool for future use.
  • The network administrator sets up DHCP servers that store TCP/IP configuration information and offer it to clients when they connect to the network.
  • The DHCP server stores a list of valid IP addresses that can be assigned to clients in the pool. Also on this list are addresses that are not available for assignment.
  • Specific IP addresses can also be reserved for specific DHCP clients.
  • The DHCP server database also specifies the IP address lease duration, that is, the amount of time a client can use that address before the lease is renewed.
When a DHCP-enabled client leases an IP address, it is provided with the IP address of the subnet associated with its connection; DHCP settings (router (default gateway), DNS server, and domain).

DHCP protocol operation - principles

The DHCP protocol is divided into client and server parts, which perform important tasks. The server part configures the network and issues IP addresses. The client part is responsible for connecting to the network by sending requests to the server for settings, IP address, gateway, mask and DNS servers.

Stages of data exchange

Data exchange can be categorized into four main stages:
  • Discovery - The client sends a request to the server. A DHCPDISCOVER message is sent to all devices on the subnet. These requests are called broadcast requests. Only the DHCP server can respond to this message.
  • Offer - The server responds to the client with a DHCPOFFER message that contains a free IP address. If multiple servers are responding at the same time, the client can select any of them. The client then communicates only with the selected server.
  • Request - The client confirms server settings by sending a DHCPREQUEST message to each DHCP server on the network with its IP address. The servers realize that this IP is already busy and do not offer it to other clients.
  • Confirmation - The server confirms the client's request that an IP address is bound to a specific device for a specific duration and sends a DHCPACK message to the client with the address, its expiration date, and other network settings.
When the client connects for the first time, it selects the first available DHCP server. But if the device has connected to this network before, when it reconnects, it will select the DHCP server it first communicated with.
If a client moves to a new subnet and needs to change its IP address, it sends a DHCPRELEASE message to the server. The DHCP server marks the selected address as free. The client network settings are also saved, allowing the device to reuse this IP address if necessary. Manually unleasing a particular address is possible by using the ipconfig/release command.
When the server and client are on different subnets, communication can be accomplished using DHCP relay. This allows requests and responses to be relayed between different networks so that clients can obtain IP addresses even in such cases.

IP address allocation methods in DHCP

There are three ways to assign IP addresses in DHCP:
  • Fixed - Manual Assignment. In this case, the administrator of the DHCP server manually sets the mapping between each device's MAC address and IP address. This method is convenient in small networks where all MAC addresses are known.
  • Automatic - allows each device to automatically obtain an IP address. It is issued indefinitely and will remain unchanged until the client relinquishes it. This method is often used in organizations where flexibility in IP address assignment is not required.
  • Dynamic - A DHCP server issues the client any available IP address from a specific range. These addresses are not associated with specific devices and are intended for situations where the number and composition of users on the network are constantly changing. A Wi-Fi café acquires a certain number of IP addresses and allocates them as needed. A DHCP server issues IP addresses to visitors who join the network.
In order for DHCP to work, both the client and server sides need to be always active.

Disadvantages of the DHCP protocol

To activate DHCP, you need to configure your device beforehand. However, modern gadgets can do it on their own.
In the case of a static IP, other network equipment must save it so that other devices can connect to it without problems. Therefore, in such situations, it is better to use manual configuration.
Using DHCP can be inconvenient for a computer that often needs to be accessed remotely. After a reboot, the IP address will change and the setting will have to be set manually again. In this case, it is also recommended to set a static IP address.


To work on a network, a computer needs an IP address to identify it among other devices. An IP address can be static, when it is set manually, or dynamic, when it is assigned automatically through the DHCP protocol. DHCP (Dynamic Host Configuration Protocol) is used to automatically assign IP addresses on a network. A server can assign an IP address to a client in a fixed, automatic, or dynamic manner depending on the parameters specified.
Using DHCP provides convenience and automation in assigning IP addresses, which simplifies networking.
23 Apr 2024, 12:58:35