Skip to content

Routing through instances

Route tables that send traffic to your own instances (NAT, VPN and firewall instances), inspection between subnets, partial internet routes and failover.

Updated View as Markdown

Besides the default routes to the Network Gateway, a route table can send traffic to one of your own instances: a NAT instance for a private subnet, a VPN instance to another network, or a firewall instance that inspects traffic between subnets. Routing happens in the network: instances keep sending to their subnet’s .1 (IPv4) and fe80::1 (IPv6), and configure nothing for the tables.

Routes

Destination Target
Any IPv4 or IPv6 prefix outside the VPC’s ranges, 0.0.0.0/0 and ::/0 included The VPC’s Network Gateway (networkGateway, ngw_…), or a private network interface of the VPC (networkInterface, eni_…)
Exactly one of the VPC’s subnets’ ranges (its IPv4 CIDR, or its IPv6 /64) A private network interface of the VPC
ezgh compute route-tables routes set private 0.0.0.0/0 --target eni_7hq2m0x9ka3c
ezgh compute route-tables routes set app-table 10.0.2.0/24 --target eni_4fw1n5p0d2ka

An interface route is active while the interface is attached to an instance, and blackhole when it’s detached or deleted.

Which route applies

For a packet leaving a subnet, by the subnet’s table:

  1. If the destination is in a subnet range the table routes to an interface, it goes to that interface.
  2. Otherwise, if the destination is inside the VPC’s range, it’s local: delivered to the interface that has the address, or dropped if none does. It never goes on to step 3.
  3. Otherwise, the longest matching route decides. With no match, it’s dropped.

Traffic between two addresses of the same subnet never consults the table. A blackhole route drops its traffic; it doesn’t fall through to a shorter route.

The source/destination check

An interface accepts only traffic addressed to it, and sends only traffic from its own addresses: its source/destination check. An instance that forwards traffic (NAT, VPN, firewall) needs it off on the interface routes point at.

Console API CLI
The interface’s Source/destination check switch, confirmed when turned off UpdateNetworkInterface { sourceDestCheck: false } ezgh compute network-interfaces update <interface> --source-dest-check=false
  • Only a private interface can turn it off (400 invalid_request on a public one).
  • Its firewalls still apply to everything it sends and receives.
  • Tightening its firewall stops new forwarded connections and doesn’t end ones already open.
  • A transparent proxy must open its upstream connection from a new source port.
  • With it off, the interface still can’t reach other VPCs, and sends to the internet only from its own public addresses.

Inside the instance, turn on forwarding (net.ipv4.ip_forward=1, net.ipv6.conf.all.forwarding=1).

A NAT instance for a private subnet

A NAT Gateway does this without an instance to run. To run your own instead:

  1. Launch the NAT instance with an interface in a subnet whose table routes 0.0.0.0/0 to the gateway, and give that interface a public IPv4 address.
  2. Turn its interface’s source/destination check off, and set up NAT in the guest (for example, nftables masquerade on that interface).
  3. In the private subnets’ table, route 0.0.0.0/0 to that interface.

Traffic from the private subnets then reaches the internet from the NAT instance’s address, and nothing on the internet can reach them.

Inspecting traffic between subnets

To send traffic between subnets app (10.0.1.0/24) and db (10.0.2.0/24) through a firewall instance in subnet inspect, route each direction through it, so replies take the same path:

Table Associated with Route
app-table app 10.0.2.0/24 → the firewall’s interface
db-table db 10.0.1.0/24 → the firewall’s interface

The inspect subnet stays on a table without those routes: a table can’t route the range of a subnet that uses it, or point at an interface in a subnet that uses it (409 route_table_conflict).

Partial internet routes

A gateway route needn’t be a default route: 198.51.100.0/24 to the gateway with 0.0.0.0/0 to a VPN instance sends only that prefix straight to the internet. Any active gateway route in a family lets the subnet’s public addresses in that family receive traffic from anywhere; replies leave only toward destinations a gateway route covers.

Traffic addressed to an instance’s public IPv4 address or public /64 arrives straight at its interface: route tables steer traffic leaving a subnet, not traffic arriving from the internet.

Instances with a public interface too

An instance with a public primary interface and a private one chooses itself which interface a packet leaves by. The route table applies only to what it sends out its private interface.

Failover

To move a route to a standby instance, set it again: one call, which touches no other route.

ezgh compute route-tables routes set private 0.0.0.0/0 --target eni_standby00001

Refusals

Refusal When
409 route_table_conflict A route to the range of a subnet that uses the table, or to an interface in such a subnet; or associating a subnet with a table that does either
409 subnet_routed Deleting a subnet whose range a table of its VPC routes. Remove those routes first
400 invalid_request A destination inside the VPC that isn’t exactly one subnet’s range, or isn’t to an interface; a destination inside 169.254.0.0/16 or fd65:7a67:6800::/48; a public interface, or one of another VPC, as a target
Navigation

Type to search…

↑↓ navigate↵ selectEsc close