Google compute engine 谷歌云计算引擎的一个实例可以有多个外部ip地址吗
我正在使用google cloud compute engin运行一个小型web服务器以及一些其他服务器。我目前正在使用免费试用版。到期后,我将升级到付费帐户,但我希望在不同的wan IP地址上有另一台服务器。我知道我可以使用不同的端口并进行转发/重定向,但我的问题是,我可以一个实例有多个外部IP,或者我需要创建/支付另一个实例以获得第二个外部IP地址吗?是的,您可以创建具有多个外部IP的VM实例 请查看文档: 默认情况下,VPC网络中的每个实例都有一个默认值 网络接口。使用这些说明创建其他网络 接口。每个接口都连接到不同的VPC网络, 允许该实例访问Google云中的不同VPC网络 平台(GCP)。不能将多个网络接口连接到 相同的专有网络 在该部分:Google compute engine 谷歌云计算引擎的一个实例可以有多个外部ip地址吗,google-compute-engine,Google Compute Engine,我正在使用google cloud compute engin运行一个小型web服务器以及一些其他服务器。我目前正在使用免费试用版。到期后,我将升级到付费帐户,但我希望在不同的wan IP地址上有另一台服务器。我知道我可以使用不同的端口并进行转发/重定向,但我的问题是,我可以一个实例有多个外部IP,或者我需要创建/支付另一个实例以获得第二个外部IP地址吗?是的,您可以创建具有多个外部IP的VM实例 请查看文档: 默认情况下,VPC网络中的每个实例都有一个默认值 网络接口。使用这些说明创建其他网络
- 您只能在创建实例时配置网络接口
- 在单个实例中配置的每个网络接口必须连接到不同的VPC网络,并且每个接口必须属于 IP范围不与任何其他网络的子网重叠的子网 接口
- 在创建实例之前,多个接口将连接到的其他VPC网络必须存在。看见 有关创建其他VPC网络的说明
- 如果不删除实例,则无法删除网络接口
- 每个接口都可以选择具有外部IP地址
$ gcloud compute instances create test-instance-2ip --zone=europe-west3-a --machine-type=n1-standard-1 --network-interface subnet=test-subnet-1,address=34.89.215.180 --network-interface subnet=test-subnet-2,address=35.234.123.210 --tags=test-instance-2ip --image=ubuntu-1804-bionic-v20200430 --image-project=ubuntu-os-cloud --boot-disk-device-name=test-instance-2ip
这里是具有2个外部IP的VM实例:
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
test-instance-2ip europe-west3-a n1-standard-1 172.16.1.3,172.16.2.2 XXX.89.XXX.180,XXX.234.XXX.210 RUNNING
谢谢这正是我想要做的,我找不到创建VPC子网的区域列表。你知道我在哪里可以找到所有可用区域的列表吗?谢谢你的确认。如果我的回答对你有帮助,请接受或投赞成票。当然,看一下文档部分,我已经接受了您的答案,但是当我尝试运行命令创建实例时,它给出了一个错误,我已将区域更改为us-east1,我如何找到用于该reagin的IP地址?错误:-字段“resource.networkInterfaces[0]。accessConfigs[0]。natIP”的值无效:“34.89.215.180”。在区域“us-east1”中找不到指定的外部IP地址“34.89.215.180”。我发现address参数仅适用于静态IP,现在删除它后效果很好!在我的示例中,我使用了静态IP,但这不是必需的。您可以在文档中找到更多示例。
$ gcloud compute addresses create test-static-ip-1 --region=europe-west3
$ gcloud compute addresses create test-static-ip-2 --region=europe-west3
$ gcloud compute instances create test-instance-2ip --zone=europe-west3-a --machine-type=n1-standard-1 --network-interface subnet=test-subnet-1,address=34.89.215.180 --network-interface subnet=test-subnet-2,address=35.234.123.210 --tags=test-instance-2ip --image=ubuntu-1804-bionic-v20200430 --image-project=ubuntu-os-cloud --boot-disk-device-name=test-instance-2ip
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
test-instance-2ip europe-west3-a n1-standard-1 172.16.1.3,172.16.2.2 XXX.89.XXX.180,XXX.234.XXX.210 RUNNING
$ gcloud compute firewall-rules create test-instance-2ip-vpc-1 --direction=INGRESS --priority=900 --network=test-vpc-network-1 --action=ALLOW --rules=tcp,udp --source-ranges=0.0.0.0/0 --target-tags=test-instance-2ip
$ gcloud compute firewall-rules create test-instance-2ip-vpc-2 --direction=INGRESS --priority=900 --network=test-vpc-network-2 --action=ALLOW --rules=tcp,udp --source-ranges=0.0.0.0/0 --target-tags=test-instance-2ip