有一台网关服务器,须要配置电信联通两条线路,以保证电信和联通用户的访问速度bash
rt_tables
文件echo 201 telnet-line >> /etc/iproute2/rt_tables
ip route add 222.171.246.0/24 dev eth0 src 222.171.246.150 table telecom-line ip route add default via 222.171.246.254 dev eth0 table telecom-line ip rule add from 222.171.246.150 table telecom-line ip rule add to 222.171.246.150 table telecom-line
至此所有配置以完成,访问电信IP的用户会自动从电信线路返回。其他的都会从联通线路返回。服务器
测试没有问题咱们能够把以上IP加入启动脚本里/etc/rc.local
测试
# routing policy for telecom line ip route add 222.171.246.0/27 dev eth0 src 222.171.246.150 table telecom-line ip route add default via 222.171.246.254 dev eth0 table telecom-line ip rule add from 222.171.246.150 table telecom-line ip rule add to 222.171.246.250 table telecom-line