centos7下双网卡电信、联通双通配置

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 via 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 via 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

转载于:https://blog.51cto.com/xuchi/2108707

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值