国内和香港IP地址/掩码/网关到网卡:eth0和eth1
eth0相关信息国内IP:14.17.65.76 255.255.255.192 14.17.65.65
eth1相关信息香港IP:45.124.27.46 255.255.255.128 45.124.27.1
IP的配置就不说详细说了,要将2个IP的网关都写上
#vi /etc/iproute2/rt_tables #增加下面香港和国内两个路由表,路由序号和路由名称不能和系统已有的重复
252 xhhk #香港
251 xhcn #国内
保存退出(:wq)
#vi /etc/rc.d/rc.local #设置香港和国内路由表内容,增加以下内容
ip route replace default via 14.17.65.65 dev eth0 #默认路由线路,这里默认走国内
ip route flush table xhcn #刷新xhcn路由表
ip route add default via 14.17.65.65 dev eth0 src 14.17.65.76 table xhcn #添加xhcn回环地址
ip rule add from 14.17.65.76 table xhcn #从14.17.65.76过来的走xhcn路由
ip route flush table xhhk #刷新xhhk路由表
ip route add default via 45.124.27.1 dev eth1 src 45.124.27.46 table xhhk #添加xhhk回环地址
ip rule add from 45.124.27.46 table xhhk #从45.124.27.46过来的走xhhk路由
保存退出(:wq)
reboot #重启
