Linux小课堂开课了(7)-三线IP刷路由-移动-联通-电信

Linux小课堂开课了(7)-三线IP刷路由-移动-联通-电信,第1张

概述最近有客户需求,要在服务器上安装centos7 使用三线(移动-联通-电信),三个网卡分别配置,需要三个IP都可以正常通信,因为三个IP分别有各自的网关,直接配置,只能有一个IP可以正常通信,如此,就需要刷路由,直接将三个IP的网关都配置进去。目前三个IP的网关都是末尾为.1。如下,是刷路由的配置。 1、在/etc/rc.local里面加上 ip route replace default via 最近有客户需求,要在服务器上安装centos7
使用三线(移动-联通-电信),三个网卡分别配置,需要三个IP都可以正常通信,因为三个IP分别有各自的网关,直接配置,只能有一个IP可以正常通信,如此,就需要刷路由,直接将三个IP的网关都配置进去。目前三个IP的网关都是末尾为.1。如下,是刷路由的配置。
1、在/etc/rc.local里面加上
ip route replace default via 101.X.X.X dev em1
ip route replace default via 43.X.X.X dev em2
ip route replace default via 117.X.X.X dev em3
ip route flush table ctc
ip route add default via 101.X.X.1 dev em1 src 101.X.X.X table ctc proto static
ip rule add from 101.X.X.X table ctc
ip route flush table cnc
ip route add default via 43.X.X.1 dev em2 src 43.X.X.X table cnc proto static
ip rule add from 43.X.X.X table cnc
ip route flush table cmcc
ip route add default via 117.X.X.1 dev em3 src 117.X.X.X table cmcc proto static
ip rule add from 117.X.X.X table cmcc

2、在/etc/iproute2/rt_tables 里面加上

252 cmcc
251 cnc
250 ctc

3、在/etc/init.d/networking 加上
ip route replace default via 101.X.X.X dev em1
ip route replace default via 43.X.X.X dev em2
ip route replace default via 117.X.X.X dev em3
ip route flush table ctc
ip route add default via 101.X.X.1 dev em1 src 101.X.X.X table ctc proto static
ip rule add from 101.X.X.X table ctc
ip route flush table cnc
ip route add default via 43.X.X.1 dev em2 src 43.X.X.X table cnc proto static
ip rule add from 43.X.X.X table cnc
ip route flush table cmcc
ip route add default via 117.X.X.1 dev em3 src 117.X.X.X table cmcc proto static
ip rule add from 117.X.X.X table cmcc
4、reboot一下
测试都可以正常通信

未完,待续~

总结

以上是内存溢出为你收集整理的Linux小课堂开课了(7)-三线IP刷路由-移动-联通-电信全部内容,希望文章能够帮你解决Linux小课堂开课了(7)-三线IP刷路由-移动-联通-电信所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1020899.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存