Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
deb http://ftp.ru.debian.org/debian unstable main contrib non-free
APT::Default-Release "testing";
apt-get -t sid install bird
make -C /usr/ports/net/quagga/ install clean
echo 'quagga_enable="YES"' >> /etc/rc.conf
echo 'quagga_daemons="zebra"' >> /etc/rc.conf
echo 'ip route 0.0.0.0/0 em0 20' >> /usr/local/etc/quagga/zebra.conf
echo 'ip route 0.0.0.0/0 em1 10' >> /usr/local/etc/quagga/zebra.conf
service quagga start
pass in on $ext_if1 reply-to ($ext_if1 $ext_gateway1) from any to $ext_if1
pass in on $ext_if2 reply-to ($ext_if2 $ext_gateway2) from any to $ext_if2
nat on $ext_if1 from $lan_if:network to $ext_if1 -> {$ext_if1, $ext_if2}
nat on $ext_if2 from $lan_if:network to $ext_if2 -> {$ext_if1, $ext_if2}
pass out on $ext_if1 from $lan_if:network to any nat-to {$ext_if1, $ext_if2}
pass out on $ext_if2 from $lan_if:network to any nat-to {$ext_if1, $ext_if2}
#!/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
GW1=Шлюз первого аплинка
GW2=Шлюз второго аплинка
tester=0;
itest1=`/sbin/ping -c 3 $GW1 | grep "64 bytes" | wc -l`;
itest2=`/sbin/ping -c 3 $GW2 | grep "64 bytes" | wc -l`;
if [ ! -f "/tmp/countGW.tmp" ]
then
echo 3 > /tmp/countGW.tmp
fi
oldtest=`cat /tmp/countGW.tmp`
if (test $itest1 -gt "0")
then
let tester=tester+1
fi
if (test $itest2 -gt "0")
then
let tester=tester+2
fi
if [ $oldtest = $tester ]; then
exit;
#echo "Canali ne izmenilis"
else
if [ $oldtest = 3 ]; then
cp /etc/pf.conf /etc/pf.conf3
fi
if [ $tester = 3 ]; then
cp /etc/pf.conf3 /etc/pf.conf
/sbin/route change default $GW1
fi
if [ $tester = 2 ]; then
cp /etc/pf.conf2 /etc/pf.conf
/sbin/route change default $GW2
fi
if [ $tester = 1 ]; then
cp /etc/pf.conf1 /etc/pf.conf
/sbin/route change default $GW1
fi
/etc/rc.d/pf restart
fi
ext_if1="ip канала 1"
ext_if2="ip канала 2"
ext_gw1="Шлюз канала 1"
ext_gw2="Шлюз канала 2"
#{Тут какую сеть на какой канал, либо текущий рабочий канал для всех сетей}
#Этих через канал 2
nat on $ext_if1 from 192.168.3.0/24 to !<no_nat> -> $ext_if2
nat on $ext_if1 from 192.168.4.0/24 to !<no_nat> -> $ext_if2
#Остальных через канал 1
nat on $ext_if1 from 192.168.0.0/16 to !<no_nat> -> $ext_if1
pass out on $ext_if1 route-to ($ext_if2 $ext_gw2) from $ext_if2 to !<no_nat>
pass out on $ext_if2 route-to ($ext_if1 $ext_gw1) from $ext_if1 to !<no_nat>
route 0.0.0.0/0 multipath
via 10.10.10.1 weight 7
via 172.17.5.1 weight 3;
Домашний интернет: маршрутизация двух (и боле) провайдеров на основе Bird Routing Daemon