Outgoing traffic not taking highest priority route

Problem

Outgoing traffic follows the default internet gateway route with the priority 1000, rather than the route towards the peered VPC network with a higher priority.

Environment

  • VPC peering
  • Route name: Default internet gateway route
    • Destination CIDR range: 0.0.0.0/0
    • Priority: 1000
  • Route name: Peering-route-to-internet
    • Destination CIDR range: 0.0.0.0/0
    • Priority: 100

Solution

  1. Remove the default internet gateway route in the local VPC network. 
  2. Alternatively, if your destination IP range can be specified by a more specific CIDR range. Modify the route's destination IP range in the peered VPC. Thus, that more specific route will be selected over the default gateway route with the broadest IP range 0.0.0.0/0

Cause

When an instance sends a packet, the route is selected regarding the route selection order in Google Cloud. If the packet can not be routed to a subnet route or peering subnet route, it evaluates the most specific destination. If the routes have the same specificity, Google Cloud first evaluates the route existing in the local VPC Network and then evaluates the candidates from the peered networks.

As the destination CIDR range for both routes has the same specificity (0.0.0.0/0), the default internet gateway route existing in the local VPC network is selected.