Google 计算引擎 IP 范围

Google 计算引擎 IP 范围

我正在尝试弄清楚 Google 计算引擎的 IP 范围是什么。

我有一个库,它被锁定,仅供特定 IP 范围使用。我知道这很疯狂,但它确实有点特殊。

我搜索了 Google 文档,但找不到列表。有没有办法查找或查询它?

答案1

正如另一个答案所说,谷歌在这里描述了如何获取列表: https://cloud.google.com/compute/docs/faq#where_can_i_find_product_name_short_ip_ranges

我在这里找到了一个用于以下 spf 记录的好脚本:

https://aplawrence.com/Kerio/recursive_spf.html

创建文件 lookup.perl 为:

#!/usr/bin/perl
$domain=shift @ARGV;
@results=getit($domain);


sub getit {
  my $domain=shift;

  my @foo=`nslookup -q=TXT $domain`;
  my @results=();
  foreach (@foo) {
   next if not /$domain\ttext/;
   s/$domain\ttext = "v=spf1//;
   @results=split /\s+/;
   foreach (@results) {
    next if /-all/;
    print "$_\n";
    if (/include:/) {
     s/include://;
     getit($_);
    }
   } 
  } 
}

然后运行:./lookup.perl _cloud-netblocks.googleusercontent.com | grep ip4

ip4:35.190.224.0/20
ip4:35.232.0.0/15
ip4:35.234.0.0/16
ip4:35.235.0.0/17
ip4:35.235.192.0/20
ip4:35.236.0.0/14
ip4:35.240.0.0/15
ip4:35.203.232.0/21
ip4:130.211.4.0/22
ip4:35.220.0.0/14
ip4:35.242.0.0/15
ip4:35.244.0.0/14
ip4:34.64.0.0/11
ip4:34.96.0.0/14
ip4:34.100.0.0/18
ip4:34.100.64.0/19
ip4:108.170.216.0/22
ip4:108.170.220.0/23
ip4:108.170.222.0/24
ip4:35.224.0.0/13
ip4:35.202.0.0/16
ip4:35.190.240.0/22
ip4:35.190.242.0/23
ip4:35.206.0.0/15
ip4:8.34.208.0/20
ip4:8.35.192.0/21
ip4:8.35.200.0/23
ip4:108.59.80.0/20
ip4:108.170.192.0/20
ip4:108.170.208.0/21
ip4:162.216.148.0/22
ip4:162.222.176.0/21
ip4:173.255.112.0/20
ip4:192.158.28.0/22
ip4:199.192.112.0/22
ip4:199.223.232.0/22
ip4:199.223.236.0/23
ip4:23.236.48.0/20
ip4:23.251.128.0/19
ip4:35.204.0.0/14
ip4:35.208.0.0/13
ip4:107.167.160.0/19
ip4:107.178.192.0/18
ip4:146.148.2.0/23
ip4:146.148.4.0/22
ip4:146.148.8.0/21
ip4:146.148.16.0/20
ip4:146.148.32.0/19
ip4:146.148.64.0/18
ip4:35.203.0.0/17
ip4:35.203.128.0/18
ip4:35.203.192.0/19
ip4:35.203.240.0/20
ip4:130.211.8.0/21
ip4:130.211.16.0/20
ip4:130.211.32.0/19
ip4:130.211.64.0/18
ip4:130.211.128.0/17
ip4:104.154.0.0/15
ip4:104.196.0.0/14
ip4:208.68.108.0/23
ip4:35.184.0.0/14
ip4:35.188.0.0/15
ip4:35.216.0.0/15
ip4:35.190.0.0/17
ip4:35.190.128.0/18
ip4:35.190.192.0/19
ip4:35.235.224.0/20
ip4:35.192.0.0/14
ip4:35.196.0.0/15
ip4:35.198.0.0/16
ip4:35.199.0.0/17
ip4:35.199.128.0/18
ip4:35.200.0.0/15
ip4:35.235.216.0/21

答案2

Google Cloud Platform 计算引擎 IP 范围会随着时间而变化,因此我建议使用此命令文档获得最新信息。

答案3

GCP Compute Engine 的 IP 范围会随时间而变化,但您可以通过以下方式检查当前的 IP 范围文档

另外,您可以通过运行以下命令通过 Cloud Shell 进行检查:

google_ips=$(for LINE in `dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | cut -f 2 -d :`; do dig txt $LINE +short; done | tr " " "\n" | grep ip4 | cut -f 2 -d : | sort -n | xargs | tr " " ",")

echo $google_ips

上述命令将创建一个包含当前 Compute Engine IP 范围的环境变量。

此外,还有一个问题追踪器以改进这一过程。

希望这可以帮助!

相关内容