External IPs not assigned within VM

2019-09-06 15:17发布

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?

2条回答
再贱就再见
2楼-- · 2019-09-06 15:59

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.

查看更多
劳资没心,怎么记你
3楼-- · 2019-09-06 16:03

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"

查看更多
登录 后发表回答