Relay agent¶
This page lets Ninlil forward the DHCP requests of one network to a DHCP server on another network. Each protocol runs either as Ninlil's server or as a relay, never both. The README is the complete reference.
Before you start¶
- A running Ninlil, a signed-in API token and the placeholder
<token>, as in DHCPv4 scopes, reservations and leases "Before you start". The commands use the Quick start's HTTPS port18443. - A user that holds
dhcpsettings:writeanddhcpservices:manage. The bootstrap administrator holds every permission. - A DHCP server on another network, with an enabled scope that covers the relay's address on the clients' network.
The examples call the API on 127.0.0.1 with curl -k, which skips the certificate check.
That is safe only on the machine that runs Ninlil; see Self-signed certificate.
Forward requests to an upstream server¶
A relay agent forwards the requests of its network to a DHCP server somewhere else. Each protocol runs either as Ninlil's server or as a relay, chosen at start, never both.
- On the host that acts as the relay, start Ninlil with
NINLIL_DHCP_SERVER_PROTOCOL_DHCPV4_ENABLE=trueandNINLIL_DHCP_SERVER_RELAY_DHCPV4_ENABLE=true. -
Save the relay settings: the upstream servers, the relay's address on the clients' network (
giaddr), and an optional circuit ID that the server can match:curl -k -X PATCH https://127.0.0.1:18443/api/dhcp-settings/relay -H 'Authorization: Bearer <token>' -H 'Content-Type: application/json' -d '{"upstreamServerAddresses":["192.168.50.2"],"relayAgentAddress":"192.168.50.3","relayAgentCircuitId":"port-7"}'{"note":"Written to the configuration file. This setting is read once, at startup, so a restart is required before this change takes effect."} -
Restart Ninlil. On the upstream server, an enabled scope must cover the relay address (
192.168.50.3falls in thelanscope of the DHCPv4 page).
The DHCPv6 relay works the same way with the dhcpv6-relay section
(NINLIL_DHCP_SERVER_RELAY_DHCPV6_ENABLE, the upstream addresses and relayLinkAddress). The relay
relays a reply only when its source address is one of the listed upstream addresses. With no
upstream address, it drops every request.
The script src/script/development/dhcp-relay-two-link-test.sh checks a relay with two real links.
It needs root, tcpdump and DHCP clients, and CI does not run it. See the README for its use.
Check that it worked¶
-
Check that the service runs.
Dhcpv4shows"isRunning":true:curl -k https://127.0.0.1:18443/api/dhcp-services -H 'Authorization: Bearer <token>' -
On the upstream server, a device behind the relay appears in the lease list (see "See the leases" in DHCPv4 scopes, reservations and leases) after it renews.
When something goes wrong¶
- The relay drops everything. The log has
Dropping a DHCPv4 request this relay would otherwise forward: no upstream server addresses are configured. SaveupstreamServerAddressesand restart. - A relayed device gets no reply. No enabled scope on the upstream server covers
giaddr, or the upstream server answers from an address that is not in the list.
Every NINLIL_DHCP_* variable is in ENVIRONMENT.md.
Next steps¶
- DHCPv4 scopes, reservations and leases: the scope on the upstream server.
- DHCPv6 and prefix delegation.
- README: DHCP, DHCPv6 and Router Advertisement: the complete reference.