• Пакетная загрузка правил роутинга

 #10266   IgorA100
 10 фев 2019, 21:56
http://ip.kentavr.com.ru/ip/public/rkn_w_pref.ip - агрегированный список IP адресов с префиксом
http://ip.kentavr.com.ru/ip/public/rkn_list.ip - чистый список IP адресов

Для OpenWRT:
Код: Выделить всё#!/bin/sh
IFACE_V='tap0'
FILE_LOCAL='/tmp/rkn.ip'
FILE_REMOTE='http://ip.kentavr.com.ru/rkn_w_pref.ip'

IP_V=`ip addr list $IFACE_V | grep "  inet " | head -n 1 | cut -d " " -f 6 | cut -d / -f 1`

while [ -z $IP_V ]
do
IP_V=`ip addr list $IFACE_V | grep "  inet " | head -n 1 | cut -d " " -f 6 | cut -d / -f 1`
sleep 2
done

#rutracker.org
/sbin/route add -net 195.82.146.214 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
/sbin/route add -net 185.81.128.108 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
#nnm-club.me
/sbin/route add -net 81.17.30.22 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
/sbin/route add -net 134.19.179.73 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
/sbin/route add -net 134.19.179.70 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
#freebfg.org
/sbin/route add -net 104.18.63.89 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
/sbin/route add -net 104.18.62.89 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
/sbin/route add -net 104.27.162.7 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
/sbin/route add -net 104.27.163.7 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
#Torrent.by
/sbin/route add -net 185.43.221.157 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
#Rutor.org
/sbin/route add -net 5.45.86.112 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
#Rutor.info
/sbin/route add -net 185.176.192.247 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
#Rutor.org (open-tor.org)
/sbin/route add -net 46.148.16.235 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
#Fast-Torrent.ru
/sbin/route add -net 5.45.71.49 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
#PickTorrent.com
/sbin/route add -net 179.43.156.36 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
#Megapeer.org
/sbin/route add -net 72.52.179.175 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
#linkedin.com
/sbin/route add -net 108.174.10.10 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
/sbin/route add -net 185.63.144.1 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
#archive.org
/sbin/route add -net 207.241.224.2 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
#Bitru.org
/sbin/route add -net 104.27.182.181 netmask 255.255.255.255 gw $IP_V dev $IFACE_V
/sbin/route add -net 104.27.183.181 netmask 255.255.255.255 gw $IP_V dev $IFACE_V

sleep 60
wget -q -O - $FILE_REMOTE > $FILE_LOCAL
sleep 5
/bin/cat $FILE_LOCAL | /usr/bin/awk '{printf("/sbin/route add %s gw "IP_V" dev "IFACE_V" \n",$0) | "/bin/sh" }' IP_V=$IP_V IFACE_V=$IFACE_V | xargs -n 2000


Для DD-WRT:
Код: Выделить всё#!/bin/sh
IFACE_V='tap1'
DNS_SRV='8.8.8.8'
DNS_PORT='53'

IP_V=`ifconfig $IFACE_V | grep "inet addr" | head -n 1 | cut -d : -f 2 | cut -d " " -f 1`

while [ ! -f /tmp/openvpncl/route-up.sh ]
do
sleep 1
done
while [ ! $IP_V ]
do
sleep 1
IP_V=`ifconfig $IFACE_V | grep "inet addr" | head -n 1 | cut -d : -f 2 | cut -d " " -f 1`
done
cd /tmp/openvpncl
cp route-up.sh route-up.sh.old
#route-up.sh.old > route-up.sh
#grep -v 'exit 0' route-up.sh.old > route-up.sh
echo "/sbin/route add -net $DNS_SRV netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#rutracker.org
echo "/sbin/route add -net 195.82.146.214 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
echo "/sbin/route add -net 185.81.128.108 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#nnm-club.me
echo "/sbin/route add -net 81.17.30.22 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#freebfg.org
echo "/sbin/route add -net 104.18.63.89 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
echo "/sbin/route add -net 104.18.62.89 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
echo "/sbin/route add -net 104.27.162.7 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
echo "/sbin/route add -net 104.27.163.7 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#Torrent.by
echo "/sbin/route add -net 185.43.221.157 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#Rutor.org
echo "/sbin/route add -net 5.45.86.112 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#Rutor.info
echo "/sbin/route add -net 185.176.192.247 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#Rutor.org (зеркало: open-tor.org)
echo "/sbin/route add -net 46.148.16.235 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#Fast-Torrent.ru
echo "/sbin/route add -net 5.45.71.49 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#PickTorrent.com
echo "/sbin/route add -net 179.43.156.36 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#Megapeer.org
echo "/sbin/route add -net 72.52.179.175 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#linkedin.com
echo "/sbin/route add -net 108.174.10.10 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
echo "/sbin/route add -net 185.63.144.1 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#2ip.ru
echo "/sbin/route add -net 178.63.151.224 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#archive.org
echo "/sbin/route add -net 207.241.224.2 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#Bitru.org
echo "/sbin/route add -net 104.27.182.181 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
echo "/sbin/route add -net 104.27.183.181 netmask 255.255.255.255 gw $IP_V dev $IFACE_V" >> route-up.sh
#Заворачиваем весь DNS трафик только на один DNS сервер через тунель
iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to $DNS_SRV:$DNS_PORT; iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to $DNS_SRV:$DNS_PORT; iptables -t nat -A POSTROUTING -j MASQUERADE

####echo "/usr/bin/wget -q -O - http://reestr.rublacklist.net/api/ips | /bin/sed -e 's/\;/\n/g' -e 's/\\\"//g' > /tmp/openvpncl/rkn.ip" >> route-up.sh
####echo "/usr/bin/wget -q -O - http://kentavr.com.ru/_pub_files/antizapret/rkn.ip > /tmp/openvpncl/rkn.ip" >> route-up.sh
echo "/usr/bin/wget -q -O - http://ip.kentavr.com.ru/antizapret/netlist.txt > /tmp/openvpncl/rkn.ip" >> route-up.sh
echo "/bin/cat /tmp/openvpncl/rkn.ip | /usr/bin/awk '{printf(\"/sbin/route add -net %s gw $IP_V dev $IFACE_V\n\",\$0) | \"/bin/sh\" }'" >> route-up.sh
echo "/bin/cat /proc/net/ip_conntrack_flush" >> route-up.sh
####echo "exit 0" >> route-up.sh
./route-up.sh

Или вот так добавлять большой файл с префиксом
Код: Выделить всёecho "/bin/cat /tmp/openvpncl/rkn.ip | /usr/bin/awk '{printf(\"/sbin/route add %s gw $IP_V dev $IFACE_V\n\",\$0) | \"/bin/sh\" }' | xargs -n 2000" >> route-up.sh