VPC Network Peering (original) (raw)

Google Cloud VPC Network Peering connects two Virtual Private Cloud (VPC) networks so that resources in each network can communicate with each other. Peered VPC networks can be in the same project, different projects of the same organization, or different projects of different organizations.

Specifications

VPC Network Peering lets you do the following:

Connectivity

Administration

Peered VPC networks remain administratively separate. Only routes are exchanged, according to the peering configuration. For more information, seeAbout peering connections.

Network security

VPC networks connected using VPC Network Peering only exchange routes, based on the route exchange options configured by a network administrator of each VPC network.

VPC Network Peering doesn't exchange VPC firewall rules or firewall policies.

For VPC firewall rules:

Rules in network firewall policies can use secureTags, which are different from network tags, to identify targets and sources:

Every VPC network contains implied firewall rules. Because of theimplied deny ingress firewall rules, security administrators for each VPC network must create ingress allow firewall rules or rules in firewall policies. Sources for those rules can include IP address ranges of a peered VPC network.

Because of the implied allow egress firewall rules, you don't need to create egress allow firewall rules or rules in firewall policies to permit packets to destinations in the peered VPC network unless your networks include egress deny rules.

DNS support

Resources in a peered VPC network can't useCompute Engine internal DNS namescreated by a local VPC network.

A peered VPC network can't use Cloud DNS managed private zones that are authorized for only a local VPC network. To make the DNS names available to resources in a peered VPC network, use one of the following techniques:

Internal load balancer support

Clients in a local VPC network can access internal load balancers in a peer VPC network. For more information, see the Use VPC Network Peering sections of the following load balancer documentation:

Peered networks can exchange static routes that use internal passthrough Network Load Balancers as next hops. For more information, see Route exchange options.

Peering group & quotas

The VPC peering quotas depend on a concept called a peering group. Each VPC network has its own peering group consisting of itself and all other VPC networks connected to it by using VPC Network Peering. In the simplest scenario, if two VPC networks, net-a and net-b, are peered with each other, there are two peering groups: one from the perspective of net-a and the other from the perspective of net-b.

For more information about VPC Network Peering quotas see:

Limitations

VPC Network Peering has the following limitations.

Subnet IP ranges can't overlap across peered VPC networks

No subnet IP range can exactly match, contain, or fit within another subnet IP range in a peered VPC network. At the time of peering, Google Cloud checks if subnets with overlapping IP ranges exist; if they do, then the peering fails. For already peered networks, if you performan action that results in the creation of a new subnet route, Google Cloud requires the new subnet route to have a unique destination IP address range.

Before creating new subnets, you can list the routes from peering connections to ensure that the new subnet IPv4 address range is not already used.

This limitation and Google Cloud's corresponding checks also apply to scenarios such as the following:

In this scenario, you must coordinate with a network administrator for thenetwork-2. Ask the network administrator for network-2to list peering routesin their VPC network.

For more information about overlap checks, seeSubnet and peering subnet route interactions.

Internal DNS names don't resolve in peered networks

Compute Engine internal DNS names created in a network aren't accessible to peered networks. To reach the VM instances in the peered network, use the IP address of the VM.

Tags and service accounts are not usable across peered networks

You cannot reference a tag or service account pertaining to a VM from one peered network in a firewall rule in the other peered network. For example, if an ingress rule in one peered network filters its source based on a tag, it will only apply to VM traffic originating from within that network, not its peers, even if a VM in a peered network has that tag. This situation holds similarly for service accounts.

Route exchange options

When a VPC network shares local routes with a peered VPC network, it exports the routes. The peered VPC network can then import the routes. Subnet routes, except for IPv4 subnet routes using privately used public IPv4 addresses, are always exchanged.

VPC Network Peering configuration lets you control the following:

You can update the configuration before the peering has been established or while the peering connectivity is active.

VPC Network Peering doesn't provide:

Options for exchanging subnet routes

The following table describes the route exchange options forsubnet routes:

Route type Route export conditions Route import conditions
IPv4 subnet routes (primary and secondary IPv4 subnet ranges) using private IPv4 address ranges Always exported Can't be disabled Always imported Can't be disabled
IPv4 subnet routes (primary and secondary IPv4 subnet ranges) using privately used public IPv4 address ranges Exported by default Export is controlled using the --export-subnet-routes-with-public-ip flag Not imported by default Import is controlled using the --import-subnet-routes-with-public-ip flag
Internal IPv6 subnet ranges (ipv6-access-type=INTERNAL) Not exported by default Export is enabled by setting --stack-type=IPV4_IPV6 Not imported by default Import is enabled by setting --stack-type=IPV4_IPV6
External IPv6 subnet ranges (ipv6-access-type=EXTERNAL) Not exported by default Export is enabled by setting --stack-type=IPV4_IPV6 Not imported by default Import is enabled by setting --stack-type=IPV4_IPV6

Options for exchanging static routes

The following table describes the route exchange options for static routes.

Route type Route export conditions Route import conditions
Static routes with network tags (all next hop types) Can't be exported Can't be imported
Static routes that use the default internet gateway next hop Can't be exported Can't be imported
IPv4 static routes—without network tags—that use a next hop different from default internet gateway Not exported by default Export is controlled by using the --export-custom-routes flag Not imported by default Import is controlled by using the --import-custom-routes flag
IPv6 static routes—without network tags—that use a VM instance as the next hop Not exported by default Export is controlled by using the --export-custom-routes flag when the stack type of the peering is set to --stack-type=IPV4_IPV6 Not imported by default Import is controlled by using the --import-custom-routes flag when the stack type of the peering is set to --stack-type=IPV4_IPV6

Options for exchanging dynamic routes

The following table describes the route exchange options fordynamic routes.

Route type Route export conditions Route import conditions
Dynamic IPv4 routes Not exported by default Export is controlled by using the --export-custom-routes flag Not imported by default Import is controlled by using the --import-custom-routes flag
Dynamic IPv6 routes Not exported by default Export is controlled by using the --export-custom-routes flag when the stack type of the peering is set to --stack-type=IPV4_IPV6 Not imported by default Import is controlled by using the --import-custom-routes flag when the stack type of the peering is set to --stack-type=IPV4_IPV6

Benefits of exchanging static and dynamic routes

When one VPC network exports static and dynamic routes and the other VPC network imports those routes, the importing network can send packets directly to the next hop for each imported static or dynamic route whose next hop is in the peer VPC network.

A network administrator of a local VPC network controls the export of that network's static and dynamic routes—together—by using the --export-custom-routes flag. A network administrator of the corresponding peered VPC network controls the import of those static and dynamic routes by using the --import-custom-routes flag. For more information, see Ignored routes, Subnet and peering subnet route interactions, and Subnet and static route interactions.

Importing static and dynamic routes from a peered VPC network can be useful in the following scenarios:

Ignored routes

Even when a VPC network imports a route, it can ignore the imported route in situations like the following:

For more details about the preceding situations, seeRouting order.

For dual-stack peerings, if a local VPC network importing IPv6 routes doesn't have any dual-stack or IPv6-only subnets, none of the IPv6 routes it receives from peered VPC networks can be used. Further, if theconstraints/compute.disableAllIpv6organization policy constraint has been set, a Network Administrator may not be able to create subnets with IPv6 address ranges.

Subnet and peering subnet route interactions

IPv4 subnet routes in peered VPC networks can't overlap:

Google Cloud enforces the preceding conditions for IPv4 subnet routes in the following cases:

While you peer networks, Google Cloud returns an error if any of the following operations result in an overlap:

IPv6 subnet routes (both internal and external) are unique by definition. No two VPC networks can use the same internal or external IPv6 subnet ranges. For example, if one VPC network uses fc:1000:1000:1000::/64 as an IPv6 subnet range, no other VPC network in Google Cloud can usefc:1000:1000:1000::/64, regardless of whether the VPC networks are connected by using VPC Network Peering.

Subnet and static route interactions

Google Cloud requires that subnet routes and peering subnet routes have the most specific destination IPv4 or IPv6 ranges. Within any VPC network, a local static route can't have a destination that exactly matches or fits within a local subnet route. For a more detailed discussion about this scenario, see Interactions with static routes.

This concept is extended to VPC Network Peering by the following two rules:

Effects of the dynamic routing mode

The dynamic routing mode of a VPC network determines the regions in which prefixes learned from Cloud Routers in that network are applied as local dynamic routes. For details about this behavior, see Effects of dynamic routing mode.

This concept is extended to VPC Network Peering. The dynamic routing mode of the exporting VPC network—the network that contains the Cloud Routers that learned the prefixes for those dynamic routes— determines the regions in which the peering dynamic routes can be programmed in peer networks:

In both cases, the dynamic routing mode of the importing VPC network is not relevant.

For an example illustrating this behavior, see Local VPC network and peer VPC network with on-premises connectivity.

Subnet and dynamic route interactions

Conflicts between local or peering subnet routes and dynamic routes are resolved as described inInteractions with dynamic routes.

VPC Network Peering examples

The following examples demonstrate two common VPC Network Peering scenarios.

Local VPC network and peer VPC network with on-premises connectivity

In this example, the following network peering is set up:

Peered network with global dynamic routing.

Peered network with access to the on-premises network with global dynamic routing (click to enlarge).

To provide connectivity from on-premises to subnets innetwork-a and network-b, the Cloud Router in network-b must be configured to usecustom advertisement mode. For example, the Cloud Router advertises only the custom prefix,custom-prefix-1, which includes the subnet ranges from network-b and the subnet ranges from network-a.

The Cloud Router in us-west1 learns on-premises-prefix from an on-premises router. on-premises-prefix does not create any conflict because it's broader than the subnet and peering subnet routes. In other words, on-premises-prefix does not exactly match and does not fit within any subnet or peering subnet route.

The following table summarizes the network configuration specified in the preceding example:

Network name Networking component IPv4 range IPv6 range Region
network-a subnet-a 10.0.0.0/24 fc:1000:1000:1000::/64 us-west1
network-a subnet-b 10.0.1.0/24 fc:1000:1000:1001::/64 europe-north 1
network-b subnet-c 10.0.2.0/23 fc:1000:1000:1002::/64 us-west1
network-b Cloud Router 10.0.0.0/22 fc:1000:1000:1000::/64 us-west1
On-premises network On-premises router 10.0.0.0/8 fc:1000:1000:1000::/56 N/A

Regardless of the dynamic routing mode of network-a, the following routing characteristics apply:

Transit network with multiple peerings

Consider a scenario in which network-b is connected to an on-premises network and acts as a transit network for two other networks, network-aand network-c. To let VMs in both of these networks access network-b and its connected on-premises network by using only internal IP addresses, the following configuration is required:

A transit VPC network, containing a VPN tunnel,     that's peered with two other VPC networks.

VPC transit network (click to enlarge).

If firewalls are configured correctly, the following connectivity scenarios are possible:

Because VPC Network Peering isn't transitive, VM instances in network-a andnetwork-c can't communicate with each other unless you also connect networksnetwork-a and network-c using VPC Network Peering.

Pricing

Regular network pricing applies to VPC Network Peering.

What's next