Last active
November 8, 2019 13:12
-
-
Save triangletodd/b3d0153d75e386ab11271f7f735c4c65 to your computer and use it in GitHub Desktop.
Google Compute Engine GCE IP Ranges
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
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.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/15 | |
35.202.0.0/16 | |
35.203.0.0/17 | |
35.203.128.0/18 | |
35.203.192.0/19 | |
35.203.240.0/20 | |
35.204.0.0/14 | |
35.208.0.0/13 | |
35.235.216.0/21 | |
35.235.224.0/20 | |
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.59.80.0/20 | |
130.211.128.0/17 | |
130.211.16.0/20 | |
130.211.32.0/19 | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
trap teardown EXIT | |
setup() { | |
export GIST_ID | |
export PATH=$HOME/bin:/usr/local/bin:$PATH | |
export GIST_OPTS="-d 'Google Compute Engine GCE IP Ranges'" | |
pushd "${0%/*}" > /dev/null | |
} | |
teardown() { | |
cd "$(dirs -l -0)" && dirs -c | |
} | |
gist_url_exists() { | |
if [[ -f gist.url ]] && grep -q '^https://gist.github.com/' gist.url; then | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
gist_url() { | |
cat gist.url | |
} | |
set_gist_opts() { | |
if gist_url_exists; then | |
GIST_OPTS+=" -u '$(gist_url)'" | |
fi | |
} | |
raw_netblocks() { | |
dig txt _cloud-netblocks.googleusercontent.com +short | |
} | |
netblocks() { | |
echo "$(raw_netblocks)" | tr ' ' '\n' | grep include | cut -f 2 -d : | |
} | |
raw_gce_ip_ranges() { | |
for netblock in $(netblocks); do | |
dig txt $netblock +short | |
done | |
} | |
gce_ip_ranges() { | |
echo "$(raw_gce_ip_ranges)" | tr " " "\n" | grep ip4 | cut -f 2 -d : | sort -n | |
} | |
main() { | |
setup | |
set_gist_opts | |
gce_ip_ranges > gce_ip_ranges.log | |
bash -c "gist $GIST_OPTS gce* | tee gist.url" | |
} | |
main "$@" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment