set_lan_ipv6
set_lan_ipv6
Section titled “set_lan_ipv6”Set the IPv6 configuration of one LAN/VLAN network.
Side effects:
- Changes how this network gets and advertises IPv6. Turning on
interface_type="pd"plusra_enabled=Trueis what makes the LAN’s clients receive global IPv6 addresses from the prefix delegated by the WAN. Toggling router advertisements (ra_enabled) or the address-assignment mode causes clients on this network to re-acquire IPv6; IPv4 is unaffected. - Only the IPv6 keys you supply change; every other field on the network record is read first and written back unchanged (strict read-modify-write).
- Mutates controller state. Use dry_run=True to preview the before/ after diff without applying.
Prefix-delegation binding: when interface_type="pd" the controller
REQUIRES the LAN to reference which DHCPv6 WAN’s delegation to draw
from. ipv6_interface_type=pd on its own returns HTTP 400
api.err.PdRequiresAssignedDhcpv6Wan. This tool auto-binds the LAN to
the WAN that actually has DHCPv6-PD enabled (on a single-uplink gateway
that is the only internet uplink) by emitting ipv6_pd_interface =
that WAN’s networkgroup (e.g. "wan"). No WAN with PD enabled → a
clear error instead of a controller 400.
Fresh-LAN PD scaffold: a brand-new LAN
(ipv6_setting_preference=manual, every ipv6 key unset) has no PD
window, DHCPv6 lease window, or RA lifetimes. Enabling PD on it without
those returns HTTP 400 api.err.InvalidIpv6Addr (the merged record
carries ipv6_pd_start: null). When enabling PD, this tool fills the
COMPLETE required scaffold with the controller’s standard defaults
(ipv6_pd_start=::2, ipv6_pd_stop=::7d1, matching DHCPv6 lease
window, ipv6_ra_priority=high, RA lifetimes) — but ONLY for keys the
live record lacks and the caller did not set explicitly, so an
already-configured PD LAN keeps its own window untouched.
Carving a DISTINCT /64 for a SECOND PD LAN (prefix_id): on UniFi
Network 10.4.57 the controller’s auto IPv6 mode hands the primary
sub-prefix (id 0) to ONE LAN (the Default/MGMT LAN) and leaves a second
auto PD LAN with an empty ipv6_subnets — it never carves its own /64
(probed live 2026-06-14). To give a second LAN its own slice, pass an
explicit prefix_id (e.g. 1). When prefix_id is supplied the
tool writes ipv6_pd_prefixid=<id> AND pins
ipv6_setting_preference="manual" (it does NOT flip to auto),
because only manual mode honours an operator-pinned sub-prefix. Both keys
survive the strict read-modify-write and the scaffold-fill. Omitting
prefix_id keeps the legacy auto behaviour unchanged.
Read first: call list_networks to find the network_id and see
the current ipv6_* state (now surfaced inline).
Example
Section titled “Example”set_lan_ipv6(network_id="65f...", interface_type="pd", ra_enabled=True, dry_run=True)Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
network_id | string | yes | — | The _id from list_networks (a LAN/VLAN, not a WAN). |
interface_type | string | no | "" | "none", "pd" (use the WAN-delegated prefix), or "static". Empty leaves it unchanged. When set to "pd" the WAN binding is added automatically. |
ra_enabled | `boolean | null` | no | null |
address_assignment | string | no | "" | "slaac" or "dhcpv6". Empty leaves it unchanged. |
dns_auto | `boolean | null` | no | null |
dns_servers | `array | null` | no | null |
prefix_id | integer | no | -1 | Sub-prefix id (e.g. 0, 1) selecting which /64 to carve from the delegated /56, so multiple PD LANs don’t collide. Only valid with interface_type="pd". Default -1 means “not supplied” — the LAN keeps the controller-managed auto carve (only the primary LAN gets a /64). Supplying a value (0 and up) writes ipv6_pd_prefixid AND pins ipv6_setting_preference="manual" so the controller honours the pinned sub-prefix and the LAN carves its OWN /64. The Default/MGMT LAN already holds id 0, so a second LAN needs a distinct id (1, 2, …). |
controller | string | no | ”default” | Name of the UniFi controller to target. Defaults to "default". |
dry_run | boolean | no | false | Preview the before/after diff without applying it. |