e-pullasn 468 B

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