Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform gcloud-查找ip地址的编号';它在子网中是免费的_Google Cloud Platform_Gcloud - Fatal编程技术网

Google cloud platform gcloud-查找ip地址的编号';它在子网中是免费的

Google cloud platform gcloud-查找ip地址的编号';它在子网中是免费的,google-cloud-platform,gcloud,Google Cloud Platform,Gcloud,是否有任何方法可以使用gcloud获取子网中的免费ip数。 问题是,我试图创建内部lB,但它无法获得所需的ip。 我可以列出用于子网的ip吗?您可以这样列出所有ip gcloud asset search-all-resources --asset-types='compute.googleapis.com/Instance' \ --query="networks/default" \ --format=json | jq ".[].additionalA

是否有任何方法可以使用gcloud获取子网中的免费ip数。 问题是,我试图创建内部lB,但它无法获得所需的ip。
我可以列出用于子网的ip吗?

您可以这样列出所有ip

gcloud asset search-all-resources --asset-types='compute.googleapis.com/Instance' \
  --query="networks/default" \
  --format=json | jq ".[].additionalAttributes.networkInterfaces[].networkIP"
在查询字段中,您可以按网络(如此处)或按位置/区域进行筛选,但不能按子网进行筛选

你得到了这个结果

"10.128.0.46"
"10.129.0.5"
"10.132.0.2"

然后,您可以根据需要进行筛选和排序。

纪尧姆给出的答案是一个很好的方法。目前没有特定的命令来查看子网中的可用IP,但是,我发现和功能请求要求类似的功能。我建议您启动它们并留下评论,因为您也希望拥有此功能

您还可以使用以下命令了解在已确定的子网中分配了多少实例,这将帮助您了解是否有足够的可用子网:

gcloud compute instances list --filter="networkInterfaces.subnetwork=https://www.googleapis.com/compute/v1/projects/Your_project_id/regions/us-central1/subnetworks/default" --project Your_project_id