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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux小课堂开课了-三线IP刷路由-移动-联通-电信相关的知识,希望对你有一定的参考价值。

最近有客户需求,要在服务器上安装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小课堂开课了-三线IP刷路由-移动-联通-电信的主要内容,如果未能解决你的问题,请参考以下文章

Linux小课堂开课了-Centos7日常运维管理

Linux小课堂开课了(11)-CentOS7配置本地yum源

Linux小课堂开课了

Linux小课堂开课了

Linux小课堂开课了

Linux小课堂开课了