This article describes the steps needed to relay DHCP messages from clients to a DHCP server located on a different subnet.
Notes & Requirements:
Applicable to EdgeOS 1.9.1+ firmware in all EdgeRouter models. Knowledge of the Command Line Interface (CLI) and basic networking knowledge is required. Find a basic article on the subject in the Related Articles below.
Equipment used in this article:
Table of Contents
The network topology is shown below. The following interfaces are in use on the ER:
- Ethernet 0 (Eth0) 172.16.1.1
- Ethernet 1 (Eth1) 192.168.1.1/24
- Ethernet 2 (Eth2) 10.0.1.1/24
Steps – DHCP Relay
In this example the ER is running in the default configuration. The ER is connected to two DHCP clients but is not running a DHCP server itself, instead it forwards all DHCP requests to the DHCP server located at 172.16.1.2.
The DHCP relay agent (the ER) sets the gateway address (giaddr) and adds the relay agent information option to the forwarded packet:
- The giaddr address is used by the dhcp server to identify which subnet (interface) the request originated on.
- Using this information, the server knows which pool to assign an address from.
Access the command line interface (CLI). You can do this using the CLI button in the GUI or by using a program such as PuTTY.
1. Enter configuration mode.
2. Create the DHCP Relay agent configuration on the relevant interfaces (including the upstream interface).
set service dhcp-relay interface eth0
set service dhcp-relay interface eth1
set service dhcp-relay interface eth2
|Note: The DHCP Relay agent needs to be configured to listen on all the interfaces participating in the relaying process. This includes the interfaces connected to the clients (Eth1 and Eth2) but also the interface that connects (upstream) to the DHCP server (Eth0)|
3. Define the location of the DHCP Server.
set service dhcp-relay server 172.16.1.2
4. (Optional) Futher define the relaying options.
A DHCP relay agent may receive a DHCP message from another DHCP relay agent that already contains relaying information (relayed twice). By default the DHCP packet is discarded, but you can customize this behavior with the following command:
set service dhcp-relay relay-options relay-agents-packets [ append | replace | forward | discard ]
- append append own relay options to packet
- replace replace existing agent option field
- forward forward packet unchanged
- discard discard packet (default action if giaddr not set in packet)
5. Commit the changes.
6. Save the configuration.