4

I am using Google Cloud Platform.

I know that we can list the Public IP Addresses used by instances using the gcloud command like explained in https://stackoverflow.com/q/27994033.

I also have found out how to get the Public IP Addresses used by load balancers with the help of this blog post.

However, I am nearly certain that those two lists do not represent the complete Public IP addresses I'm using.

What other the services that can hold Public IP addresses? And what command I can use to retrieve those lists?

Thank you for your consideration.

pepoluan
  • 5,038
  • 4
  • 47
  • 72

2 Answers2

5

We don't have any specific command the list all the IP addresses associated with a project. You can open a feature request here about this feature.

You can list all the Static IP addresses used in your project, using this command here. There is also a command that provides IP address associated with the forwarding rules used in LoadBalancer. According to the Stackoverflow thread, below is a command that provides the external IPs for all the instances.

gcloud --format="value(networkInterfaces[0].accessConfigs[0].natIP)" compute instances list
RalfFriedl
  • 3,108
  • 4
  • 13
  • 17
shamma
  • 99
  • 3
  • So, does it mean we couldn't list any dynamic allocated public IP through the following command? "gcloud compute addresses list" Only the following command could show dynamic public IP? "gcloud compute instances list" Because I used the "addresses list" which shows nothing. – Clock ZHONG Dec 27 '19 at 17:01
1

The following command seems to also include load-balancer and NAT gateways:

gcloud compute addresses list --filter=addressType:EXTERNAL

Command docs: https://cloud.google.com/sdk/gcloud/reference/compute/addresses/list

devkaoru
  • 111
  • 1