Skip to content

create_route

Create a static next-hop route.

Side effects:

  • Adds a destination-based route: traffic to destination is sent to next_hop instead of following the default route. Takes effect immediately on the gateway’s routing table.
  • Mutates controller state. Use dry_run=True to preview the change without applying.

BLAST RADIUS: a static route changes where traffic for the destination prefix is sent. A wrong next-hop can black-hole that prefix. It does not affect traffic outside destination.

create_route(name="Lab via firewall", destination="10.99.0.0/24", next_hop="192.168.1.254")
Parameter Type Required Default Description
name string yes Display name for the route (e.g. "Lab via firewall").
destination string yes Destination network in CIDR form ("10.99.0.0/24"). This is the prefix the route matches.
next_hop string yes Next-hop gateway IP that traffic to destination is forwarded to (must be reachable on a directly-connected network).
distance integer no 1 Administrative distance (1-255). Lower wins when two routes match the same destination. Defaults to 1.
enabled boolean no true False creates the route disabled for staging.
controller string no “default” Name of the UniFi controller to target. Defaults to "default".
dry_run boolean no false Preview the change without applying it. Returns the predicted change set.