Table of contents | |
Introduction | |
What is DHCP? | |
Why Use DHCP? | |
How DHCP Works | |
DHCP Relay Agent in Computer Network |
Dynamic Host Configuration Protocol (DHCP) is a network protocol used to automate the assignment of IP addresses and other network configuration parameters to devices such as computers, smartphones, and printers. Instead of manually configuring each device, DHCP allows devices to connect to a network and receive necessary information like IP address, subnet mask, default gateway, and DNS server addresses automatically from a DHCP server. This simplifies network management, especially in large networks, by ensuring devices can communicate effectively without configuration conflicts.
DHCP stands for Dynamic Host Configuration Protocol. It is crucial for enterprise networks, helping to manage IP address allocation for devices like desktops, laptops, and cellphones. As an application layer protocol, DHCP operates on a client-server model and involves discovery, offer, request, and acknowledgment (ACK) steps.
Subnet Mask (Option 1 - e.g., 255.255.255.0)
Router Address (Option 3 - e.g., 192.168.1.1)
DNS Address (Option 6 - e.g., 8.8.8.8)
Vendor Class Identifier (Option 43 - e.g.,
'unifi' = 192.168.1.9 ##where unifi = controller)
DHCP automates and centralizes IP address management. It maintains unique IP addresses for hosts via a server, handling TCP/IP configuration and address allocation through lease offers.
DHCP operates on the application layer of the TCP/IP protocol, dynamically assigning IP addresses and allocating TCP/IP configuration to clients. The process involves exchanging four main messages: discover, offer, request, and acknowledgment (DORA), but includes eight messages in total.
Working of DHCP
Note: All DHCP messages can also be unicast by a DHCP relay agent if the server is on a different network.
A DHCP starvation attack occurs when a hacker floods the server with IP requests, exhausting available addresses. This can lead to a denial of service for legitimate users and enable man-in-the-middle attacks.
Automating DHCP reduces manual management, allowing for seamless network expansion without additional staffing. It prevents common issues like printer connectivity problems and subnet incompatibilities.
Advantages
Disadvantages
DHCP simplifies network setup by automatically assigning IP addresses and configurations. While it offers significant convenience, it requires careful security management to prevent issues like IP address exhaustion and unauthorized data access. Robust measures, including firewalls and VPNs, are essential to protect against network disruptions and ensure the efficient management of connections.
To assign an IP address to the host dynamically, the DHCP client exchanges DHCP messages with the DHCP server in the DORA process.
In the DORA process, the discover and request message is broadcast, the offer and the acknowledgement message is broadcast or unicast depending upon the value of the broadcast flag i.e. If the value of the broadcast flag is 1, then the offer and acknowledgement message is broadcast and if 0, the messages are unicast. But this is valid only when the DHCP server is present in the same network because the router doesn’t forward any broadcast packet. What if the server is present in a different network? Here comes the role of DHCP relay agent.
The DHCP relay agent is any TCP/IP host which is used to forward requests and replies between the DHCP server and client when the server is present on a different network. Relay agents receive DHCP messages and then generate a new DHCP message to send out on another INTERFACE. Also, the DHCP relay agent adds a giaddr (gateway address of the packet) field and also the Relay agent information option 82 if enabled. The options field is removed when the server reply is forwarded to the host.
DHCP relay agents are commonly used in large enterprise networks where the DHCP server is located on a different network segment than the client devices.The DHCP relay agent listens for DHCP broadcast messages from the client devices and then forwards those messages to the DHCP server, encapsulating them in a unicast packet.The DHCP relay agent may be configured with one or more IP addresses of DHCP servers that it can forward requests to.The giaddr field in the DHCP relay agent message is used to indicate the IP address of the relay agent interface on which the message was received.The Relay Agent Information option (option 82) may be used to add additional information to the DHCP request message, such as the interface or port number on which the request was received, or the VLAN ID of the requesting device.DHCP relay agents may be implemented in dedicated hardware devices, or they may be implemented in software on routers or other network devices.Some DHCP relay agents may include additional features such as DHCP packet filtering, rate limiting, or access control based on the source or destination IP address.If a DHCP relay agent is not properly configured, it can cause delays or failures in the DHCP process, leading to network connectivity issues for client devices.
Note – The discover and request messages are unicast by the DHCP relay agent.
Example –
Here is a topology in which there is a DHCP client having no IP address. There is a DHCP server having IP address 192.168.2.2 and there is a router in the middle which we want as the DHCP relay agent has an IP address 192.168.1.1 on interface fa0/0 and 192.168.2.1 on interface fa0/1.
Now, first, the discover message is broadcast by the DHCP client to find out the DHCP server which is received by the switch as it is in the same broadcast domain. The switch broadcast the DHCP packet in the network, received by both PC and Router(DHCP Relay Agent). The PC and the router receive the broadcast packet but the PC drops the packet as the DHCP server is present in the different network therefore the packet has to be delivered to the default gateway only.
The router, with DHCP relay agent feature, enabled, replaces the source address with its own address and the destination IP address with DHCP server IP address i.e. the DHCP relay agent unicast the packet to DHCP server. DHCP relay agent adds giaddr field into the packet and forwards it to the DHCP server. giaddr field is added to the packet so that the server should know from which pool, it has to assign the IP address.
In our case, the giaddr field will contain 192.168.1.1 (IP address of the interface on which the router [DHCP relay agent] receives the discover message).
The server replies with a unicast DHCP offer to the router offering the unleashed IP address.
In return, the router broadcast the DHCP Offer message to the network which has sent the DHCP request. The broadcast message is received by a switch as shown in the above figure.
The switch broadcasts the DHCP offer message to the hosts. Therefore, the message is received by the DHCP client
Now, the DHCP client broadcast the DHCP request message, showing the acceptance of the IP address, for the server which is received by the switch. The switch broadcast the DHCP request message to the other host and the router(DHCP Relay Agent)as shown in the above figure.
The router replaces the source IP address with its own IP address and destination IP remains the same i.e. It is unicast by the DHCP relay agent
The server replies with a unicast DHCP Acknowledgement message to the router (DHCP relay agent) as shown in the above figure.
The router in turn broadcast the DHCP Acknowledgement message to the network it receives the DHCP request for an IP address. The broadcast message is received by a switch as shown in the above figure.
The broadcast DHCP Acknowledgement message is received by the DHCP client as the switch broadcast the message through all its ports.
This is the basic configuration of the client, router, dhcp_server. The router has been assigning IP addresses 192.168.1.1 on fa0/0 and 192.168.2.1 on fa0/1.
ROUTER(config)#int f0/0
ROUTER(config-if)#ip address 192.168.1.1 255.255.255.0
ROUTER(config-if)#no shutdown
ROUTER(config)#int f0/1
ROUTER(config-if)#ip address 192.168.2.1 255.255.255.0
ROUTER(config-if)#no shutdown
The DHCP_SERVER is assigned IP Address 192.168.2.2 on the interface fa0/0 and the DHCP pool is defined with name POOL1 and network of 192.168.1.0 with subnet mask 255.255.255.0 is assigned to the pool POOL1.
DHCP_SERVER(config)#int f0/0
DHCP_SERVER(config-if)#ip address 192.168.2.2 255.255.255.0
DHCP_SERVER(config-if)#no shutdown
DHCP_SERVER(config)#ip dhcp pool POOL1
DHCP_SERVER(dhcp-config)#network 192.168.1.0 255.255.255.0
DHCP_SERVER(dhcp-config)#default-router 192.168.1.1
DHCP_SERVER(dhcp-config)#exit
Now, the IP helper-address command is used for configuring the router as a DHCP relay agent, giving 192.168.2.2 the address of DHCP_server.
ROUTER(config)#int f0/0
ROUTER(config-if)#ip helper-address 192.168.2.2
ROUTER(config-if)#exit
21 videos|113 docs|66 tests
|
1. What is the role of a DHCP relay agent in a computer network? |
2. How does DHCP work in a computer network? |
3. Why is DHCP used in computer networks? |
4. What are the benefits of using DHCP in a network environment? |
5. Can DHCP be used in both wired and wireless networks? |
|
Explore Courses for Computer Science Engineering (CSE) exam
|