Skip to content

Instantly share code, notes, and snippets.

@x2c3z4
Forked from n0531m/list_gcp_iprange.sh
Created December 28, 2016 09:03
Show Gist options
  • Save x2c3z4/c5d6fd8a8b02ea7556a22cb5891e335b to your computer and use it in GitHub Desktop.
Save x2c3z4/c5d6fd8a8b02ea7556a22cb5891e335b to your computer and use it in GitHub Desktop.
Google Cloud Platform : ip address range
#!/bin/bash
# https://cloud.google.com/compute/docs/faq#ipranges
#nslookup -q=TXT _cloud-netblocks.googleusercontent.com 8.8.8.8
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
# changing target to _spf.google.com, you can get a simliar range now for Google Apps mail servers.
# https://support.google.com/a/answer/60764
# changing it to _netblocks.google.com will help get all the ip ranges google uses for its services.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment