multiple gateways in one server
# cat Set_Dual_Brigde_Network.sh
#!/bin/bash
# http://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.multiple-links.html
echo 1 T1 >> /etc/iproute2/rt_tables
echo 2 T2 >> /etc/iproute2/rt_tables
echo 3 T3 >> /etc/iproute2/rt_tables
T1=T1
T2=T2
T3=T3
IF1=br0
IF2=br2
IF3=br3
IP1=9.12.13.15
IP2=9.12.6.50
IP3=9.10.11.35
P1=9.12.13.1
P2=9.12.6.1
P3=9.10.11.1
P1_NET=13
P2_NET=6
P3_NET=11
ip route add $P1_NET dev $IF1 src $IP1 table $T1
ip route add default via $P1 table $T1
ip route add $P2_NET dev $IF2 src $IP2 table $T2
ip route add default via $P2 table $T2
ip route add $P3_NET dev $IF3 src $IP3 table $T3
ip route add default via $P3 table $T3
ip route add $P1_NET dev $IF1 src $IP1
ip route add $P2_NET dev $IF2 src $IP2
ip route add $P3_NET dev $IF3 src $IP3
ip rule add from $IP1 table $T1
ip rule add from $IP2 table $T2
ip rule add from $IP3 table $T3
#!/bin/bash
# http://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.multiple-links.html
echo 1 T1 >> /etc/iproute2/rt_tables
echo 2 T2 >> /etc/iproute2/rt_tables
echo 3 T3 >> /etc/iproute2/rt_tables
T1=T1
T2=T2
T3=T3
IF1=br0
IF2=br2
IF3=br3
IP1=9.12.13.15
IP2=9.12.6.50
IP3=9.10.11.35
P1=9.12.13.1
P2=9.12.6.1
P3=9.10.11.1
P1_NET=13
P2_NET=6
P3_NET=11
ip route add $P1_NET dev $IF1 src $IP1 table $T1
ip route add default via $P1 table $T1
ip route add $P2_NET dev $IF2 src $IP2 table $T2
ip route add default via $P2 table $T2
ip route add $P3_NET dev $IF3 src $IP3 table $T3
ip route add default via $P3 table $T3
ip route add $P1_NET dev $IF1 src $IP1
ip route add $P2_NET dev $IF2 src $IP2
ip route add $P3_NET dev $IF3 src $IP3
ip rule add from $IP1 table $T1
ip rule add from $IP2 table $T2
ip rule add from $IP3 table $T3
Comments
Post a Comment