如何为Google Compute Engine实例上托管的VM设置静态IP [英] How to setup static IP to VM hosted on Google Compute Engine instance

查看:133
本文介绍了如何为Google Compute Engine实例上托管的VM设置静态IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法为GCE VM实例(作为VM主机)托管的虚拟机(VirtualBox)设置静态IP地址.

I am wondering if there is a way to setup a static IP address to a virtual machine (VirtualBox) hosted on a GCE VM instance (as a VM host).

我想在我的GCE VM实例上运行两个VirtualBox VM,并希望公开访问它们.

I want to run two VirtualBox VMs on my GCE VM instance and I want to access them publicly.

推荐答案

是的,您可以这样做,但是您还应该考虑是否需要在另一个虚拟机(GCE)中运行一个虚拟机(VirtualBox)的额外开销. VM).直接在GCE VM上运行会更有效率,您可以通过Google Cloud Platform API轻松创建/销毁/控制这些VM.

Yes, you can do this, but you should also consider whether you want the additional overhead of running one virtual machine (VirtualBox) inside of another virtual machine (GCE VM). Running directly on GCE VMs would be more efficient and you can easily create/destroy/control these VMs via Google Cloud Platform APIs.

此外,如果您已经为VirtualBox VM使用自动化框架,例如 Vagrant ,请注意 Vagrant原生支持GCE VM ,因此,只需对配置进行一些更改,就可以使用Vagrant与本地VirtualBox VM一样轻松地创建/修改/连接/销毁GCE VM.

In addition, if you are already using an automation framework for your VirtualBox VMs such as Vagrant, note that Vagrant natively supports GCE VMs, so with a few changes to your configuration, you can use Vagrant to create/modify/connect/destroy your GCE VMs as easily as you would local VirtualBox VMs.

作为静态外部IP的替代方法,请考虑还使用将域名映射到实例的临时外部IP的方法.您可以使用 Google Cloud DNS 来管理DNS映射.

As an alternative to static external IPs, consider also using a domain name mapping to ephemeral external IP(s) of your instance(s). You can use Google Cloud DNS to manage your DNS mappings.

有关静态外部IP的详细信息,请参见文档:

For more info on static external IPs, see the docs:

静态外部IP地址

如果您需要分配给项目的静态外部IP地址并一直存在,直到您明确释放它为止,则可以保留新的静态外部IP地址,也可以将临时外部IP地址提升为静态外部IP地址.将gcloud compute addresses create 命令一起使用或对适当的区域性地址集合的PUT请求,以保留静态外部IP地址.

Static external IP addresses

If you need a static external IP address that is assigned to your project and persists until you explicitly release it, you can reserve a new static external IP address or promote an ephemeral external IP address to a static external IP address. Use gcloud compute with the addresses create command or make a PUT request to the appropriate regional Addresses collection to reserve a static external IP address.

分配给实例的静态外部IP地址是一种区域资源,创建地址时必须选择IP地址所属的区域.

Static external IP addresses assigned to instances are a regional resource and you must select the region where the IP address will belong to when you create the address.

[...]

静态外部IP地址一次只能由一个资源使用.您不能将静态外部IP地址分配给多个资源.

Static external IP addresses can only be used by one resource at a time. You cannot assign a static external IP address to multiple resources.

除了将IP地址与为该项目保留的静态外部IP地址列表进行比较之外,没有办法知道IP地址是静态的还是短暂的.使用 addresses list 子命令查看列表项目可用的静态外部IP地址数量.

There is no way to tell whether an IP address is static or ephemeral after it has been assigned to a resource, except to compare the IP address against the list of static external IP addresses reserved to that project. Use the addresses list sub-command to see a list of static external IP addresses available to the project.

请注意,静态外部IP也附带一些成本:

Note that static external IPs also come with some cost:

IP地址定价

Type                                                            Price/Hour

Static IP address (assigned but unused)                           $0.01
Static IP address (assigned and in use)                         No charge
Ephemeral IP address (attached to instance or forwarding rule)  No charge

这篇关于如何为Google Compute Engine实例上托管的VM设置静态IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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