1、拷贝到 /etc/rc2.d/,并且 chown 755 S30route
2、第一次运行之前,需要修改里面几个参数
P1, P2,
P1_NET
P2_NET
3、第一次运行之前,运行一下下面的命令:
echo 101 telecom >> /etc/iproute2/rt_tables
echo 102 netcom >> /etc/iproute2/rt_tables
#!/bin/bash
#
set -x
PATH=/sbin:/bin:/usr/sbin:/usr/bin
IPTABLES=”/sbin/iptables”
#interface
IF1=eth0
IF2=eth1
#gateway
P1=”222.185.245.129″
P2=”58.241.71.1″
#network
P1_NET=”222.185.245.128/25″
P2_NET=”58.241.71.0/25″
#route table
#echo 101 telecom >> /etc/iproute2/rt_tables
#echo 102 netcom >> /etc/iproute2/rt_tables
T1=telecom
T2=netcom
IP1=`ifconfig ${IF1} |awk ‘/inet addr/ {split($2,x,”:”);print x[2]}’`
IP2=`ifconfig ${IF2} |awk ‘/inet addr/ {split($2,x,”:”);print x[2]}’`
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 $P1_NET dev $IF1 src $IP1
ip route add $P2_NET dev $IF2 src $IP2
#ip route add default via $P1
ip rule add from $IP1 table $T1
ip rule add from $IP2 table $T2 |