標籤:網卡設定
1、實現:通過電訊廠商提供的智能DNS,把電信使用者訪問時,資料進電信的網卡,出來時也從電信的網關出來,訪問聯通時,從聯通網卡時,聯通網卡出。這樣速度就會快,實現雙線主機的功能。
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,增加網通和電信兩個路由表
251 tel 電信路由表
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 telip 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 telip 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 cncexit 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下雙網卡電信、聯通雙通配置