The unifi.StaticRoute resource manages static routes on UniFi Security Gateways (USG) and UniFi Dream Machines (UDM/UDM-Pro).
Static routes allow you to manually configure routing paths for specific networks. This is useful for:
- Connecting to networks not directly connected to your UniFi gateway
- Creating backup routes for redundancy
- Implementing policy-based routing
- Blocking traffic to specific networks using blackhole routes
Routes can be configured to use either a next-hop IP address, a specific interface, or as a blackhole route.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as unifi from "@pulumiverse/unifi";
const nexthop = new unifi.StaticRoute("nexthop", {
type: "nexthop-route",
network: "172.17.0.0/16",
name: "basic nexthop",
distance: 1,
nextHop: "172.16.0.1",
});
const blackhole = new unifi.StaticRoute("blackhole", {
type: "blackhole",
network: blackholeCidr,
name: "blackhole traffice to cidr",
distance: 1,
});
const _interface = new unifi.StaticRoute("interface", {
type: "interface-route",
network: wan2Cidr,
name: "send traffic over wan2",
distance: 1,
"interface": "WAN2",
});
import pulumi
import pulumiverse_unifi as unifi
nexthop = unifi.StaticRoute("nexthop",
type="nexthop-route",
network="172.17.0.0/16",
name="basic nexthop",
distance=1,
next_hop="172.16.0.1")
blackhole = unifi.StaticRoute("blackhole",
type="blackhole",
network=blackhole_cidr,
name="blackhole traffice to cidr",
distance=1)
interface = unifi.StaticRoute("interface",
type="interface-route",
network=wan2_cidr,
name="send traffic over wan2",
distance=1,
interface="WAN2")
package main
import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumiverse/pulumi-unifi/sdk/go/unifi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := unifi.NewStaticRoute(ctx, "nexthop", &unifi.StaticRouteArgs{
Type: pulumi.String("nexthop-route"),
Network: pulumi.String("172.17.0.0/16"),
Name: pulumi.String("basic nexthop"),
Distance: pulumi.Int(1),
NextHop: pulumi.String("172.16.0.1"),
})
if err != nil {
return err
}
_, err = unifi.NewStaticRoute(ctx, "blackhole", &unifi.StaticRouteArgs{
Type: pulumi.String("blackhole"),
Network: pulumi.Any(blackholeCidr),
Name: pulumi.String("blackhole traffice to cidr"),
Distance: pulumi.Int(1),
})
if err != nil {
return err
}
_, err = unifi.NewStaticRoute(ctx, "interface", &unifi.StaticRouteArgs{
Type: pulumi.String("interface-route"),
Network: pulumi.Any(wan2Cidr),
Name: pulumi.String("send traffic over wan2"),
Distance: pulumi.Int(1),
Interface: pulumi.String("WAN2"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Unifi = Pulumiverse.Unifi;
return await Deployment.RunAsync(() =>
{
var nexthop = new Unifi.StaticRoute("nexthop", new()
{
Type = "nexthop-route",
Network = "172.17.0.0/16",
Name = "basic nexthop",
Distance = 1,
NextHop = "172.16.0.1",
});
var blackhole = new Unifi.StaticRoute("blackhole", new()
{
Type = "blackhole",
Network = blackholeCidr,
Name = "blackhole traffice to cidr",
Distance = 1,
});
var @interface = new Unifi.StaticRoute("interface", new()
{
Type = "interface-route",
Network = wan2Cidr,
Name = "send traffic over wan2",
Distance = 1,
Interface = "WAN2",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumiverse.unifi.StaticRoute;
import com.pulumiverse.unifi.StaticRouteArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var nexthop = new StaticRoute("nexthop", StaticRouteArgs.builder()
.type("nexthop-route")
.network("172.17.0.0/16")
.name("basic nexthop")
.distance(1)
.nextHop("172.16.0.1")
.build());
var blackhole = new StaticRoute("blackhole", StaticRouteArgs.builder()
.type("blackhole")
.network(blackholeCidr)
.name("blackhole traffice to cidr")
.distance(1)
.build());
var interface_ = new StaticRoute("interface", StaticRouteArgs.builder()
.type("interface-route")
.network(wan2Cidr)
.name("send traffic over wan2")
.distance(1)
.interface_("WAN2")
.build());
}
}
resources:
nexthop:
type: unifi:StaticRoute
properties:
type: nexthop-route
network: 172.17.0.0/16
name: basic nexthop
distance: 1
nextHop: 172.16.0.1
blackhole:
type: unifi:StaticRoute
properties:
type: blackhole
network: ${blackholeCidr}
name: blackhole traffice to cidr
distance: 1
interface:
type: unifi:StaticRoute
properties:
type: interface-route
network: ${wan2Cidr}
name: send traffic over wan2
distance: 1
interface: WAN2
Create StaticRoute Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new StaticRoute(name: string, args: StaticRouteArgs, opts?: CustomResourceOptions);@overload
def StaticRoute(resource_name: str,
args: StaticRouteArgs,
opts: Optional[ResourceOptions] = None)
@overload
def StaticRoute(resource_name: str,
opts: Optional[ResourceOptions] = None,
distance: Optional[int] = None,
network: Optional[str] = None,
type: Optional[str] = None,
interface: Optional[str] = None,
name: Optional[str] = None,
next_hop: Optional[str] = None,
site: Optional[str] = None)func NewStaticRoute(ctx *Context, name string, args StaticRouteArgs, opts ...ResourceOption) (*StaticRoute, error)public StaticRoute(string name, StaticRouteArgs args, CustomResourceOptions? opts = null)
public StaticRoute(String name, StaticRouteArgs args)
public StaticRoute(String name, StaticRouteArgs args, CustomResourceOptions options)
type: unifi:StaticRoute
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args StaticRouteArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args StaticRouteArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args StaticRouteArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args StaticRouteArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args StaticRouteArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var staticRouteResource = new Unifi.StaticRoute("staticRouteResource", new()
{
Distance = 0,
Network = "string",
Type = "string",
Interface = "string",
Name = "string",
NextHop = "string",
Site = "string",
});
example, err := unifi.NewStaticRoute(ctx, "staticRouteResource", &unifi.StaticRouteArgs{
Distance: pulumi.Int(0),
Network: pulumi.String("string"),
Type: pulumi.String("string"),
Interface: pulumi.String("string"),
Name: pulumi.String("string"),
NextHop: pulumi.String("string"),
Site: pulumi.String("string"),
})
var staticRouteResource = new StaticRoute("staticRouteResource", StaticRouteArgs.builder()
.distance(0)
.network("string")
.type("string")
.interface_("string")
.name("string")
.nextHop("string")
.site("string")
.build());
static_route_resource = unifi.StaticRoute("staticRouteResource",
distance=0,
network="string",
type="string",
interface="string",
name="string",
next_hop="string",
site="string")
const staticRouteResource = new unifi.StaticRoute("staticRouteResource", {
distance: 0,
network: "string",
type: "string",
"interface": "string",
name: "string",
nextHop: "string",
site: "string",
});
type: unifi:StaticRoute
properties:
distance: 0
interface: string
name: string
network: string
nextHop: string
site: string
type: string
StaticRoute Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The StaticRoute resource accepts the following input properties:
- Distance int
- The administrative distance for this route. Lower values are preferred. Use this to control route selection when multiple routes to the same destination exist.
- Network string
- The destination network in CIDR notation that this route will direct traffic to (e.g., '10.0.0.0/16' or '192.168.100.0/24').
- Type string
- The type of static route. Valid values are:
interface-route- Route traffic through a specific interfacenexthop-route- Route traffic to a specific next-hop IP addressblackhole- Drop all traffic to this network
- Interface string
- The outbound interface to use for this route. Only used when type is set to 'interface-route'. Can be:
WAN1- Primary WAN interfaceWAN2- Secondary WAN interface- A network ID for internal networks
- Name string
- A friendly name for the static route to help identify its purpose (e.g., 'Backup DC Link' or 'Cloud VPN Route').
- Next
Hop string - The IP address of the next hop router for this route. Only used when type is set to 'nexthop-route'. This should be an IP address that is directly reachable from your UniFi gateway.
- Site string
- The name of the UniFi site where the static route should be created. If not specified, the default site will be used.
- Distance int
- The administrative distance for this route. Lower values are preferred. Use this to control route selection when multiple routes to the same destination exist.
- Network string
- The destination network in CIDR notation that this route will direct traffic to (e.g., '10.0.0.0/16' or '192.168.100.0/24').
- Type string
- The type of static route. Valid values are:
interface-route- Route traffic through a specific interfacenexthop-route- Route traffic to a specific next-hop IP addressblackhole- Drop all traffic to this network
- Interface string
- The outbound interface to use for this route. Only used when type is set to 'interface-route'. Can be:
WAN1- Primary WAN interfaceWAN2- Secondary WAN interface- A network ID for internal networks
- Name string
- A friendly name for the static route to help identify its purpose (e.g., 'Backup DC Link' or 'Cloud VPN Route').
- Next
Hop string - The IP address of the next hop router for this route. Only used when type is set to 'nexthop-route'. This should be an IP address that is directly reachable from your UniFi gateway.
- Site string
- The name of the UniFi site where the static route should be created. If not specified, the default site will be used.
- distance Integer
- The administrative distance for this route. Lower values are preferred. Use this to control route selection when multiple routes to the same destination exist.
- network String
- The destination network in CIDR notation that this route will direct traffic to (e.g., '10.0.0.0/16' or '192.168.100.0/24').
- type String
- The type of static route. Valid values are:
interface-route- Route traffic through a specific interfacenexthop-route- Route traffic to a specific next-hop IP addressblackhole- Drop all traffic to this network
- interface_ String
- The outbound interface to use for this route. Only used when type is set to 'interface-route'. Can be:
WAN1- Primary WAN interfaceWAN2- Secondary WAN interface- A network ID for internal networks
- name String
- A friendly name for the static route to help identify its purpose (e.g., 'Backup DC Link' or 'Cloud VPN Route').
- next
Hop String - The IP address of the next hop router for this route. Only used when type is set to 'nexthop-route'. This should be an IP address that is directly reachable from your UniFi gateway.
- site String
- The name of the UniFi site where the static route should be created. If not specified, the default site will be used.
- distance number
- The administrative distance for this route. Lower values are preferred. Use this to control route selection when multiple routes to the same destination exist.
- network string
- The destination network in CIDR notation that this route will direct traffic to (e.g., '10.0.0.0/16' or '192.168.100.0/24').
- type string
- The type of static route. Valid values are:
interface-route- Route traffic through a specific interfacenexthop-route- Route traffic to a specific next-hop IP addressblackhole- Drop all traffic to this network
- interface string
- The outbound interface to use for this route. Only used when type is set to 'interface-route'. Can be:
WAN1- Primary WAN interfaceWAN2- Secondary WAN interface- A network ID for internal networks
- name string
- A friendly name for the static route to help identify its purpose (e.g., 'Backup DC Link' or 'Cloud VPN Route').
- next
Hop string - The IP address of the next hop router for this route. Only used when type is set to 'nexthop-route'. This should be an IP address that is directly reachable from your UniFi gateway.
- site string
- The name of the UniFi site where the static route should be created. If not specified, the default site will be used.
- distance int
- The administrative distance for this route. Lower values are preferred. Use this to control route selection when multiple routes to the same destination exist.
- network str
- The destination network in CIDR notation that this route will direct traffic to (e.g., '10.0.0.0/16' or '192.168.100.0/24').
- type str
- The type of static route. Valid values are:
interface-route- Route traffic through a specific interfacenexthop-route- Route traffic to a specific next-hop IP addressblackhole- Drop all traffic to this network
- interface str
- The outbound interface to use for this route. Only used when type is set to 'interface-route'. Can be:
WAN1- Primary WAN interfaceWAN2- Secondary WAN interface- A network ID for internal networks
- name str
- A friendly name for the static route to help identify its purpose (e.g., 'Backup DC Link' or 'Cloud VPN Route').
- next_
hop str - The IP address of the next hop router for this route. Only used when type is set to 'nexthop-route'. This should be an IP address that is directly reachable from your UniFi gateway.
- site str
- The name of the UniFi site where the static route should be created. If not specified, the default site will be used.
- distance Number
- The administrative distance for this route. Lower values are preferred. Use this to control route selection when multiple routes to the same destination exist.
- network String
- The destination network in CIDR notation that this route will direct traffic to (e.g., '10.0.0.0/16' or '192.168.100.0/24').
- type String
- The type of static route. Valid values are:
interface-route- Route traffic through a specific interfacenexthop-route- Route traffic to a specific next-hop IP addressblackhole- Drop all traffic to this network
- interface String
- The outbound interface to use for this route. Only used when type is set to 'interface-route'. Can be:
WAN1- Primary WAN interfaceWAN2- Secondary WAN interface- A network ID for internal networks
- name String
- A friendly name for the static route to help identify its purpose (e.g., 'Backup DC Link' or 'Cloud VPN Route').
- next
Hop String - The IP address of the next hop router for this route. Only used when type is set to 'nexthop-route'. This should be an IP address that is directly reachable from your UniFi gateway.
- site String
- The name of the UniFi site where the static route should be created. If not specified, the default site will be used.
Outputs
All input properties are implicitly available as output properties. Additionally, the StaticRoute resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing StaticRoute Resource
Get an existing StaticRoute resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: StaticRouteState, opts?: CustomResourceOptions): StaticRoute@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
distance: Optional[int] = None,
interface: Optional[str] = None,
name: Optional[str] = None,
network: Optional[str] = None,
next_hop: Optional[str] = None,
site: Optional[str] = None,
type: Optional[str] = None) -> StaticRoutefunc GetStaticRoute(ctx *Context, name string, id IDInput, state *StaticRouteState, opts ...ResourceOption) (*StaticRoute, error)public static StaticRoute Get(string name, Input<string> id, StaticRouteState? state, CustomResourceOptions? opts = null)public static StaticRoute get(String name, Output<String> id, StaticRouteState state, CustomResourceOptions options)resources: _: type: unifi:StaticRoute get: id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Distance int
- The administrative distance for this route. Lower values are preferred. Use this to control route selection when multiple routes to the same destination exist.
- Interface string
- The outbound interface to use for this route. Only used when type is set to 'interface-route'. Can be:
WAN1- Primary WAN interfaceWAN2- Secondary WAN interface- A network ID for internal networks
- Name string
- A friendly name for the static route to help identify its purpose (e.g., 'Backup DC Link' or 'Cloud VPN Route').
- Network string
- The destination network in CIDR notation that this route will direct traffic to (e.g., '10.0.0.0/16' or '192.168.100.0/24').
- Next
Hop string - The IP address of the next hop router for this route. Only used when type is set to 'nexthop-route'. This should be an IP address that is directly reachable from your UniFi gateway.
- Site string
- The name of the UniFi site where the static route should be created. If not specified, the default site will be used.
- Type string
- The type of static route. Valid values are:
interface-route- Route traffic through a specific interfacenexthop-route- Route traffic to a specific next-hop IP addressblackhole- Drop all traffic to this network
- Distance int
- The administrative distance for this route. Lower values are preferred. Use this to control route selection when multiple routes to the same destination exist.
- Interface string
- The outbound interface to use for this route. Only used when type is set to 'interface-route'. Can be:
WAN1- Primary WAN interfaceWAN2- Secondary WAN interface- A network ID for internal networks
- Name string
- A friendly name for the static route to help identify its purpose (e.g., 'Backup DC Link' or 'Cloud VPN Route').
- Network string
- The destination network in CIDR notation that this route will direct traffic to (e.g., '10.0.0.0/16' or '192.168.100.0/24').
- Next
Hop string - The IP address of the next hop router for this route. Only used when type is set to 'nexthop-route'. This should be an IP address that is directly reachable from your UniFi gateway.
- Site string
- The name of the UniFi site where the static route should be created. If not specified, the default site will be used.
- Type string
- The type of static route. Valid values are:
interface-route- Route traffic through a specific interfacenexthop-route- Route traffic to a specific next-hop IP addressblackhole- Drop all traffic to this network
- distance Integer
- The administrative distance for this route. Lower values are preferred. Use this to control route selection when multiple routes to the same destination exist.
- interface_ String
- The outbound interface to use for this route. Only used when type is set to 'interface-route'. Can be:
WAN1- Primary WAN interfaceWAN2- Secondary WAN interface- A network ID for internal networks
- name String
- A friendly name for the static route to help identify its purpose (e.g., 'Backup DC Link' or 'Cloud VPN Route').
- network String
- The destination network in CIDR notation that this route will direct traffic to (e.g., '10.0.0.0/16' or '192.168.100.0/24').
- next
Hop String - The IP address of the next hop router for this route. Only used when type is set to 'nexthop-route'. This should be an IP address that is directly reachable from your UniFi gateway.
- site String
- The name of the UniFi site where the static route should be created. If not specified, the default site will be used.
- type String
- The type of static route. Valid values are:
interface-route- Route traffic through a specific interfacenexthop-route- Route traffic to a specific next-hop IP addressblackhole- Drop all traffic to this network
- distance number
- The administrative distance for this route. Lower values are preferred. Use this to control route selection when multiple routes to the same destination exist.
- interface string
- The outbound interface to use for this route. Only used when type is set to 'interface-route'. Can be:
WAN1- Primary WAN interfaceWAN2- Secondary WAN interface- A network ID for internal networks
- name string
- A friendly name for the static route to help identify its purpose (e.g., 'Backup DC Link' or 'Cloud VPN Route').
- network string
- The destination network in CIDR notation that this route will direct traffic to (e.g., '10.0.0.0/16' or '192.168.100.0/24').
- next
Hop string - The IP address of the next hop router for this route. Only used when type is set to 'nexthop-route'. This should be an IP address that is directly reachable from your UniFi gateway.
- site string
- The name of the UniFi site where the static route should be created. If not specified, the default site will be used.
- type string
- The type of static route. Valid values are:
interface-route- Route traffic through a specific interfacenexthop-route- Route traffic to a specific next-hop IP addressblackhole- Drop all traffic to this network
- distance int
- The administrative distance for this route. Lower values are preferred. Use this to control route selection when multiple routes to the same destination exist.
- interface str
- The outbound interface to use for this route. Only used when type is set to 'interface-route'. Can be:
WAN1- Primary WAN interfaceWAN2- Secondary WAN interface- A network ID for internal networks
- name str
- A friendly name for the static route to help identify its purpose (e.g., 'Backup DC Link' or 'Cloud VPN Route').
- network str
- The destination network in CIDR notation that this route will direct traffic to (e.g., '10.0.0.0/16' or '192.168.100.0/24').
- next_
hop str - The IP address of the next hop router for this route. Only used when type is set to 'nexthop-route'. This should be an IP address that is directly reachable from your UniFi gateway.
- site str
- The name of the UniFi site where the static route should be created. If not specified, the default site will be used.
- type str
- The type of static route. Valid values are:
interface-route- Route traffic through a specific interfacenexthop-route- Route traffic to a specific next-hop IP addressblackhole- Drop all traffic to this network
- distance Number
- The administrative distance for this route. Lower values are preferred. Use this to control route selection when multiple routes to the same destination exist.
- interface String
- The outbound interface to use for this route. Only used when type is set to 'interface-route'. Can be:
WAN1- Primary WAN interfaceWAN2- Secondary WAN interface- A network ID for internal networks
- name String
- A friendly name for the static route to help identify its purpose (e.g., 'Backup DC Link' or 'Cloud VPN Route').
- network String
- The destination network in CIDR notation that this route will direct traffic to (e.g., '10.0.0.0/16' or '192.168.100.0/24').
- next
Hop String - The IP address of the next hop router for this route. Only used when type is set to 'nexthop-route'. This should be an IP address that is directly reachable from your UniFi gateway.
- site String
- The name of the UniFi site where the static route should be created. If not specified, the default site will be used.
- type String
- The type of static route. Valid values are:
interface-route- Route traffic through a specific interfacenexthop-route- Route traffic to a specific next-hop IP addressblackhole- Drop all traffic to this network
Package Details
- Repository
- unifi pulumiverse/pulumi-unifi
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
unifiTerraform Provider.
