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

被折叠的 条评论
为什么被折叠?



