0

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?

Simo Kivistö
  • 4,247
  • 3
  • 38
  • 42
  • In case I need to specify, this is for google cloud compute platform – Enoch Bryant Mar 27 '15 at 18:16
  • how/where did you set the static ip? could you please describe your network topology? – JPT Mar 27 '15 at 18:20
  • Nothing complex, I built 2 vms in the google cloud compute section https://cloud.google.com/compute and during setup instead of selecting Ephemeral for external network, I selected static IP. Upon reboot of both servers I ran ifconfig and also looked in /etc/sysconfig/network-scripts/ifcfg-eth# I saw no new configs, I only have eth0 which is the internal IP and lo. To further troubleshoot I built a brand new vm selecting the same static IP for external and it did not show the external IP under ifconfig – Enoch Bryant Mar 27 '15 at 18:39
  • My guess was this somehow is dhcp related. did you try a `sudo dhclient -v`? And I do not understand what you mean by internal and external network. could you please integrate your details into your initial question? – JPT Mar 27 '15 at 18:44
  • Thanks JPT for the help, but I think I am looking for someone a little more well versed with google cloud compute engine. The majority of stuff is out of my control since the infrastructure and everything beyond whats inside my VM is completely out of my control. – Enoch Bryant Mar 27 '15 at 22:25

2 Answers2

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"

Adrián
  • 2,876
  • 17
  • 22
  • So unless I am doing something wrong, i still do not see it showing up under ifconfig. https://bo-strato-comp.tinytake.com/sf/MTA0NjYyXzY5MTQ2Nw – Enoch Bryant Mar 29 '15 at 12:50
  • The command I proposed is to get that information. However, it doesn't modify the output that you will receive with the ifconfig command. – Adrián Mar 31 '15 at 15:47
0

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.

E. Anderson
  • 3,405
  • 1
  • 16
  • 19
  • Thanks for the info, I will do some more research but i just want to confirm that you are saying i can have the VM for example ifcfg-eth1 show the external IP? – Enoch Bryant Mar 29 '15 at 04:56