Table of Contents
In principle, the DHCP server and DHCP clients must be connected on the same network. The DHCP Relay Agent is the function to avoid this restriction.
This section explains how the DHCP Relay Agent works and the configuration commands on a Cisco router (Cisco IOS).
Please also refer to the following article about DHCP.
What is DHCP Relay Agent?
In principle, the DHCP server and DHCP clients must be connected to the same network. This means that DHCP servers must be deployed in each network. It is very time-consuming to deploy many DHCP servers and manage each server.
Therefore, the DHCP Relay Agent is used so that a single DHCP server can distribute TCP/IP configuration information to DHCP clients on multiple networks. The DHCP Relay Agent forwards broadcast DHCP messages from DHCP clients as unicasts to the DHCP server. In most cases, routers are configured as DHCP relay agents.
How the DHCP Relay Agent works
Configure DHCP pools for multiple networks on DHCP server
In order to distribute configuration information to DHCP clients on multiple networks with single DHCP server, DHCP pools for multiple networks should be configured in advance.
For example, to distribute TCP/IP configuration information to DHCP clients on three networks, 192.168.1.0/24, 192.168.2.0/24, and 192.168.3.0/24, create three DHCP pools as shown in the following figure.
In considering how the DHCP Relay Agent works, let’s look at the IP address assignment to DHCP client 1 on 192.168.1.0/24 in the above figure.
DHCP DISCOVER Forwarding
When DHCP Client 1 connects to the network, it broadcasts DHCP DISCOVER message to find a DHCP server. The broadcast is not forwarded to other networks.
The router with the DHCP relay agent enabled receives the DHCP DISCOVER message and translates the destination IP address to the unicast IP address of the DHCP server and forwards it. At that time, the IP address of the relay agent, 192.168.1.1, is specified as gipaddr in the DHCP message.
The DHCP server receives a unicast DHCP DISCOVER message and must determine which network the DHCP client is on. So, it checks the gipaddr of the DHCP relay agent’s IP address in the DHCP message.The DHCP Relay Agent should be on the same network as the client. The DHCP server distributes the IP address of DHCP Pool 1, which is the same network as the IP address of the DHCP Relay Agent.
The source IP address and source port number for forwarding to the DHCP server are not specified in the RFC; in Cisco’s implementation, the source IP address is the IP address of the relay agent. In the figure above, the source IP address is 192.168.1.1. And the source port number is UDP67 (DHCP server).
DHCP OFFER Forwarding
The DHCP server forwards DHCP OFFER, which provide configuration information to the client, to the relay agent. The relay agent then forwards it to the entire 192.168.1.0/24 address with the destination as a broadcast address. DHCP client 1 can then receive the DHCP OFFER.
The destination of DHCP OFFER can be unicast rather than broadcast; whether an OFFER is broadcast or unicast is determined by the broadcast flag in the DHCP message.
DHCP REQUEST Forwarding
DHCP client 1 broadcasts DHCP REQUEST to request the TCP/IP configuration information proposed in the OFFER. The DHCP Relay Agent will then forward the information to the DHCP server via unicast.
DHCP ACK Forwarding
Forwards ACK message from DHCP server to relay agent authorizing use of TCP/IP configuration information. The relay agent forwards the DHCP ACK message to the client via broadcast. DHCP client 1 now completes the TCP/IP configuration, including the IP address.
The destination of DHCP ACK may also be unicast rather than broadcast; whether the ACK is broadcast or unicast is determined by the broadcast flag in the DHCP message.
DHCP Relay Agent Configuration and Verification Commands (Cisco IOS)
DHCP Relay Agent Configuration Commands
You can configure a Cisco router as a DHCP relay agent. Enter the configuration command on the interface that will receive broadcast DHCP messages. That is, the interface to which the DHCP client is connected.
DHCP Relay Agent Configuration
(config-if)#ip helper-address <dhcp-server-ip-address>
<interface-name> : Name of the interface to which the DHCP client is connected
<dhcp-server-ip-address> : IP address of the forwarding DHCP server
The configuration command is very simple: configure the ip helper-address command on every interface where DHCP clients are present.
DHCP Relay Agent Verification Commands
The following table summarizes the main commands used to verify that the DHCP Relay Agent has been configured correctly.
|#show ip interface||Verify the IP address of the forwarding DHCP server.|
show ip interface
Verify that the IP address of the DHCP server to which DHCP messages are forwarded is configured correctly with the show ip interface command.
show ip interface
R1#show ip interface Ethernet 0/0 Ethernet0/0 is up, line protocol is up Internet address is 192.168.1.1/24 Broadcast address is 255.255.255.255 Address determined by setup command MTU is 1500 bytes Helper address is 192.168.4.100 Directed broadcast forwarding is disabled Outgoing access list is not set Inbound access list is not set Proxy ARP is enabled -- omitted --
- If the DHCP server and DHCP client are not on the same network, the DHCP Relay Agent is required.
- The DHCP Relay Agent forwards broadcast DHCP messages unicast to the DHCP server.
- To configure a Cisco router to be a DHCP relay agent, enter the following command in interface configuration mode on the interface where the client exists.
- (config-if)#ip helper-address <dhcp-server-ip-address>
The following article is a detailed configuration example of the DHCP Relay Agent on a Cisco router. The packet capture results are also included so that you can see in detail how the DHCP Relay Agent works.
The following article summarizes DHCP server placement.
- 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)