e-pullasn 473 B

1234567891011121314151617
  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. trap "/bin/rm -f ${tmp}" EXIT SIGHUP SIGINT SIGTERM
  8. while read -r asn ; do
  9. [[ "$asn" =~ ^AS[0-9]{1,}$ ]] || continue
  10. whois -h whois.radb.net -- -K -T route -i origin ${asn} >> $tmp
  11. done < $CONFD/WHITE.asn
  12. grep -Eo "([0-9.]+){4}/[0-9]+" $tmp | while read -r net ; do
  13. ipset -! add $whitenetset $net timeout $whitenetttl
  14. done