1.#vi /etc/iproute2/rt_tables (增加联通、电信、移动三个路由表)

   #添加

    10    cnc

    20    tel

    30    cmcc

2.需要使用到vconfig软件。首先yum安装vconfig

    yum install vconfig

3.#vi /etc/rc.local设置路由表内容

    #添加

        modprobe 8021q

        vconfig add eth0 60(联通)

        vconfig add eth0 113(电信)

        vconfig add eth0 120(移动)

        ifconfig eth0 0.0.0.0

        ifconfig eth0.60 联通IP netmask 子网掩码 up

        ifconfig eth0.113 电信IP netmask 子网掩码 up

        ifconfig eth0.120 移动IP netmask 子网掩码 up

        ip route add 电信IP所属子网/子网掩码的位数 dev eth0.113 src 电信IP table tel

        ip route add default via 电信网关 table tel

        ip rule add from 电信IP table tel

        ip route add 联通IP所属子网/子网掩码的位数 dev eth0.60 src 联通IP table cnc

        ip route add default via 联通网关 table cnc

        ip rule add from 联通IP table cnc

        ip route add 移动IP所属子网/子网掩码的位数 dev eth0.120 src 移动IP table cmcc

        ip route add default via 移动网关 table cmcc

        ip rule add from 移动IP table cmcc

        route add default gw 移动网关

为什么这里最后是移动网关?这里因为客户的是单线接入,而且是移动的IP,然后给了个电信的IP。

今天整理下发出来,大家补充下,谢谢!