Skip to content

create_port_forward

Create a port-forward (DNAT) rule on the WAN.

Side effects:

  • Adds a NAT rule that exposes the internal host fwd:fwd_port to the WAN on dst_port. The service is reachable from the public internet (subject to src restriction).
  • Takes effect immediately on the next inbound packet.
  • Mutates controller state. Use dry_run=True to preview the change without applying.
create_port_forward(name="plex", fwd="10.50.0.10", fwd_port="32400", dst_port="32400", proto="tcp")
ParameterTypeRequiredDefaultDescription
namestringyesDisplay name for the rule.
fwdstringyesInternal IP to forward to (e.g. "10.50.0.10").
fwd_portstringyesInternal port (string; UniFi accepts ranges like "8000-8010").
dst_portstringyesExternal / WAN port to listen on.
protostringno”tcp”"tcp", "udp", or "tcp_udp".
srcstringno”any”Source restriction. "any" (default) or a CIDR.
enabledbooleannotrueTrue enables the rule immediately.
logbooleannofalseTrue logs forwarded packets.
controllerstringno”default”Name of the UniFi controller to target. Defaults to "default".
dry_runbooleannofalsePreview the change without applying it. Returns the predicted change set.