14.3. DHCP Relay Agent
The DHCP Relay Agent (dhcrelay) enables the relay of
DHCP
and BOOTP
requests from a subnet with no DHCP
server on it to one or more DHCP
servers on other subnets.
When a
DHCP
client requests information, the DHCP Relay Agent forwards the request to the list of DHCP
servers specified when the DHCP Relay Agent is started. When a DHCP
server returns a reply, the reply is broadcast or unicast on the network that sent the original request.
The DHCP Relay Agent for
IPv4
, dhcrelay, listens for DHCPv4
and BOOTP
requests on all interfaces unless the interfaces are specified in /etc/sysconfig/dhcrelay
with the INTERFACES
directive. See Section 14.3.1, “Configure dhcrelay as a DHCPv4 and BOOTP relay agent”. The DHCP Relay Agent for IPv6
, dhcrelay6, does not have this default behavior and interfaces to listen for DHCPv6
requests must be specified. See Section 14.3.2, “Configure dhcrelay as a DHCPv6 relay agent”.
dhcrelay can either be run as a
DHCPv4
and BOOTP
relay agent (by default) or as a DHCPv6
relay agent (with -6
argument). To see the usage message, issue the command dhcrelay -h
.
14.3.1. Configure dhcrelay as a DHCPv4 and BOOTP relay agent
To run dhcrelay in
DHCPv4
and BOOTP
mode specify the servers to which the requests should be forwarded to. Copy and then edit the dhcrelay.service
file as the root
user:
~]#cp /lib/systemd/system/dhcrelay.service /etc/systemd/system/
~]#vi /etc/systemd/system/dhcrelay.service
Edit the
ExecStart
option under section [Service] and add one or more server IPv4
addresses to the end of the line, for example: ExecStart=/usr/sbin/dhcrelay -d --no-pid 192.168.1.1
If you also want to specify interfaces where the DHCP Relay Agent listens for
DHCP
requests, add them to the ExecStart
option with -i
argument (otherwise it will listen on all interfaces), for example: ExecStart=/usr/sbin/dhcrelay -d --no-pid 192.168.1.1 -i em1For other options see the
dhcrelay(8)
man page.
To activate the changes made, as the
root
user, restart the service:
~]#systemctl --system daemon-reload
~]#systemctl restart dhcrelay
14.3.2. Configure dhcrelay as a DHCPv6 relay agent
To run dhcrelay in
DHCPv6
mode add the -6
argument and specify the “lower interface” (on which queries will be received from clients or from other relay agents) and the “upper interface” (to which queries from clients and other relay agents should be forwarded). Copy dhcrelay.service
to dhcrelay6.service
and edit it as the root
user:
~]#cp /lib/systemd/system/dhcrelay.service /etc/systemd/system/dhcrelay6.service
~]#vi /etc/systemd/system/dhcrelay6.service
Edit the
ExecStart
option under section [Service] add -6
argument and add the “lower interface” and “upper interface” interface, for example: ExecStart=/usr/sbin/dhcrelay -d --no-pid -6 -l em1 -u em2For other options see the
dhcrelay(8)
man page.
To activate the changes made, as the
root
user, restart the service:
~]#systemctl --system daemon-reload
~]#systemctl restart dhcrelay6