|
@@ -0,0 +1,18 @@
|
|
|
|
|
+#!/bin/bash
|
|
|
|
|
+((EUID == 0 )) || { echo "Need root"; exit 1; }
|
|
|
|
|
+set -euo pipefail
|
|
|
|
|
+CONFD=/etc/e-router
|
|
|
|
|
+source $CONFD/config
|
|
|
|
|
+
|
|
|
|
|
+tmp=$(mktemp)
|
|
|
|
|
+
|
|
|
|
|
+while read -r asn ; do
|
|
|
|
|
+ [[ "$asn" =~ ^[0-9]{1,}$ ]] || continue
|
|
|
|
|
+ whois -h whois.radb.net -- -K -T route -i origin AS${asn} >> $tmp
|
|
|
|
|
+done < $CONFD/WHITE.asn
|
|
|
|
|
+
|
|
|
|
|
+grep -Eo "([0-9.]+){4}/[0-9]+" $tmp | while read -r net ; do
|
|
|
|
|
+ ipset -! add $whiteset $net timeout $routettl
|
|
|
|
|
+done
|
|
|
|
|
+
|
|
|
|
|
+trap "/bin/rm -f ${tmp}" EXIT SIGHUP SIGINT SIGTERM
|