Skip to content

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_type tears 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.

set_wan_ipv6(connection_type="dhcpv6", prefix_delegation="prefix-delegation", dry_run=True)
ParameterTypeRequiredDefaultDescription
connection_typestringno"""disabled", "dhcpv6", "pppoe", or "static". Empty leaves it unchanged. Most ISPs that hand out IPv6 (incl. Empire Access) use "dhcpv6".
prefix_delegationstringno"""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_sizeintegerno0DHCPv6-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_preferencestringno"""auto" or "manual" for IPv6 DNS. Empty leaves it unchanged.
wan_namestringno""Display name of the WAN to target (e.g. "Internet 1"). Required only on multi-WAN gateways; single-WAN gateways match automatically.
controllerstringno”default”Name of the UniFi controller to target. Defaults to "default".
dry_runbooleannofalsePreview the before/after diff without applying it.