Table of Contents
DHCP is the protocol used to automatically distribute IP addresses and other TCP/IP configurations. DHCP is a very commonly used protocol. It is important to understand how it works.
What is DHCP(Dynamic Host Configuration Protocol)?
DHCP (Dynamic Host Configuration Protocol) is the protocol used to automatically configure IP addresses and other configurations required for TCP/IP communication.
In order to communicate with TCP/IP, it is a prerequisite that the TCP/IP configurations are correct. If the configurations are incorrect, of course, normal communication will not be possible. Specific configurations include the following.
- IP address / Subnet mask
- Default gateway IP address
- DNS server IP address
Users who are familiar with information technology will be able to configure these settings without difficulty. However, for users who are not so familiar with information technology, it can be a challenge to configure TCP/IP by themselves. Even experienced users often make mistakes. In order to eliminate such mistakes, it is effective to automate the configuration. DHCP is the protocol for this purpose.
DHCP automatically configures the necessary TCP/IP settings once the host is connected to the network, allowing even users unfamiliar with IT technology to make the correct configurations. This also prevents problems caused by simple misconfigurations.
As an IT technician, you should properly understand the meaning of TCP/IP configurations. The following article explains in detail the meaning of TCP/IP configurations.
DHCP message encapsulation
DHCP is a protocol located in the application layer that uses UDP in the transport layer. Note that although DHCP is a protocol located at the application layer, its purpose is not to define application functions or data formats, but rather to configure the necessary configurations for TCP/IP communication.
DHCP messages are encapsulated in UDP header. Well-known port numbers are 67 and 68: 67 for the DHCP server and 68 for the DHCP client. Further encapsulation is done with IP header. The physical signal is then sent out to the transmission medium by encapsulating it with an Ethernet header and an 802.11 (Wi-Fi) header.
Overview of DHCP behavior
To use DHCP, prepare a DHCP server in advance and register TCP/IP configurations, such as IP addresses to be distributed, etc. Windows/Linux servers can be used as DHCP servers. Routers/Layer 3 switches also have a DHCP server function.
When a DHCP client host connects to the network, it exchanges the following four messages with the DHCP server to automatically configure TCP/IP settings.
- DHCP DISCOVER
- DHCP OFFER
- DHCP REQUEST
- DHCP ACK
The DHCP exchange described above uses broadcast. To begin with, the DHCP client does not know its own IP address. Of course, the IP address of the DHCP server is also unknown. Even if the client does not know the IP address of the DHCP server, broadcast is used when the client wants to send some data.The idea is that if you send a broadcast to everyone on the same network, if there is a DHCP server on the same network, the DHCP server will respond back. In order to use broadcast, the DHCP server and DHCP client must, in principle, be connected to the same network.This is because routers interconnecting networks do not forward broadcasts to other networks.
When DHCP is used to obtain configuration information, the IP address of a host can change frequently, making it time-consuming to identify the host if the IP address changes. When DHCP is used to automatically set IP addresses, it is also possible to distribute a fixed IP address.
The following article describes the commands to configure a Cisco router as a DHCP server.
DHCP Relay Agent
The DHCP client and DHCP server must be on the same network, but this can be difficult. A company’s internal network is divided into multiple networks, e.g., for each department. If a DHCP server is prepared for each network, many DHCP servers will be needed and server management will become complicated. It is natural to want a single DHCP server to distribute TCP/IP configuration information to DHCP clients on multiple networks.
To distribute TCP/IP configuration information to DHCP clients on multiple networks with a single DHCP server, configure a DHCP pool for each network. The DHCP Relay Agent function is then used.
DHCP Relay Agent is a function that converts DHCP broadcast messages to unicast.The DHCP Relay Agent function is commonly used on routers; enable the DHCP Relay Agent function on the router on the network to which the DHCP client is connected.
With DHCP Relay Agent, DHCP server distributes TCP/IP configuration information to DHCP clients on different networks as follows.
- DHCP client broadcasts DHCPDISCOVER.
- When a router with DHCP Relay Agent enabled receives a DHCPDISCOVER broadcast message from a DHCP client, it converts the DHCP server IP address to a unicast as the destination IP address and forwards it. At this time, information on the IP address of the DHCP relay agent is also added.
- The DHCP server determines which DHCP pools to distribute to clients based on the IP address information in the DHCP Relay Agent. The DHCP server then returns DHCPOFFER from the appropriate DHCP pool to the router of the DHCP relay agent.
- The router converts the DHCPOFFER to a broadcast and forwards it.
Thereafter, DHCPREQUEST and DHCPACK are forwarded in the same manner.
The following article summarizes the DHCP Relay Agent in more detail.
The following article summarizes DHCP server placement.
- DHCP allows for automatic TCP/IP configuration, including IP addresses.
- The four main DHCP messages are
- DHCP messages are exchanged on broadcast basis. Therefore, as principle, the DHCP server and DHCP client must be connected on the same network.
- nslookup command : Verifying DNS name resolution
- DHCP : Automatically Assign IP Address
- Cisco IOS DHCP Server Configuration and Verification Commands
- Cisco Router DHCP Server Configuration Example
- DHCP Relay Agent
- TCP/IP Configuration Summary
- ipconfig command : To verify TCP/IP configurations on Windows OS
- Commands to Verify TCP/IP Configuration On Linux (Ubuntu)