0

我在谷歌云计算中创建了一个新实例,它有一个公共动态 ip 和一个局域网 ip,但是当我看到接口列表时,我只能看到一个局域网 Ip 接口。在 ifconfig 的输出下方。请帮助我如何获取此接口中的公共 IP。

#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

如果您需要更多详细信息,请告诉我。

提前致谢。

4

1 回答 1

2

无法从ifconfig命令中获取实例公共 IP。您可以使用gcloud命令行获取它:

$ gcloud compute instances describe <instance name>

要为 API 验证机器,请使用:

$ gcloud auth login
于 2016-01-16T11:58:08.807 回答