diff --git a/google/downloader.sh b/google/downloader.sh index c8400faa..0ac4298a 100755 --- a/google/downloader.sh +++ b/google/downloader.sh @@ -1,8 +1,10 @@ #!/bin/bash +# https://support.google.com/a/answer/60764 # https://cloud.google.com/compute/docs/faq#find_ip_range # From: https://github.com/pierrocknroll/googlecloud-iprange/blob/master/list.sh # From: https://gist.github.com/jeffmccune/e7d635116f25bc7e12b2a19efbafcdf8 +# From: https://gist.github.com/n0531m/f3714f6ad6ef738a3b0a set -euo pipefail set -x @@ -21,6 +23,23 @@ while [[ -n "${txt}" ]]; do ((idx++)) done +# get from other netblocks +get_dns_spf() { + dig @8.8.8.8 +short txt "$1" | + tr ' ' '\n' | + while read entry; do + case "$entry" in + ip4:*) echo "${entry#*:}" ;; + ip6:*) echo "${entry#*:}" ;; + include:*) get_dns_spf "${entry#*:}" ;; + esac + done +} + +get_dns_spf "_cloud-netblocks.googleusercontent.com" >> /tmp/netblocks.txt +get_dns_spf "_spf.google.com" >> /tmp/netblocks.txt + + # save ipv4 grep -v ':' /tmp/goog.txt > /tmp/google-ipv4.txt