一个Google Compute Engine实例上的多个IP地址 [英] Multiple IP addresses on a single Google Compute Engine instance

查看:119
本文介绍了一个Google Compute Engine实例上的多个IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让我的GCE实例侦听多个IP地址(出于SEO的原因-在同一实例上托管多个低流量站点).

I'm trying to have my GCE instance listen on multiple IP addresses (for SEO reasons - to host multiple low traffic sites on the same instance).

最终目标:mydomain.com指向IP1,myotherdomain.es指向IP2,GCE实例将侦听IP1和IP2并相应地提供内容.

Final objective: mydomain.com points to IP1, myotherdomain.es points to IP2, the GCE instance will listen on both IP1 and IP2 and serve content accordingly.

我添加了一个指向我的主实例的目标实例,并设法创建了这样的转发规则:

I added a target instance pointing to my main instance and managed to create a forwarding rule like this:

gcloud compute forwarding-rules create another-ip --port 80 --target-instance MY_TARGET_INSTANCE_URL

它实际上创建了一个临时IP地址;我尝试将其升级为静态版本,但超出了配额(目前正在进行2个月的免费试用).

It actually created an ephemeral IP address; I tried to promote it to static but I exceeded my quota (I'm currently on my 2 months free trial).

这是正确的吗?试用结束后,我能否创建任意数量的静态IP并将它们指向我的唯一实例?我也找不到任何有关定价的信息:我知道分配给活动实例的IP是免费的,但是其他IP呢?

Is this correct though? Will I be able to create any number of static IPs and point them to my only instance once the trial ends? I also couldn't find anything about pricing: I know an IP assigned to an active instance is free, but what about additional ones?

由于这是我管理的网站的必要配置,因此我想确保在承诺移动GCE上的所有内容之前,它可以正常工作.

Since this is a necessary configuration for a site I'm managing, I'd like to be sure it works before committing to moving everything on GCE.

推荐答案

您可以使用转发规则为一个VM实例获取多个外部IP.

You can get multiple external IPs for one VM instance with forwarding rules.

  1. 默认情况下,VM将被分配一个临时外部IP,您可以将其提升为静态外部IP,在停止并重新启动后该IP将保持不变.
  2. 必须将额外的外部IP附加到指向VM的转发规则.您也可以使用(或提升为)静态IP.

您可能要使用的命令:

  1. 为您的VM实例创建TargetInstance:

  1. Create a TargetInstance for your VM instance:

gcloud compute target-instances create <target-instance-name> --instance <instance-name> --zone=<zone>

  • 创建一个指向TargetInstance的ForwardingRule:

  • Create a ForwardingRule pointing to the TargetInstance:

    gcloud compute forwarding-rules create <forwarding-rule-name> --target-instance=<target-instance-name> --ip-protocol=TCP --ports=<ports>
    

  • 请参见协议转发.

    这篇关于一个Google Compute Engine实例上的多个IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆