Идеята е, че имаме доставчика (в този случай) и искаме да разпределим връзката между тях, чрез iproute. Това решение разбира се, не е особено добро, но за временно решение става. Ето го и решението:
#!/bin/bash
#Create Multiple Uplinks. Written by amri [ www.mpetrov.net ]#ISP 1
isp0_ip=“10.10.10.2″;
isp0_gw=“10.10.10.1″;
isp0_network=“10.10.10.0/24″;
isp0_iface=“eth0″;
isp0_netmask=“255.255.255.0″;#ISP 2
isp1_ip=“192.168.1.2″;
isp1_gw=“192.168.1.1″;
isp1_network=“192.168.1.0/24″;
isp1_iface=“eth0:10″;
isp1_netmask=“255.255.255.0″;#Create tables
rt_tables=“/etc/iproute2/rt_tables“;
if [ `grep „ISP0“ $rt_tables|grep -v grep|wc -l` -eq 0 ];
then
echo „1 ISP0“ >> $rt_tables
fi;if [ `grep „ISP1“ $rt_tables|grep -v grep|wc -l` -eq 0 ];
then
echo „2 ISP1“ >> $rt_tables
fi;#Ifconfig
ifconfig $isp0_iface $isp0_ip netmask $isp0_netmask up
ifconfig $isp1_iface $isp1_ip netmask $isp1_netmask up#Create routes
ip route add $isp0_network dev $isp0_iface src $isp0_ip table ISP0
ip route add default via $isp0_gw table ISP0
ip route add $isp1_network dev $isp1_iface src $isp1_ip table ISP1
ip route add default via $isp1_gw table ISP1#Rules
ip rule add from $isp0_ip table ISP0
ip rule add from $isp1_ip table ISP1#Load balancing
ip route add default scope global nexthop via $isp0_gw dev $isp0_iface weight 1 \
nexthop via $isp1_gw dev $isp1_iface weight 1
Скриптчето може да се изтегли и от тук: create_multipe_uplinks.sh
Logged in as {{omniform_current_user_display_name}}. Edit your profile. Log out? Required fields are marked *
Your email address will not be published. Required fields are marked *
Comments are closed.
You must be logged in to post a comment.