set_wan_ipv6
set_wan_ipv6
Section titled “set_wan_ipv6”Set the WAN uplink’s IPv6 connection type and prefix delegation.
Side effects:
- Changes how the gateway obtains IPv6 on the WAN. Changing
connection_typetears down and re-establishes the WAN IPv6 session: existing IPv6 connections drop and the gateway re-negotiates with the ISP (DHCPv6/SLAAC). IPv4 connectivity is not affected, but IPv6 hosts lose reachability for a few seconds to a minute. Enabling delegation (prefix-delegation) is what hands IPv6 prefixes down to your LANs. - Only the IPv6 keys you supply change; every other field on the WAN 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.
Read first: call get_wan_ipv6 to see the current values.
BLAST RADIUS: this is a WAN-level change. On dual-WAN gateways it only
touches the named WAN. Do not run this against the live gateway without
intent: a mistyped connection_type can leave the WAN with no IPv6.
Example
Section titled “Example”set_wan_ipv6(connection_type="dhcpv6", prefix_delegation="prefix-delegation", dry_run=True)Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
connection_type | string | no | "" | "disabled", "dhcpv6", "pppoe", or "static". Empty leaves it unchanged. Most ISPs that hand out IPv6 (incl. Empire Access) use "dhcpv6". |
prefix_delegation | string | no | "" | "none" or "prefix-delegation" (alias for the controller’s wire value "pd"; "pd" is also accepted). Empty leaves it unchanged. Prefix delegation is required for your LANs to receive IPv6 subnets. |
pd_size | integer | no | 0 | DHCPv6-PD prefix size (48-64), e.g. 56. When enabling delegation, the controller requires a consistent wan_dhcpv6_pd_size_auto / wan_dhcpv6_pd_size pair: a non-zero pd_size pins wan_dhcpv6_pd_size_auto=false and sends that size; pd_size=0 while enabling delegation pins wan_dhcpv6_pd_size_auto=true (controller auto-sizes). Leaving an inconsistent pair on the record is what triggers api.err.InvalidValue, so the tool always emits a consistent pair when delegation is turned on. |
dns_preference | string | no | "" | "auto" or "manual" for IPv6 DNS. Empty leaves it unchanged. |
wan_name | string | no | "" | Display name of the WAN to target (e.g. "Internet 1"). Required only on multi-WAN gateways; single-WAN gateways match automatically. |
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. |