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")
ParameterTypeRequiredDefaultDescription
namestringyesDisplay name for the route (e.g. "Lab via firewall").
destinationstringyesDestination network in CIDR form ("10.99.0.0/24"). This is the prefix the route matches.
next_hopstringyesNext-hop gateway IP that traffic to destination is forwarded to (must be reachable on a directly-connected network).
distanceintegerno1Administrative distance (1-255). Lower wins when two routes match the same destination. Defaults to 1.
enabledbooleannotrueFalse creates the route disabled for staging.
controllerstringno”default”Name of the UniFi controller to target. Defaults to "default".
dry_runbooleannofalsePreview the change without applying it. Returns the predicted change set.