#!/bin/bash ip1="1.1.1.2" e1="eth0" gw1="1.1.1.1" ip2="2.2.2.2" e2="eth1" gw2="2.2.2.1" ################################################# ### 上面的配置要改改 ### 下面就不要动了 ################################################# rt="/etc/iproute2/rt_tables" echo "252 cnc " >> $rt echo "251 tel " >> $rt rclocal="/etc/rc.local" echo "ip route flush table tel" >> $rclocal echo "ip route add default via $gw1 dev $e1 src $ip1 table tel" >> $rclocal echo "ip rule add from $ip1 table tel" >> $rclocal echo "ip route flush table cnc" >> $rclocal echo "ip route add default via $gw2 dev $e2 src $ip2 table cnc" >> $rclocal echo "ip rule add from $ip2 table cnc" >> $rclocal