DHCPv6 and prefix delegation¶
This page lets you hand out IPv6 addresses, and blocks of addresses (prefixes) for routers behind
the network, with Ninlil. You turn on DHCPv6, create a scope for the addresses and optionally a
scope for prefix delegation. DHCPv6 answers on UDP port 547 (RFC 9915). 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
dhcpscopes:write,dhcpservices:manageanddhcpsettings:write. The bootstrap administrator holds every permission. - A network where Ninlil may answer DHCPv6, and the right to open UDP port
547(root orCAP_NET_BIND_SERVICE, see Ports). The scope and reservation rules in DHCPv4 scopes, reservations and leases apply to DHCPv6 scopes too.
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.
Turn on DHCPv6 and create scopes¶
-
Start the service, then save the switch with the
dhcpv6-protocolsection (the variable isNINLIL_DHCP_SERVER_PROTOCOL_DHCPV6_ENABLE):curl -k -X POST https://127.0.0.1:18443/api/dhcp-services/Dhcpv6/start -H 'Authorization: Bearer <token>' curl -k -X PATCH https://127.0.0.1:18443/api/dhcp-settings/dhcpv6-protocol -H 'Authorization: Bearer <token>' -H 'Content-Type: application/json' -d '{"enable":true}' -
Create a scope for the addresses. A DHCPv6 scope has no gateway, because IPv6 routers announce themselves (see Router Advertisement):
curl -k https://127.0.0.1:18443/api/dhcp-scopes -H 'Authorization: Bearer <token>' -H 'Content-Type: application/json' -d '{"name":"lan6","protocolVersion":"IPv6","rangeStartAddress":"fd00:50::1000","rangeEndAddress":"fd00:50::10ff","subnetPrefixLength":64,"defaultLeaseDuration":"08:00:00","maxLeaseDuration":"1.00:00:00","dnsServerAddresses":["fd00:50::2"]}' -
Optional: delegate blocks of addresses to routers (prefix delegation). Create a scope of kind
PrefixDelegation. The range is the pool of prefixes,subnetPrefixLengthis the size of the whole pool anddelegatedPrefixLengthis the size of each block. This pool is2001:db8:100::/48and delegates/56blocks, 256 of them:curl -k https://127.0.0.1:18443/api/dhcp-scopes -H 'Authorization: Bearer <token>' -H 'Content-Type: application/json' -d '{"name":"delegation","protocolVersion":"IPv6","kind":"PrefixDelegation","rangeStartAddress":"2001:db8:100::","rangeEndAddress":"2001:db8:100:ff00::","subnetPrefixLength":48,"delegatedPrefixLength":56,"defaultLeaseDuration":"08:00:00","maxLeaseDuration":"1.00:00:00"}'
A DHCPv6 reservation uses the device's DUID as clientIdentifier, for example
00:03:00:01:aa:bb:cc:00:06:01. A PrefixDelegation scope takes no reservations. DHCPv6 ignores
the lease times a device suggests: the lifetime is defaultLeaseDuration capped at
maxLeaseDuration. DHCPv6 Rapid Commit is off; read the README before you turn it on.
Check that it worked¶
-
Check the service.
Dhcpv6shows"isRunning":true:curl -k https://127.0.0.1:18443/api/dhcp-services -H 'Authorization: Bearer <token>'[{"kind":"Dhcpv4", ... },{"kind":"Dhcpv6","enabled":true,"isRunning":true}, ... -
List the leases (see "See the leases" in DHCPv4 scopes, reservations and leases). A DHCPv6 device appears with
"protocolVersion":"IPv6"and"state":"Active"after its request.
When something goes wrong¶
- A device gets no address. The service is
isRunninginGET /api/dhcp-services, the scope is enabled and hasavailableSlots, and with two or more enabled scopes a new local device needs a reservation or a relay (DHCPv4 page). - The log has
could not bind its socket: Permission deniedorAddress already in use. See the bind-failure entry on the DHCPv4 page; start the service again withPOST /api/dhcp-services/Dhcpv6/start.
Every NINLIL_DHCP_* variable is in ENVIRONMENT.md.
Next steps¶
- Router Advertisement: let devices find the router and build addresses.
- Relay agent: serve a network that Ninlil does not sit on.
- DHCPv4 scopes, reservations and leases.
- README: DHCP, DHCPv6 and Router Advertisement: the complete reference.