Linux下双网卡-双外网网关-电信联通双线主机设置

本文详细介绍了如何通过运营商提供的智能DNS,配置不同的路由表,将电信和联通用户的网络请求分别引导至对应的网卡,从而实现快速的数据传输和优化的网络访问体验。通过在`/etc/iproute2/rt_tables`中增加特定路由表,以及在启动脚本中设置相应的路由规则,确保了不同运营商用户的数据能够高效地通过最短路径传输。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、实现:通过运营商提供的智能DNS,把电信用户访问时,数据进电信的网卡,出来时也从电信的网关出来,访问联通时,从联通网卡时,联通网卡出。这样速度就会快,实现双线主机的功能。

2、网卡信息:
电信IP(TEL):114.80.0.4 netmask 255.255.255.128 gateway 114.80.0.3
联通IP(CNC):112.65.0.2 netmask 255.255.255.0 gateway 112.65.0.1

3、vi /etc/iproute2/rt_tables,增加网通和电信两个路由表
251 tel   电信路由表
252 cnc   网通路由表

4、设置电信的路由表
ip route flush table tel    #清空路由表
ip route add default via 114.80.0.3 dev eth0 src 114.80.0.4 table tel
ip rule add from 114.80.0.4 table tel

5、设置联通的路由表
ip route flush table cnc
ip route add default via 112.65.0.1 dev eth1 src 112.65.0.2 table cnc
ip rule add from 112.65.0.2 table cnc

6、配置network启动脚本文件 在结尾exit 0之前增加如下内容:
# vi /etc/rc.d/init.d/network

ip route flush table tel
ip route add default via 114.80.0.3 dev eth0 src 114.80.0.4 table tel
ip rule add from 114.80.0.4 table tel

ip route flush table cnc
ip route add default via 112.65.0.1 dev eth1 src 112.65.0.2 table cnc
ip rule add from 112.65.0.2 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值