Edvinas Valatka 9 лет назад
Родитель
Сommit
1df9f520cd
3 измененных файлов с 36 добавлено и 0 удалено
  1. 18 0
      e-pullasn
  2. 8 0
      e-pullasn.service
  3. 10 0
      e-pullasn.timer

+ 18 - 0
e-pullasn

@@ -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

+ 8 - 0
e-pullasn.service

@@ -0,0 +1,8 @@
+[Unit]
+Description=Update goodips ipset  from whois.radb.net
+Requires=iptables.service e-router.service
+After=iptables.service e-router.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/e-pullasn

+ 10 - 0
e-pullasn.timer

@@ -0,0 +1,10 @@
+[Unit]
+Description=e-pullasn timer
+
+[Timer]
+OnUnitActiveSec=42000
+OnBootSec=300
+
+[Install]
+WantedBy=timers.target
+