| 123456789101112131415161718 |
- #!/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" =~ ^AS[0-9]{1,}$ ]] || continue
- whois -h whois.radb.net -- -K -T route -i origin ${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
|