Skip to content

Instantly share code, notes, and snippets.

@rogueresistor
Created March 5, 2020 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogueresistor/92d1a6992951ed8391a56f080a39b3a3 to your computer and use it in GitHub Desktop.
Save rogueresistor/92d1a6992951ed8391a56f080a39b3a3 to your computer and use it in GitHub Desktop.
List all of the GCP IP ranges
#!/bin/sh
# This is modified from the script posted at
# https://cloud.google.com/compute/docs/faq#where_can_i_find_product_name_short_ip_ranges,
# this will also show the IPv6 ranges that are returned
set -- $(dig -t txt +short _cloud-netblocks.googleusercontent.com)
included="" ip4=""
while [ $# -gt 0 ]; do
k="${1%%:*}" v="${1#*:}"
case "$k" in
include)
# only include once
if [ "${included% $v *}" = "${included}" ]; then
set -- "$@" $(dig -t txt +short "$v")
included=" $v $included"
fi
;;
ip4) ip4="$v $ip4" ;;
ip6) ip6="$v $ip6" ;;
esac
shift
done
echo -n "Today's date: "
date
echo ""
echo "GCP IPv4 ranges:"
(for i in $ip4; do
echo "$i"
done) | sort -n
echo ""
echo "GCP IPv6 ranges: "
for i in $ip6; do
echo "$i"
done
@rogueresistor
Copy link
Author

Today's date: Thu Mar  5 15:58:14 PST 2020

GCP IPv4 ranges:
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
34.100.0.0/16
34.102.0.0/15
34.104.0.0/14
34.124.0.0/18
34.124.64.0/20
34.124.80.0/23
34.124.84.0/22
34.124.88.0/23
34.124.92.0/22
34.125.0.0/16
34.64.0.0/11
34.96.0.0/14
35.184.0.0/14
35.188.0.0/15
35.190.0.0/17
35.190.128.0/18
35.190.192.0/19
35.190.224.0/20
35.190.240.0/22
35.192.0.0/14
35.196.0.0/15
35.198.0.0/16
35.199.0.0/17
35.199.128.0/18
35.200.0.0/13
35.208.0.0/13
35.216.0.0/15
35.219.192.0/24
35.220.0.0/14
35.224.0.0/13
35.232.0.0/15
35.234.0.0/16
35.235.0.0/17
35.235.192.0/20
35.235.216.0/21
35.235.224.0/20
35.236.0.0/14
35.240.0.0/13
104.154.0.0/15
104.196.0.0/14
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.128.0/17
130.211.16.0/20
130.211.32.0/19
130.211.4.0/22
130.211.64.0/18
130.211.8.0/21
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
208.68.108.0/23

GCP IPv6 ranges: 
2600:1900::/35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment