Understanding the Operation of DHCP Relay Agents

The discover and request messages are broadcast in the DORA process, and the offer and acknowledgement messages are broadcast or unicast depending on the value of the broadcast flag, i.e. if the value of the broadcast flag is 1, the offer and acknowledgement messages are broadcast, and if the value of the broadcast flag is 0, the messages are unicast. 

What exactly is Dora in DHCP?

A DHCP client-to-server communication between two peers consists of three types of interaction: DORA is a broadcast-based organisation (Discover, Offer, Request, Acknowledgement). The DHCP client broadcast Request requests the offered IP address lease, followed by the DHCP broadcast Acknowledgement.

However, because the router does not forward any broadcast packets, this is only true when the DHCP server is present on the same network. What happens if the server is on a different network? This is where the DHCP relay agent comes in.

In this tutorial, I will go over in detail how to configure a DHCP relay agent. Learn how to configure DHCP relay agents on Cisco routers using the 'ip helper-address' command using a packet tracer example. Before we get into the details, it's important to understand the basics of DHCP, DHCP client, and DHCP server.

What is the main use of DHCP?

Dynamic Host Configuration Protocol (DHCP) is a network management protocol used to automate the process of configuring devices on IP networks, thus allowing them to use network services such as DNS, NTP, and any communication protocol based on UDP or TCP.

DHCP is a protocol that allows hosts to allocate IP addresses automatically and employs four separate packets to do so. We use broadcast messages over the network to hopefully reach a DHCP server because a computer doesn't have an IP address to begin with. 

The issue with broadcast is that it requires the DHCP server to be in the same broadcast domain as the DHCP client because routers do not forward broadcast packets.

Local broadcast messages are used by DHCP clients to obtain IP addresses from the DHCP server. Local broadcast messages are not forwarded by routers by default. This means that if the DHCP server is configured on a different network, or if a router is configured between the DHCP server and the DHCP clients, the DHCP clients will not receive IP addresses from the DHCP server. 

In this case, a network administrator has two options: configure a DHCP server in each subnet or configure the router as a DHCP relay agent, connecting the subnet to the DHCP server.

If a client resides on a different network than the DHCP server, you have to configure the default gateway of the client as a DHCP relay agent to forward the broadcast packets as unicast packets to the server. 

It is much easier than you might think to configure a router's interface as a DHCP relay agent. In interface configuration mode, use the following command to configure a router's interface as a DHCP relay agent.

Router(config-if)#ip helper-address [dhcp-IP server's address]

The command 'ip helper-address' instructs the interface to forward the incoming DHCP message to the configured DHCP server. Use this command on all interfaces connected to local subnets with DHCP clients.

In this post, I have explained how to set up Cisco routers as DHCP relay agents.

Let's look at an example:

A client (C1) is on the left, a router (R1) is in the middle, and our DHCP server is on the right. The client will emit a DHCP discover the message in order to obtain an IP address using DHCP. Because the router is performing its duty, broadcast traffic will not be forwarded, and the DHCP discovery will never reach the DHCP server.

So, how do we go about resolving this? We must employ the DHCP Relay Agent feature. In short, the router will forward DHCP requests from the client to the DHCP server, and when the DHCP server responds, the messages will be forwarded back to the client.

If a client resides on a different network than the DHCP server, you need to configure the default gateway of the client as a DHCP relay agent to forward the broadcast packets as unicast packets to the server. 

You use the ip helper-address ip_address interface configuration mode command to configure a router to relay DHCP messages to a DHCP server in the organization.

What exactly is a DHCP relay agent and how does it work?

Any TCP/IP host that forwards requests and answers between DHCP server and client when the server is on a different network is referred to as a DHCP relay agent. DHCP transmissions are received by relay agents, who then construct a fresh DHCP message to transmit out on another interface.

The DHCP server selects an IP address to allocate to the DHCP client from an IP pool by referring to the relay agent IP address in a DHCP Discover message and sends a DHCP Offer message with the destination IP address set as the relay agent IP address.

What is the port number for the DHCP relay?

DHCP messages sent by a client to a server are routed through the well-known port 67 (UDP—Bootstrap Protocol and DHCP). DHCP messages sent by a server to a client are routed to port 68. A Palo Alto Networks firewall interface can act as a DHCP server, client, or relay agent.

Why does DHCP require two ports?

The use of a well-known port (in our case, 68) prevents the use of the same two destination port numbers, preventing other protocols from using a port that is already in use by another protocol. In other words, it prevents an application from receiving a message from a different protocol.

What causes DHCP failure?

A DHCP error can be caused by one of two things. The configuration on the computer or device that allows a DHCP server to assign it an IP address is one example. The other is the DHCP server configuration. DHCP errors occur when a network's DHCP server or router is unable to automatically adjust a device's IP address in order for it to join the network.

What is the best way to configure a DHCP relay agent?

To demonstrate the configuration of the DHCP relay agent, I have used the Cisco Packet Tracer tool. 

The DHCP client in the figure is part of the 172.16.1.0/24 network, while the DHCP server is part of the 10.1.1.0/24 network. The syntax shown in the Example is used to configure Router R1 as a DHCP relay agent.

Relay Agent











Configuration: DHCP server

Router#conf terminal

Router(config)#hostname dhcpServer

dhcpServer(config)#interface f0/0

dhcpServer(config-if)#ip address 10.1.1.2 255.255.255.0

dhcpServer(config-if)#no shut


dhcpServer#conf t

dhcpServer(config)#ip dhcp pool pool1

dhcpServer(dhcp-config)#network 172.16.1.0 255.255.255.0

dhcpServer(dhcp-config)#default-router 172.16.1.1

dhcpServer(dhcp-config)#dns-server 172.16.1.1

dhcpServer(dhcp-config)#ip dhcp excluded-address 172.16.1.1

dhcpServer(dhcp-config)#exit


dhcpServer#conf t

dhcpServer(config)#router rip

dhcpServer(config-router)#version 2

dhcpServer(config-router)#network 10.1.1.0



DHCP Relay Agent


dhcprelyagent#conf t

dhcprelyagent(config)#interface f0/1

dhcprelyagent(config-if)#ip address 10.1.1.1 255.255.255.0

dhcprelyagent(config-if)#no shut

dhcprelyagent(config-if)#exit

dhcprelyagent(config)#interface f0/0

dhcprelyagent(config-if)#ip address 172.16.1.1 255.255.255.0

dhcprelyagent(config-if)#no shut

dhcprelyagent#conf t

dhcprelyagent(config)#router rip

dhcprelyagent(config-router)#version 2

dhcprelyagent(config-router)#network 10.1.1.0

dhcprelyagent(config-router)#network 172.16.1.0

dhcprelyagent#conf t

dhcprelyagent(config)#interface f0/0

dhcprelyagent(config-if)#ip helper-address 10.1.1.2


DHCP Relay Configuration Verification


To view the current DHCP relay setting, use the show config command (or show running for the running-config file).


How to troubleshoot DHCP relay?


Enable debugging and use the display command on the DHCP relay agent to view debugging and interface state information in order to locate the problem. The DHCP server and relay agent are both configured to use DHCP.


Is it better to use DHCP or a static IP address?


When comparing DHCP vs static IP, it is clear that DHCP is the more popular option for most users because it is easier and less expensive to deploy. Having a static IP address and guessing which IP address is available is extremely inconvenient and time-consuming, especially for those unfamiliar with the process.


Some Useful Commands


sh ip dhcp ?

binding      DHCP address bindings

conflict      DHCP address conflicts

pool           DHCP pools information

relay          Miscellaneous DHCP relay information


I hope you found this post helpful.

0 Comments: