External IPs not assigned within VM

人盡茶涼 提交于 2019-12-25 05:30:45

问题


I have a couple of Centos 6 VMs that I am trying to setup. I assigned static IPs to them but when running ifconfig, I do not see the external IPs, just the internal IPs. Does Google not allow this capability?


回答1:


In addition to what Anderson said, this is the command to query for the external IP from the instance itself:

curl "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip" -H "Metadata-Flavor: Google"




回答2:


DHCP only supports requesting a single address. Google Compute Engine returns the internal IP address via DHCP, and maps the external assigned IP addresses to the VM using NAT.

If you want to fetch the assigned IP address from inside the VM, you could query the metadata server for that information.



来源:https://stackoverflow.com/questions/29307487/external-ips-not-assigned-within-vm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!