Stay organized with collections
Save and categorize content based on your preferences.
Outbound services, such as the URL Fetch, Sockets, and Mail APIs, make use of
a large pool of IP addresses. The IP address ranges in this pool are subject to
routine changes. In fact, two sequential API calls from the same application may
appear to originate from two different IP addresses.
You can find the current IP address ranges for your App Engine services
based on IP range information that Google publishes:
Google publishes the complete list of IP ranges that it makes available to
users on the internet in goog.json.
Google also publishes a list of global and regional external IP addresses
ranges available for customers' Google Cloud resources in
cloud.json.
The IP addresses used by Google APIs and services fit
within the list of ranges computed by taking away all ranges in cloud.json
from those in goog.json. These lists are updated frequently.
You can use the following Python script to create a list of IP address ranges
that include those used by Google APIs and services.
For information about running this script, see How to
run.
from__future__importprint_functionimportjsontry:fromurllibimporturlopenexceptImportError:fromurllib.requestimporturlopenfromurllib.errorimportHTTPErrorimportnetaddrIPRANGE_URLS={"goog":"https://www.gstatic.com/ipranges/goog.json","cloud":"https://www.gstatic.com/ipranges/cloud.json",}defread_url(url):try:returnjson.loads(urlopen(url).read())except(IOError,HTTPError):print("ERROR: Invalid HTTP response from %s"%url)exceptjson.decoder.JSONDecodeError:print("ERROR: Could not parse HTTP response from %s"%url)defget_data(link):data=read_url(link)ifdata:print("{} published: {}".format(link,data.get("creationTime")))cidrs=netaddr.IPSet()foreindata["prefixes"]:if"ipv4Prefix"ine:cidrs.add(e.get("ipv4Prefix"))if"ipv6Prefix"ine:cidrs.add(e.get("ipv6Prefix"))returncidrsdefmain():cidrs={group:get_data(link)forgroup,linkinIPRANGE_URLS.items()}iflen(cidrs)!=2:raiseValueError("ERROR: Could process data from Google")print("IP ranges for Google APIs and services default domains:")foripin(cidrs["goog"]-cidrs["cloud"]).iter_cidrs():print(ip)if__name__=="__main__":main()
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-07 UTC."],[[["Outbound services use a large pool of IP addresses that are subject to frequent changes, meaning sequential API calls from the same application may originate from different IP addresses."],["Google publishes two JSON files, `goog.json` and `cloud.json`, containing lists of IP ranges available to internet users and Google Cloud resources, respectively."],["The IP addresses used by Google APIs and services can be found by subtracting the IP ranges in `cloud.json` from those in `goog.json`."],["A Python script is provided to compute the list of IP address ranges that include those used by Google APIs and services, and instructions are available on how to run it."],["The previously used `_spf.google.com` DNS TXT record is no longer a complete representation of all possible IP ranges used by Google APIs and services, although it is still accurate for SPF purposes."]]],[]]