commit 7605e699d0826343f8bd0900f3288775d0afeedc Author: Alex Denes Date: Wed Oct 16 17:06:01 2024 +0000 Initial commit diff --git a/collect.sh b/collect.sh new file mode 100755 index 0000000..ba975d8 --- /dev/null +++ b/collect.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +IPV4_LIST=./ips-v4 +IPV6_LIST=./ips-v6 +ASLIST="" + +# Truncate +true > "$IPV4_LIST" +true > "$IPV6_LIST" + +ASLIST="$ASLIST 32934" # Facebook (Meta) +ASLIST="$ASLIST 16509" # Amazon (AWS) +ASLIST="$ASLIST 15169" # Google +ASLIST="$ASLIST 136907" # Huawei Cloud + +for ASN in $ASLIST; do + LIST="$(\ + curl -L \ + 'https://stat.ripe.net/data/announced-prefixes/data.json?resource=AS'"$ASN" | \ + jq -r '.data.prefixes[].prefix')" + + # Cheap trick to separate IPs + echo "$LIST" | grep '\.' >> "$IPV4_LIST" + echo "$LIST" | grep -v '\.' >> "$IPV6_LIST" +done + +# Sort from least specific to most +TMPFILE="$(mktemp -p /tmp)" +< "$IPV4_LIST" sort | uniq | sed 's;/;,;g' | xsv sort -s 2 -n | sed 's;,;/;g' > "$TMPFILE" +cp "$TMPFILE" "$IPV4_LIST" + +< "$IPV6_LIST" sort | uniq | sed 's;/;,;g' | xsv sort -s 2 -n | sed 's;,;/;g' > "$TMPFILE" +cp "$TMPFILE" "$IPV6_LIST" +rm -v "$TMPFILE"