centos7下雙網卡電信、聯通雙通配置
2、網卡信息(配置兩條網卡信息時需要註釋掉一條網關,否則網絡將會中斷):
電信IP(TEL):1.82.236.21 netmask 255.255.255.240 gateway 1.82.236.17(em4)
聯通IP(CNC):113.200.100.231 netmask 255.255.255.240 gateway 113.200.100.225(em1)
3、vi /etc/iproute2/rt_tables,增加網通和電信兩個路由表
252 cnc 網通路由表
4、設置電信的路由表(命令行直接執行)ip route flush table tel
#清空路由表ip route add default 1.82.236.17 dev em4 src 1.82.236.21 table tel
ip rule add from 1.82.236.21 table tel
5、設置聯通的路由表ip route flush table cnc
ip route add default via 113.200.100.225 dev em1 src 113.200.100.231 table cnc
ip rule add from 113.200.100.231 table cnc
6、配置network啟動腳本文件 在結尾exit 0之前增加如下內容:# vi /etc/rc.d/init.d/network
ip route flush table tel ip route add default 1.82.236.17 dev em4 src 1.82.236.21 table tel ip rule add from 1.82.236.21 table tel ip route flush table cnc ip route add default via 113.200.100.225 dev em1 src 113.200.100.231 table cnc ip rule add from 113.200.100.231 table cnc exit 0
7、重啟系統或網絡可能失效,請加入啟動腳本:
如果是ubuntu/debian,系統啟動腳本是/etc/rc.local
如果是RedHat/centos,系統啟動腳本是/etc/rc.d/rc.local
如果是ubuntu/debian,網絡啟動腳本是/etc/init.d/networking
如果是RedHat/centos,網絡啟動腳本是/etc/rc.d/init.d/network
centos7下雙網卡電信、聯通雙通配置