Skip to content

Instantly share code, notes, and snippets.

@kinshasha
Created May 9, 2017 11:08
Show Gist options
  • Save kinshasha/6bce746d7273264bdcb8d7adf78cb017 to your computer and use it in GitHub Desktop.
Save kinshasha/6bce746d7273264bdcb8d7adf78cb017 to your computer and use it in GitHub Desktop.
GCP Netblock lookup tool for ipv4 and ipv6
#!/bin/bash
# https://cloud.google.com/compute/docs/faq#ipranges
for LINE in `nslookup -q=txt _cloud-netblocks.googleusercontent.com 8.8.8.8 | tr " " "\n" | grep include | cut -f 2 -d :`
do
nslookup -type=txt $LINE
done | tr " " "\n" | grep ip4 | cut -f 2 -d : | sort -n
#add v6 handling
nslookup -q=TXT _cloud-netblocks5.googleusercontent.com 8.8.8.8 | tr " " "\n" | grep ip6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment