Skip to content

Instantly share code, notes, and snippets.

@n0531m
Last active April 17, 2024 21:50
Show Gist options
  • Save n0531m/f3714f6ad6ef738a3b0a to your computer and use it in GitHub Desktop.
Save n0531m/f3714f6ad6ef738a3b0a to your computer and use it in GitHub Desktop.
Google Cloud Platform : ip address range
#!/bin/bash
# https://cloud.google.com/compute/docs/faq#find_ip_range
# nslookup -q=TXT _cloud-netblocks.googleusercontent.com 8.8.8.8
myarray=()
for LINE in `dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | cut -f 2 -d :`
do
myarray+=($LINE)
for LINE2 in `dig txt $LINE +short | tr " " "\n" | grep include | cut -f 2 -d :`
do
myarray+=($LINE2)
done
done
for LINE in ${myarray[@]}
do
dig txt $LINE +short | tr " " "\n"
done | grep ip4 | cut -f 2 -d : | sort -n +0 +1 +2 +3 -t .
# 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.
@f1-outsourcing
Copy link

@mosqueteiro, all IP range updates are in: https://github.com/lord-alfred/ipranges

I just had a look, nice to see you also have digital ocean.

However the goal for me to use the ip ranges varies. So all the scans for eg wordpress sites etc I like to block. Obviously I don't want to block search engine indexing of bing/google etc.

Real people that are browsing websites are not in the digital ocean cloud nor in azure, so blocking all that shit is good for the environment. You will clearly see less resource utilization. So it would be nice to see such distinction, although I don't really have yet an idea how to do this properly myself.

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