1.环境
eth0:192.168.6.2   网关192.168.6.1
eth1:192.168.7.2   网关192.168.7.1
centos5.7
2.配置网卡
vi /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=192.168.6.2
NETMASK=255.255.255.0
GATEWAY=192.168.6.1
vi /etc/sysconfig/network-scripts/ifcfg-eth1
IPADDR=192.168.7.2
NETMASK=255.255.255.0
3.配置路由
vi /etc/iproute2/rt_tables 添加
252 tel
251 cnc
4.配置路由
ip route flush table tel
ip route add default via 192.168.6.1 dev eth0 src 192.168.6.2 table tel
ip rule add from 192.168.6.2 table tel
ip route flush table cnc
ip route add default via 192.168.7.1 dev eth1 src 192.168.7.2 table cnc
ip rule add from 192.168.7.2 table cnc
OK~可用将以上命令添加到/etc/rc.local里,这样重启后就不用重新添加了...