例如:
eth0=60.29.231.160 255.255.255.192 60.29.231.1 (网通IP)
eth1=114.80.66.145 255.255.255.192 114.80.66.1 (电信IP)
#vi /etc/iproute2/rt_tables (增加电信和网通两个路由表)
252 tel (电信)
251 cnc (网通)
#vi /etc/rc.d/rc.local (设置电信和网通路由表内容)
ip route replace default via 114.80.66.1 dev eth1 (默认路由线路)
ip route flush table tel (刷新tel路由表)
ip route add default via 114.80.66.1 dev eth1 src 114.80.66.145 table tel(添加回环地址)
ip rule add from 114.80.66.145 table tel (从114.80.66.145过来的,走 tel路由)
ip route flush table cnc
ip route add default via 60.29.231.1 dev eth0 src 60.29.231.160 table cnc
ip rule add from 60.29.231.160 table cnc
保存退出
#reboot ( 然后重启计算机即可 )
eth0=60.29.231.160 255.255.255.192 60.29.231.1 (网通IP)
eth1=114.80.66.145 255.255.255.192 114.80.66.1 (电信IP)
#vi /etc/iproute2/rt_tables (增加电信和网通两个路由表)
252 tel (电信)
251 cnc (网通)
#vi /etc/rc.d/rc.local (设置电信和网通路由表内容)
ip route replace default via 114.80.66.1 dev eth1 (默认路由线路)
ip route flush table tel (刷新tel路由表)
ip route add default via 114.80.66.1 dev eth1 src 114.80.66.145 table tel(添加回环地址)
ip rule add from 114.80.66.145 table tel (从114.80.66.145过来的,走 tel路由)
ip route flush table cnc
ip route add default via 60.29.231.1 dev eth0 src 60.29.231.160 table cnc
ip rule add from 60.29.231.160 table cnc
保存退出
#reboot ( 然后重启计算机即可 )