简体   繁体   English

Google App Engine - IP地址列表?

[英]Google App Engine - list of IP addresses?

I know that Google App Engine does not support an application having a static IP address, but I'd like to know if there is a list or range of IP addresses that an app could potentially have? 我知道Google App Engine不支持具有静态IP地址的应用程序,但我想知道应用程序可能具有的列表或IP地址范围? I'd like to use that list as a whitelist of IP addresses for another application deployed elsewhere. 我想将该列表用作其他地方部署的其他应用程序的IP地址白名单。

In addition to the other answers, GAE premier support directed me to this name, esp as the source IP address for URLFetch calls: 除了其他答案之外,GAE高级支持还指导我使用此名称,特别是URLFetch调用的源IP地址:

$ dig -t txt _cloud-netblocks.googleusercontent.com

which answers: 哪个答案:

include:_cloud-netblocks1.googleusercontent.com
include:_cloud-netblocks2.googleusercontent.com
include:_cloud-netblocks3.googleusercontent.com

if you then query those, you get this list of ranges (as of 2014-06-26): 如果你然后查询那些,你会得到这个范围列表(截至2014-06-26):

8.34.208.0/20
8.35.192.0/21
8.35.200.0/23
23.236.48.0/20
23.251.128.0/19
107.167.160.0/19
107.178.192.0/18
108.170.192.0/20
108.170.208.0/21
108.170.216.0/22
108.170.220.0/23
108.170.222.0/24
108.59.80.0/20
130.211.4.0/22
146.148.16.0/20
146.148.2.0/23
146.148.32.0/19
146.148.4.0/22
146.148.64.0/18
146.148.8.0/21
162.216.148.0/22
162.222.176.0/21
173.255.112.0/20
192.158.28.0/22
199.192.112.0/22
199.223.232.0/22
199.223.236.0/23

Use command: 使用命令:

 dig -t txt _netblocks.google.com

to get the latest google ip blocks, and then you can add the result to your white list. 获取最新的谷歌IP块,然后您可以将结果添加到您的白名单。 Be aware that the list are not static and updated from time to time. 请注意,该列表不是静态的,并且会不时更新。

From the GAE documentationn , you need to use the dig command because it does not currently provide a way to map static IP addresses to an application, due to its design: GAE文档中 ,您需要使用dig命令,因为它目前不提供将静态IP地址映射到应用程序的方法,因为它的设计:

dig -t TXT _netblocks.google.com @ns1.google.com

If the dig command is not available on your system, you can use an online service: 如果您的系统上没有dig命令,则可以使用在线服务:

As the time of writing this answer, querying http://www.digwebinterface.com/?hostnames=_netblocks.google.com&type=TXT&useresolver=8.8.4.4&ns=self&nameservers=ns1.google.com returns: 在撰写此答案时,查询http://www.digwebinterface.com/?hostnames=_netblocks.google.com&type=TXT&useresolver=8.8.4.4&ns=self&nameservers=ns1.google.com会返回:

_netblocks.google.com.  3596    IN  TXT "v=spf1 ip4:216.239.32.0/19 ip4:64.233.160.0/19 ip4:66.249.80.0/20 ip4:72.14.192.0/18 ip4:209.85.128.0/17 ip4:66.102.0.0/20 ip4:74.125.0.0/16 ip4:64.18.0.0/20 ip4:207.126.144.0/20 ip4:173.194.0.0/16 ?all"

Here the formatted list for the Google API console if you need it: 如果需要,可以在此处使用Google API控制台的格式化列表:

216.239.32.0/19 
64.233.160.0/19 
66.249.80.0/20 
72.14.192.0/18 
209.85.128.0/17 
66.102.0.0/20 
74.125.0.0/16 
64.18.0.0/20 
207.126.144.0/20 
173.194.0.0/16

Please note the IP ranges may change in the future so you will need to run this query from time to time. 请注意,IP范围将来可能会发生变化,因此您需要不时运行此查询。

And this is an updated list as of March 20, 2016: 这是截至2016年3月20日的更新列表:

Extracted using instructions in this KB article . 使用此知识库文章中的说明进行提取。

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:108.170.216.0/22
ip4:108.170.220.0/23
ip4:108.170.222.0/24

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: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:130.211.4.0/22

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

ip6:2600:1900::/35

I threw this together quickly, for use with the gcloud create-firewall command. 我快速将它们放在一起,以便与gcloud create-firewall命令一起使用。

#!/bin/bash

netblocks=$(dig TXT _cloud-netblocks.googleusercontent.com @ns1.google.com +short | sed -e 's/"//g')

for block in $netblocks; do
    if [[ $block == include:* ]]; then
        ipblocks=$(dig TXT ${block#include:} @ns1.google.com +short)

        for ipblock in $ipblocks; do
            if [[ $ipblock == ip4:* ]]; then
                printf "${ipblock:4},"
            fi
        done
    fi
done

I've created a ruby script for this exact purpose (super simple, easy to update): 我已经为这个目的创建了一个ruby脚本(超级简单,易于更新):

https://github.com/stephengroat/whitelist-travisci https://github.com/stephengroat/whitelist-travisci

Resolv::DNS.open do |dns|
  ress = dns.getresource "_cloud-netblocks.googleusercontent.com", Resolv::DNS::Resource::IN::TXT
  ress.data.scan(/(?<=include:)_cloud-netblocks+\d.googleusercontent.com/).each do |r|
    subress = dns.getresource r, Resolv::DNS::Resource::IN::TXT
    subress.data.scan(/(?<=ip[4|6]:)[^\s]+/).each do |sr|
      puts sr
    end
  end
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM