On this page
Routers
Routers connect your private networks to each other and to the internet. Attach a router to a subnet to give its instances outbound access and reachable addresses.
A router is the hinge of your topology. Give it an external gateway and it becomes the door to the internet; add an interface on a subnet and every instance there can route outbound through it. The same router can carry interfaces on several subnets so they route between each other.
Routers are also where floating IPs become useful: inbound traffic to a floating IP is delivered through the router's external gateway to the instance behind it. Static routes let you steer specific destinations toward another next hop when the default path is not what you want.
Key concepts
External gateway — The router's connection to an external (public) network, enabling outbound internet and floating IPs.
Interface — A connection from the router into one of your subnets so that subnet can be routed.
Static route — A manual rule sending traffic for a given destination CIDR to a specific next hop.
SNAT — Source address translation the gateway applies so private instances can reach the internet outbound.
Before you start
- At least one network and subnet to route.
- An external network available as a gateway (listed under external gateways).
Step by step
- Open Routers
Go to Networking and open Routers.
Screenshot — The Routers list with the Create router buttonThe Routers list with the Create router button - Create the router
Create a router and set its external gateway to an available external network so it can reach the internet.
Screenshot — The Create router form with the external gateway selectorThe Create router form with the external gateway selector - Add subnet interfaces
Add an interface on each subnet that needs routing. Instances on those subnets then get outbound access.
Screenshot — The add-interface dialog listing subnetsThe add-interface dialog listing subnets - Add static routes (optional)
If some traffic must take a non-default path, add a static route with a destination CIDR and a next-hop address.
- Assign floating IPs
For inbound access, allocate a floating IP and associate it with an instance behind this router. See Floating IPs.
Examples
patrii router create --name edge-router \ --external-network public --subnet app-tier-a # attach another subnet later patrii router attach <router-id> --subnet <subnet-id>
patrii router add-route <router-id> \ --destination 192.168.50.0/24 --nexthop 10.10.0.5
data "patrii_network" "public" {
name = "public"
}
resource "patrii_router" "edge" {
name = "edge-router"
external_network_id = data.patrii_network.public.id
}
resource "patrii_router_interface" "app" {
router_id = patrii_router.edge.id
subnet_id = patrii_subnet.app.id
}
resource "patrii_router_static_route" "branch" {
router_id = patrii_router.edge.id
destination = "192.168.50.0/24"
nexthop = "10.10.0.5"
}Limits & specifications
What a router lets you do:
| Action | Effect |
|---|---|
Set external gateway | Connects the router to an external network for outbound internet and floating IPs. |
Add interface | Routes a subnet through the router. |
Add static route | Sends a destination CIDR to a chosen next hop. |
Remove external gateway | Cuts the router off from the external network. |
Best practices
- Give a router an external gateway only when a subnet behind it truly needs internet access.
- Keep purely internal subnets off any router that has an external gateway.
- Document static routes; a forgotten route is a common cause of traffic taking a surprising path.
- Remove router interfaces before deleting a router, or the delete will be blocked while interfaces remain.
FAQ
Why can't I delete my router?
Do I need one router per network?
My instances have outbound internet but can't be reached inbound. Why?
Learn more
Everything you can do here in the console is also available through the Patrii Cloud API for automation and scripting.