Table of Contents

,

Получение диапазона IP адресов

Prerequisites

apt-get install jq netmask moreutils
wget -P ~/tmp https://gist.githubusercontent.com/kyxap1/5233d86a9649f142e0c894598d4d60b0/raw/b369cf61cea3f20cce96244c33e55a6da0c92b89/aggregate-cidr-addresses.pl
chmod +x ~/tmp/aggregate-cidr-addresses.pl

Google1

dig +short TXT _spf.google.com \
  | grep -oP "(?<=include:).+?\s" \
  | xargs dig +short TXT \
  | grep -oP "(?<=ip4:).+?\s" \
  | xargs netmask -s \
  | perl -pne 's#(.+)/(.+)#route \1 \2 vpn_gateway#'

Google2

wget -q https://www.gstatic.com/ipranges/goog.json -O - \
  | jq '.prefixes[] | select(.ipv4Prefix) | .ipv4Prefix' -r

Amazon

wget https://ip-ranges.amazonaws.com/ip-ranges.json -O - \
  | jq -r ".prefixes[].ip_prefix" \
  | ./tmp/aggregate-cidr-addresses.pl \
  | sort -V

Github

wget -O - https://api.github.com/meta \
  | jq -r ".hooks, .web, .api, .git, .pages, .importer | .[]" \
  | ./tmp/aggregate-cidr-addresses.pl \
  | sort -V