Routing in Google Cloud Platform

From Luis Gallego Hurtado - Not Another IT guy
Jump to: navigation, search

Routes tell VM instances and VPC network how to send traffic from an instance to destination, either inside the network or outside of GCP.

System-generated routes

Each VPC network comes with some system-generated routes.

Note that each VPC network has an associated dynamic routing mode that controls the behavior of all of its Cloud Routers.

Default route

It is generated by the system and routes all instances ( to Internet through default-internet-gateway. It has very low priority (1000).

It is removable.

Subnet routes

They are generated by the system and routes primary and secondary subnet IP addresses to VPC network, which fordwards packets to VMs in its subnets.

Every subnet has one subnet route for every IP range (at least there is one for the primary IP range).

They are deleted when subnet is deleted.

Priority is 1000.

Subnet routes for subnets in a peered network cannot be removed before removing the peering relationship, which removes all subnets routs on peered network.

Custom static routes

The destination must be less specific than subnet routes (IP range broader than subnet IP range).

They can be setup on defining VPN tunnels with policy based routing.

The next hop must be either an instance name, an instance IP address or a Cloud VPN tunnel.

Custom dynamic routes

Custom dynamic routes are maintained by one or more cloud routers.

The destination must be less specific than subnet routes (IP range broader than subnet IP range).

They are used in Cloud VPN tunnels with dynamic routing.

The next hop must be an IP address of the Cloud Router's BGP (Border Gateway Protocol) peer.

They are removed by Cloud Router if no longer receives the route from its BGP peer.

Applicability and Order

Applicable routes

  • System-generated routes apply to all instances in a VPC network.
  • Custom static routes can apply to all instances or specific instances, depending on the tag attribute of the route.
  • Dynamic routes apply to instances based on the dynamic routing mode of the VPC network – regional/global

Routing order

  1. Subnet routes are considered first
  2. If the packet does not fit in the destination for a subnet route, GCP looks for another route with the most specific destination.
  3. If more than one route has the same most specific destination, GCP considers the priority of the route
  4. If no applicable destination is found, GCP drops the packet