Why GCP cannot use a normal network
Builds on32. Hubs, switches and routers9. ARP
Google has to give millions of unrelated customers each their own private network, running on the same shared physical machines, in data centres all over the world. Each customer must feel like they have a data centre of their own, and must never see anyone else's traffic.
The tools from the fundamentals course do not stretch that far:
| # | Normal network tool | Why it fails at Google's size |
|---|---|---|
| 1 | A switch and one broadcast domain per network | Your VMs are spread over hosts in different zones. There is no single cable or switch they could all share |
| 2 | VLANs to keep customers apart | A VLAN ID has 12 bits, so there are only 4,094 usable IDs. Google has far more networks than that |
| 3 | ARP broadcasts and MAC learning | Broadcasts across a whole data centre would flood every host, and switch MAC tables would never be big enough |
| 4 | Firewall and NAT boxes in the path | Every packet would have to pass through a few boxes. They would become the slowest point and a single point of failure |
So the picture you see (two VMs side by side in one subnet) and what is really there are very different:
- Run by Google
- Your VPC
The subnet is not a place. It is a range of addresses and a set of rules, and Google's software makes VMs in it behave as if they were neighbours.
Wide by design - scroll it sideways.
Andromeda: a control plane and a data plane
The software that runs every VPC is called Andromeda. It has two parts, and the split between them explains almost everything in this chapter.
- Run by Google
- Your VPC
- Allowed traffic and replies
Kadé's VMs share hosts with other customers' VMs. The data plane on each host keeps them apart: it only ever hands a VM packets that belong to that VM's own network.
Wide by design - scroll it sideways.
| # | Part | Where it runs | What it knows | What it does |
|---|---|---|---|---|
| 1 | Control plane | Google's own servers, one logical system for the world | Everything: every VM, IP, host, route, firewall rule | Decides; pushes the parts each host needs down to it |
| 2 | Data plane | Every physical host, beside each vNIC | Only what it was given: where each destination IP lives, which rules apply | Acts on every packet: check firewall, look up the destination host, wrap, send |
Compare this with the home router in the fundamentals course. The home router was both at once: it held the routing table and it moved the packets. In GCP the thinking and the moving are split, and the moving is copied onto every host.
Nothing is discovered: it is all known in advance
Builds on27. DHCP9. ARP32. Switch MAC learning
This is the most important idea in the chapter. A normal LAN finds things out while it runs: DHCP hands out a free address, ARP asks who has an IP, and a switch learns which port each MAC is on by watching traffic.
GCP never needs to find anything out. When a VM is created, the control plane decides its IP and its host, and pushes that to every data plane that may need it. So there is no discovery, no flooding and no learning.
| # | Job | Home LAN (fundamentals course) | GCP |
|---|---|---|---|
| 1 | Give a device an IP | DHCP picks a free address from a pool (ch 27) | Control plane picks it when the VM is created. DHCP only delivers it |
| 2 | Find the MAC for an IP | ARP broadcast, the owner replies (ch 9) | The data plane answers the VM itself; nothing is broadcast |
| 3 | Know where a device is | Switch learns MAC → port from traffic (ch 32) | Control plane already knows IP → host |
| 4 | Decide if traffic is allowed | One firewall box at the edge | Rules loaded into the data plane beside every VM |
| 5 | Share one public IP | NAT on the home router (ch 10) | 1:1 NAT done by the data plane on the VM's host |
Follow one packet: kade-api-1 to kade-db
Builds on1. The envelopes8. MAC vs IP
kade-api-1 (zone a) runs a SQL query on kade-db (zone b). Step through what happens. Watch which parts change and which never do.
1 · The app sends
The Node app writes the query to its database socket. The kernel builds an IP packet. The destination is not inside the VM's /32, so the route table says: send it to the gateway.
- Inner packet (TCP)
- 10.10.1.10:41822 → 10.10.2.5:5432
- Route chosen
- default via 10.10.1.1
Two things to take from this. First, the packet your VM builds (source 10.10.1.10, destination 10.10.2.5) arrives exactly as it was sent. Google puts it inside its own outer envelope to cross the physical network, then takes it back out. The VMs never see that envelope. Second, the MAC addresses in the frame are only there because the guest OS expects them. The data plane throws them away and routes on the IP.
kade-api-1 and kade-db are in different subnets, yet no step in the walk is a router hop. Between two subnets of one VPC the path is exactly the same as inside one subnet: the data plane on kade-api-1's host matches the subnet route and sends the packet straight to the host running kade-db. The only differences are which subnet route matched and which firewall rules apply (chapter 5.1).
What the VM sees: a /32 and one gateway
Builds on4. Subnet masks5. The default gateway
In the fundamentals course, the subnet mask decided everything: same network, send directly; different network, send to the gateway. GCP uses that same rule to switch direct sending off.
On Linux, DHCP gives the VM a /32 mask. A /32 network holds exactly one address, the VM itself. So to the VM, every other address is on a different network, even kade-api-2 in the same subnet. Everything goes to the gateway 10.10.1.1, and the only MAC the VM ever needs is the gateway's.
That gateway is not a machine. There is no router behind 10.10.1.1: it is an address the data plane on every host answers for (section 02). You cannot log in to it or find it in any list of resources. The VM's own route table stays simple, "send everything to .1", and the real decision is made by the VPC's route table (chapter 4).
Two things GCP fakes: ARP and DHCP
The VM runs an ordinary operating system that expects an ordinary Ethernet network. Instead of changing every OS, Google lets the guest do what it always does, and the data plane quietly answers.
ARP
The VM asks "who has 10.10.1.1?". The request never leaves the host. The data plane replies with a MAC (42:01:0a:0a:01:01), the VM builds its frame with it, and the data plane throws the MAC away and routes on the IP. Because no other VM ever hears an ARP request, one VM cannot answer for another. ARP spoofing, from the Fundamentals ch 9, cannot work here.
DHCP
The VM boots and runs a normal DHCP client. The answer comes from the metadata server (section 07), but there is no pool to choose from: the address was fixed by the control plane when the network card was created. DHCP is only the delivery van for a decision already made. That is why the lease always renews to the same address.
| # | DHCP delivers | Value for kade-api-1 | Why it matters |
|---|---|---|---|
| 1 | IP address and mask | 10.10.1.10/32 | Always the same; set by the control plane |
| 2 | Gateway and routes | 10.10.1.1, plus the scope-link route to it | Section 05 |
| 3 | DNS server | 169.254.169.254 | Internal names like kade-db.asia-southeast1-b.c.kade-prod.internal (chapter 8) |
| 4 | MTU | 1460 | The VPC's MTU, the same on every VM (section 08) |
| 5 | Host name and search domains | kade-api-1, c.kade-prod.internal, … | Short names work inside the VPC |
The metadata server: 169.254.169.254
Builds on2. Link-local addresses
Every VM can reach 169.254.169.254, also known by the name metadata.google.internal. It is a link-local address: it is never routed anywhere, and the answer comes from Google's software for that VM, not from a machine out on the network. It does several jobs:
| # | Job | What the VM gets | Chapter |
|---|---|---|---|
| 1 | DHCP server | IP, routes, MTU, DNS server (section 06) | 1 |
| 2 | DNS resolver | Internal VM names, private zones, and normal internet names | 8 |
| 3 | Time (NTP) | Clock sync, as in the Fundamentals ch 27 | - |
| 4 | Instance metadata | Its own name, zone, IPs, tags, startup scripts | 3 |
| 5 | Access tokens | Short-lived tokens for the VM's service account | 5 |
MTU: 1460, set on the whole VPC
Builds on18. MTU, MSS and fragmentation
In the fundamentals course, the MTU was a property of each link, usually 1500 on Ethernet. In GCP there are no links you manage, so the MTU is a setting on the VPC network. Every VM in kade-vpc gets the same value through DHCP.
The default is 1460, 40 bytes less than normal Ethernet. Google's own outer envelope (section 04) is added underneath your MTU, so it never eats into your 1460. So a full TCP segment inside kade-vpc carries:
1460 MTU − 20 IP − 20 TCP = 1420 MSS
Two ways MTU goes wrong in practice:
| # | Mistake | What you see | Chapter |
|---|---|---|---|
| 1 | Someone hardcodes mtu 1500 inside a VM's OS while the VPC is 1460 | Small requests work; large responses or file copies hang. The same black hole as Fundamentals ch 18 | 1 |
| 2 | A VPN adds its own headers on top of 1460 | The same symptom across the VPN, unless MSS is lowered | 15 |
The firewall and external IPs live in the data plane too
Builds on10. NAT16. TCP connections
Because the data plane sits beside every VM, jobs that normally need a box in the middle are done there instead:
| # | Job | How GCP does it | What follows from that |
|---|---|---|---|
| 1 | Firewall | Rules are loaded into the data plane of every host. Outgoing (egress) rules are checked beside the sending VM, incoming (ingress) rules beside the receiving VM | No firewall box to size or to fail. A packet blocked by an egress rule never leaves the host. The firewall scales with the number of VMs |
| 2 | Stateful firewall | The data plane remembers each allowed connection, like the NAT table in the fundamentals course | Replies to an allowed connection come back in without needing their own rule (chapter 5) |
| 3 | External IP | 1:1 NAT on the VM's host: the external IP is swapped for the internal IP on the way in, and back on the way out | The VM's OS never sees its external IP. ip addr shows only the internal one (chapter 3) |
| 4 | Changes | A new or edited rule must reach every data plane it affects | Changes take effect within seconds, not at once. After a change, wait a moment before testing |
What you lose without layer 2, and what to use instead
A VPC is a layer 3 network: everything is routing, nothing is switching. Most apps never notice. Some things do:
| # | Missing | What breaks | Use instead |
|---|---|---|---|
| 1 | Broadcast and multicast | Anything that finds peers by broadcasting, such as some cluster discovery. It fails silently | A fixed list of peers, DNS, or a discovery service |
| 2 | VLANs | Nothing to configure; there are no tags | Separate subnets, firewall rules, or separate VPCs |
| 3 | Promiscuous mode | You cannot sniff other VMs' traffic; you only ever get your own packets | VPC Flow Logs or Packet Mirroring (chapter 16) |
| 4 | Gratuitous ARP (used by VRRP, HSRP, CARP, keepalived) | Moving a "floating IP" between two VMs by announcing it. The data plane ignores what the guest claims | An internal load balancer with health checks, or move an alias IP range through GCP (chapter 3) |
| 5 | Meaningful MAC addresses | Licences or tools tied to a MAC. Nothing routes on MACs here | Tie things to the VM name or IP instead |
| 6 | A real layer 2 segment | Old clustering software or appliances that truly need one | Tunnel layer 2 over layer 3 (VXLAN or GRE) inside the VPC |
Some of these losses are also protections. Rogue DHCP servers and ARP spoofing are impossible, because no other VM ever hears the request.
Back to Kadé
Commands in this chapter
All read-only. Commands 2 to 6 run inside the VM after command 1.
Log in to a VM
- What it shows: Opens an SSH session on kade-api-1 through IAP, without an external IP.
- What to look for: If it fails, the firewall or IAM is blocking IAP. Chapter 6 covers both.
gcloud compute ssh kade-api-1 --zone=asia-southeast1-a --tunnel-through-iapSee the VM's address and MTU
- What it shows: The IP, mask and MTU the VM got from DHCP.
- What to look for:
/32on Linux, andmtumatching the VPC's MTU.
ip -4 addr show ens4See the VM's routes
- What it shows: Where the VM sends traffic.
- What to look for: A
scope linkroute to10.10.1.1and a default route via it. No route for the rest of the subnet.
ip routeSee the VM's ARP table
- What it shows: Every IP the VM has resolved to a MAC.
- What to look for: Only the gateway, with a MAC starting
42:01, even after talking to other VMs.
ip neighAsk the metadata server a question
- What it shows: The zone the VM runs in, straight from the metadata server.
- What to look for: A path with the project number. Try it without the header and see the refusal.
curl -s -H "Metadata-Flavor: Google" \ http://metadata.google.internal/computeMetadata/v1/instance/zoneTest the MTU from inside the VPC
- What it shows: Whether a full-size packet reaches kade-db without being split. 1432 bytes of data plus 28 bytes of headers is exactly 1460.
- What to look for: 1432 works; 1433 fails with "message too long". That confirms the path MTU is 1460.
ping -c 3 -M do -s 1432 10.10.2.5ping -c 3 -M do -s 1433 10.10.2.5Read the VPC's MTU from outside
- What it shows: The MTU set on kade-vpc.
- What to look for:
1460, matching what the VM reported in command 2.
gcloud compute networks describe kade-vpc --format="value(mtu)"