GCP网络中的多个子网

问题描述

子网是区域资源,而网络是全局资源。我正在做一个Google实验室,但我正面临这个疑问。

在这种网络: networkAsubnet-asubnet-b都位于区域us-central1

怎么可能?

解决方法

我看不到这样的配置。

请查看文档Networks and subnets

每个VPC网络都包含一个或多个有用的IP范围分区,称为子网。每个子网都与一个 地区。

网络必须至少具有一个子网,然后才能使用它。汽车 模式VPC网络会在每个区域中自动创建子网。自订 模式的VPC网络从无子网开始,使您可以完全控制 子网创建。 您可以在每个区域创建多个子网

因此,根据文档,可能有一个网络test-network,其中两个子网subnet-asubnet-b都位于同一区域us-central1中,例如:>

$ gcloud compute networks create test-network --subnet-mode=custom --mtu=1460 --bgp-routing-mode=regional

$ gcloud compute networks subnets create subnet-a --range=10.0.1.0/24 --network=test-network --region=us-central1

$ gcloud compute networks subnets create subnet-b --range=10.0.2.0/24 --network=test-network --region=us-central1 

$ gcloud compute networks list
NAME          SUBNET_MODE  BGP_ROUTING_MODE  IPV4_RANGE  GATEWAY_IPV4
test-network  CUSTOM       REGIONAL

$ gcloud compute networks subnets list
NAME      REGION                   NETWORK       RANGE
subnet-a  us-central1              test-network  10.0.1.0/24
subnet-b  us-central1              test-network  10.0.2.0/24

此外,请查看文档部分Communication within the network

除默认网络外,您必须显式创建更高版本的网络 优先级入口防火墙规则,允许实例与之通信 彼此。默认网络中包含多个防火墙规则 除了隐含的,还包括default-allow-internal 规则,允许在 网络。默认网络还附带允许进入的规则 协议,例如RDP和SSH。

如果还有其他疑问,请更新您的问题。