0

I have created an new Instance in Google cloud compute which has one Public dynamic ip and lan ip,But when i see the interface list, i can see only one LAN Ip interface.below the output for ifconfig.Please help me how to get the Public Ip in this interface.

#ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1460
        inet 10.240.0.2  netmask 255.255.255.255  broadcast 10.240.0.2
        inet6 fe80::4001:aff:fef0:2  prefixlen 64  scopeid 0x20<link>
        ether 42:01:0a:f0:00:02  txqueuelen 1000  (Ethernet)
        RX packets 1196  bytes 214299 (209.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1124  bytes 143037 (139.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 3515  bytes 1891143 (1.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3515  bytes 1891143 (1.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Let me know if you required more details.

Thanks in Advance.

Apurva
  • 7,871
  • 7
  • 40
  • 59
Raja
  • 55
  • 1
  • 6

1 Answers1

2

There is no way to get instance public IP from the ifconfig command. You can obtain it using the gcloud command line:

$ gcloud compute instances describe <instance name>

To authenticate the machine for the API, use:

$ gcloud auth login
Daniel Cukier
  • 11,502
  • 15
  • 68
  • 123