One route table for the whole VPC
Builds on5. The default gateway12. Routing tables and longest prefix match
A route is a destination range plus a next hop: "packets for this range go there". That part is the same as the fundamentals course. What is different is where the table lives and how you limit it:
| # | Home router (fundamentals course) | AWS VPC | GCP VPC | |
|---|---|---|---|---|
| 1 | Where the table lives | In the router box | Several route tables, each attached to subnets | One table for the whole VPC, copied to every host's data plane |
| 2 | How to make a route apply to only some machines | Separate router or VLAN | Attach a different table to their subnet | Network tags on the route and on the VMs |
| 3 | "Public" vs "private" subnets | - | Which table the subnet uses | Not a subnet idea at all: done with tags, external IPs and Cloud NAT |
| 4 | Who creates most routes | You, or DHCP | You | GCP, automatically |
- Your VPC
- Allowed traffic and replies
- Firewall and access rules
There is only one table. A tag on a route does not create a second table; it only decides which VMs the route is a candidate for.
Wide by design - scroll it sideways.
That one table lives in the control plane (chapter 1.2). When you add a route, the control plane records it and pushes it to the data plane on every host that runs a kade-vpc VM, in every region. No VM asks a router where to send a packet: its host already holds the whole table. That is also why a change takes a few seconds to reach every host (section 09).
Kadé's route table today
So why can't kade-api reach PayGate (finding 5) if there is a default route? Because a route is only half of the answer. The default internet gateway only accepts traffic from a VM with an external IP, or traffic handled by Cloud NAT. kade-api has neither. The route exists; nothing can use it yet. Chapter 7 fixes that.
The route types
System-generated routes
| # | Route | What it does | Can you change it? |
|---|---|---|---|
| 1 | Subnet route | One per subnet range (primary, secondary, IPv6). Sends that range inside the VPC. Appears when a subnet is created or expanded, disappears when it is deleted | no never edited, and cannot be overridden |
| 2 | Default route | 0.0.0.0/0 to the default internet gateway, priority 1000. Created with the network | yes it is an ordinary static route and can be deleted (section 08) |
Static routes (custom routes you create)
You give a destination, a next hop, a priority, and optionally tags. The next hop can be:
| # | Next hop | Sends matching traffic to | Kadé's use |
|---|---|---|---|
| 1 | default-internet-gateway | The internet (a second internet route, often tag-scoped or for a specific range) | Routes to Google API ranges (chapter 9) |
| 2 | An instance (--next-hop-instance) | A VM acting as a router, proxy or appliance. It needs IP forwarding on (chapter 3) | The scenarios in section 06 |
| 3 | An internal IP (--next-hop-address) | The VM that holds that primary internal IP | Same as above, by address |
| 4 | An internal passthrough Network Load Balancer (--next-hop-ilb) | A group of appliance VMs behind a load balancer, with health checks | An HA version of the proxy |
| 5 | A Classic VPN tunnel (--next-hop-vpn-tunnel) | Another network across a Classic VPN | Not used: HA VPN uses dynamic routes |
Dynamic routes
Learned over BGP by a Cloud Router, not typed in. On a VPN or Interconnect, the Cloud Router tells the other side about Kadé's ranges and installs the ranges the other side advertises. When a tunnel goes down, its routes are removed automatically. The VPC's dynamic routing mode (regional or global, chapter 2 section 01) decides whether those routes apply in one region or all of them. This is chapter 15's topic; Kadé's Cloud Router in chapter 7 exists only to run Cloud NAT and learns nothing.
Policy-based routes
A newer, more specialised type. A policy-based route can match on source range, destination range and protocol (not port), and its next hop must be an internal passthrough Network Load Balancer, usually a group of firewall appliances. It is checked before subnet routes, so it is the one tool that can send even VM-to-VM traffic through an appliance. Kadé does not need it.
Special routing paths (hidden)
Some traffic uses paths that are not in your route table at all. You cannot see, delete or override them; only firewall rules can block them.
| # | Range | Used by | Chapter |
|---|---|---|---|
| 1 | 35.191.0.0/16, 130.211.0.0/22 | Google Front Ends and health checks talking to your backends | 11, 12 |
| 2 | 35.235.240.0/20 | IAP TCP forwarding (SSH through IAP) | 6 |
| 3 | 35.199.192.0/19 | Cloud DNS forwarding and alternative name servers | 8 |
| 4 | 35.199.224.0/19 | Serverless VPC Access connectors | 10 |
How GCP picks a route
When a packet leaves a VM, GCP gathers every route that applies to that VM and contains the destination, then removes candidates step by step until one is left. The full list in Google's docs has twelve steps, many about peering and Network Connectivity Center. For a single VPC it comes down to this:
| # | Step | What happens |
|---|---|---|
| 1 | Special paths | If the destination is one of the hidden paths in section 03, use it. Done |
| 2 | Policy-based routes | If one matches (by priority only), use it. Done |
| 3 | Subnet routes | If the destination is inside any subnet range, use the subnet route. Done. Nothing can beat a subnet route |
| 4 | Applicable routes | Keep static and dynamic routes that contain the destination and apply to this VM (no tags, or a tag the VM has) |
| 5 | Longest prefix | Keep only the most specific destination. Priority is not looked at yet |
| 6 | Usable next hops | Drop routes whose next hop VM is stopped or deleted, or whose tunnel is down |
| 7 | Lowest priority number | Keep only routes with the lowest number (0 to 65535, like firewall rules) |
| 8 | Next hop preference | Instance and Classic VPN next hops beat dynamic routes, which beat an internal load balancer next hop, which beats the internet gateway |
| 9 | Send | One route left: send. Several left: share traffic between them (ECMP). None left: drop, with an ICMP "network unreachable" |
Route selection, example by example
Each tab is one packet and every route that could carry it. The strip at the top is the selection order from section 04, with the number of routes still in the running under each step. The marked step is the one that decided. Faded rows show the step that removed them and why. Some examples have a "what if" button that changes one thing.
Packet from kade-api-1 (no tags) → 172.16.2.11 · warehouse scanner
Steps 1-2: no special path, no policy-based route
- step 3subnet route?3 left
- step 4applicable3 left
- step 5longest prefixdecides here
- step 6next hop alivenot needed
- step 7lowest prioritynot needed
- step 8next hop typenot needed
- step 9send or ECMPnot needed
| Destination | Specificity | Priority | Next hop | Tags | Result |
|---|---|---|---|---|---|
| 0.0.0.0/0 | /0 | 1000 | GWinternet gw | no tags | out at step 5less specific than /24 |
| 172.16.0.0/16 | /16 | 1000 | VPNvpn tunnel-a | no tags | out at step 5less specific than /24 |
| 172.16.2.0/24 | /24 | 1000 | VPNvpn tunnel-b | no tags | Wins→ vpn tunnel-b |
Which ranges contain 172.16.2.11? The inner box is more specific.
0.0.0.0/0 · prio 1000
172.16.0.0/16 · prio 1000
172.16.2.0/24 · prio 1000 ← winner
172.16.2.11
Every box contains the packet. The innermost box is the most specific route. It wins at step 5, whatever the priorities say.
All three routes contain the destination. Step 5 keeps only the /24, so the other two are gone before anyone looks at priority.
Show as config
Packet from kade-api-1 to 172.16.2.11 (warehouse scanner) candidates: 0.0.0.0/0 prio 1000 → default-internet-gateway least specific 172.16.0.0/16 prio 1000 → vpn tunnel-a 172.16.2.0/24 prio 1000 → vpn tunnel-b most specific → WINS
Tag-scoped routes: patterns
With one table per VPC, tags are the only way to make a route apply to some VMs and not others. A route with tags applies only to VMs that have at least one of them; a route with no tags applies to every VM. Tags decide which routes are candidates for a VM. The winner is still picked by the steps in section 04.
Six common patterns follow. Pick a scenario, then a VM, and watch which route its packet gets. The "what if" buttons stop a next hop or remove a tag; that is where most of these patterns surprise people.
Goal: kade-worker's internet traffic goes through kade-proxy; every other VM goes direct.
kade-worker → 8.8.8.8: kade-proxy. Both apply; priority 900 beats 1000.
The tag decides who sees route 2; priority picks the winner. Only kade-worker has both routes, and 900 beats 1000. kade-proxy needs IP forwarding on (chapter 3) and its own way out: an external IP or Cloud NAT.
Show as config
Route 1: 0.0.0.0/0 → default-internet-gateway prio 1000 no tags (all VMs) Route 2: 0.0.0.0/0 → instance kade-proxy prio 900 tags: [via-proxy] kade-worker (via-proxy): both apply, both /0 → 900 beats 1000 → kade-proxy kade-api-1 (no such tag): route 2 does not apply → route 1 → direct
| # | Scenario | Goal | The lesson |
|---|---|---|---|
| A | Some VMs through a proxy | kade-worker's internet traffic goes through kade-proxy | A tagged route with a lower priority number wins, but only for tagged VMs. If kade-proxy stops, traffic goes direct |
| B | No internet for some VMs | kade-db never reaches the internet | Delete the untagged default route and add it back with a tag. No route means no path, but every VM that needs the internet must carry the tag |
| C | A blackhole VM | kade-db's traffic is sent to a VM that drops it | It leaks when the VM stops: the default route has the same destination and takes over. Use B or a firewall rule |
| D | Only some destinations | Only kade-worker's PayGate calls go through kade-inspect | Specificity does the work; the tag only limits who sees the route. If kade-inspect stops, PayGate calls are dropped |
| E | A tagged pair of VPN tunnels | Tagged VMs send everything to the office over two tunnels | Equal routes share connections (ECMP). One tunnel down, the other carries everything |
| F | A VM with two tags | kade-worker has via-proxy and inspected | Tags decide which routes are candidates; the normal rules still pick the winner |
Three things the widget does not show. kade-proxy, kade-inspect and blackhole-vm need IP forwarding on (chapter 3), and the first two need their own way out: an external IP or Cloud NAT. Cloud NAT only works for VMs that can see a default route to the internet gateway (section 08), which matters in Scenario B. And HA VPN uses dynamic routes from BGP, which cannot carry tags, so Scenario E works only with Classic VPN (chapter 15).
Try it: which route wins?
This route table is a lab version of kade-vpc with every route from sections 05 and 06 in it. Give the sending VM the via-proxy or inspected tag to bring the tagged routes into play, choose a destination, and switch next hops off to see what takes over. Try 35.191.4.7 too: a packet to a special path never reaches the table at all.
Tags on the sending VM
Next hops that are down
kade-paygate wins at step 5: 192.0.2.0/24 → instance kade-inspect.
- step 1special path?8 left
- step 2policy route?8 left
- step 3subnet route?6 left
- step 4applicable2 left
- step 5longest prefixdecides here
- step 6next hop alivenot needed
- step 7lowest prioritynot needed
- step 8next hop typenot needed
- step 9send or ECMPnot needed
| Destination | Specificity | Priority | Next hop | Tags | Result |
|---|---|---|---|---|---|
| 10.10.1.0/24 | /24 | - | SUBNETinside kade-vpc | no tags | out at step 3destination is outside this subnet |
| 10.10.2.0/24 | /24 | - | SUBNETinside kade-vpc | no tags | out at step 3destination is outside this subnet |
| 0.0.0.0/0 | /0 | 1000 | GWinternet gw | no tags | out at step 5less specific than /24 |
| 0.0.0.0/0 | /0 | 900 | VMkade-proxy | via-proxy | out at step 4VM lacks tag via-proxy |
| 192.0.2.0/24 | /24 | 1000 | VMkade-inspect | inspected | Wins→ instance kade-inspect |
| 172.16.0.0/16 | /16 | 1000 | VPNvpn tunnel-a | no tags | out at step 4does not contain the destination |
| 172.16.0.0/16 | /16 | 1000 | VPNvpn tunnel-b | no tags | out at step 4does not contain the destination |
| 172.16.2.0/24 | /24 | 1000 | VPNvpn tunnel-b | no tags | out at step 4does not contain the destination |
Deleting the default route
The default route is only a static route, so it can be deleted. People do this to "make sure nothing can reach the internet". Before doing it, know what depends on it:
| # | Feature | Without a route to default-internet-gateway | Chapter |
|---|---|---|---|
| 1 | VMs with external IPs | breaks no outgoing path to the internet | 3 |
| 2 | Cloud NAT | breaks public Cloud NAT always needs a route to the internet gateway | 7 |
| 3 | Private Google Access with the normal API addresses | breaks unless you add routes for the Google API ranges | 9 |
| 4 | Traffic inside the VPC | works subnet routes are separate | 4 |
| 5 | Load balancer and health checks, IAP, Cloud DNS forwarding | works special paths do not use the route table | 6, 8, 11 |
| 6 | External passthrough Network Load Balancer backends | works they have their own special path | 11 |
Things to know before changing routes
| # | Fact | What it means in practice |
|---|---|---|
| 1 | Static routes cannot be edited | To change one, create the new route first, check it, then delete the old one |
| 2 | Changes spread out over a few seconds | Route changes reach every data plane "eventually". Several changes sent together may apply in any order |
| 3 | An instance next hop needs IP forwarding | Without canIpForward the VM drops forwarded packets (chapter 3) |
| 4 | GCP does not check the appliance | It only checks the next hop VM is running, not that its software works. Use an internal load balancer next hop with health checks for anything important |
| 5 | A route is not permission | The firewall still decides whether the packet is allowed (chapter 5) |
| 6 | Auto mode networks | Do not create static routes inside 10.128.0.0/9; a new region's subnet can disable them |
Routes and geography
A route belongs to kade-vpc, so it is global: one route applies to matching VMs in every region. What it points at is not always global. The next hop has a scope of its own (chapter 1.1), and that decides what a zone failure does to the route.
- Google's: the control plane, regions, zones and data planes
- The proxy route and the VMs it applies to
Every host holds the route, but the route leads to one VM in one zone. A tagged VM in another region crosses regions to reach it.
Wide by design - scroll it sideways.
| # | Piece | Scope | If a zone fails |
|---|---|---|---|
| 1 | A route, of any type | Global | Nothing happens to it. It lives in the control plane and on every host, not in one zone |
| 2 | Next hop: the default internet gateway | Global | Nothing to fail on Kadé's side |
| 3 | Next hop: an instance, such as kade-proxy | Zonal | If zone a fails, the path through kade-proxy fails with it |
| 4 | Next hop: an internal passthrough Network Load Balancer | Regional | Backends in two zones and health checks keep the path up |
| 5 | Cloud Router and its dynamic routes | Regional | The routing mode decides whether its learned routes apply in its own region only or in every region (section 03) |
Two rules follow:
- One next hop VM is one zone. For anything that matters, use a load balancer next hop (row 4), the same lesson as chapter 1.1's outage.
- Keep the next hop near the traffic. A tagged VM in asia-south1 would send its internet traffic to Singapore and only then out: slower, and billed as traffic between regions (chapter 1.1). One proxy per region, each with its own tag, avoids the detour.
Back to Kadé
Commands in this chapter
Commands 1 to 3 are read-only. Commands 4 and 5 change the project and are shown for the scenarios, not for Kadé today.
List routes in a network
- What it shows: Every route in kade-vpc: destination, next hop and priority.
- What to look for: One subnet route per subnet, the default route, and any custom route you do not recognise.
gcloud compute routes list --filter="network~kade-vpc"Show custom routes with their tags
- What it shows: Routes with the tags that limit them. Subnet routes have no tags.
- What to look for: A tagged route, and whether the VMs that should carry the tag actually do.
gcloud compute routes list --filter="network~kade-vpc" \ --format="table(name,destRange,nextHopGateway.basename(),nextHopInstance.basename(),priority,tags.list())"See a VM's tags
- What it shows: The network tags on one VM, which decide which tagged routes (and firewall rules) apply to it.
- What to look for: A missing or misspelled tag. Tags are case-sensitive and silently match nothing when wrong.
gcloud compute instances describe kade-worker --zone=asia-southeast1-a \ --format="value(tags.items)"Create a tag-scoped route (changes the project)
- What it shows: Scenario A: VMs tagged
via-proxysend internet traffic to kade-proxy. - What to look for: The route in command 2 with its tag. Check with the Console's Effective routes view for kade-worker before relying on it.
gcloud compute routes create kade-via-proxy \ --network=kade-vpc --destination-range=0.0.0.0/0 --priority=900 \ --next-hop-instance=kade-proxy --next-hop-instance-zone=asia-southeast1-a \ --tags=via-proxyAdd or remove a tag on a VM (changes the project)
- What it shows: Puts kade-worker under the tagged route, or takes it back out.
- What to look for: The change reaches the data plane within seconds. Tags also affect firewall rules, so check both.
gcloud compute instances add-tags kade-worker --zone=asia-southeast1-a --tags=via-proxygcloud compute instances remove-tags kade-worker --zone=asia-southeast1-a --tags=via-proxy