Linux小课堂开课了(7)-三线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小课堂开课了(7)-三线IP刷路由-移动-联通-电信

上一篇:@Controller和@RequestMapping和@RequestParam注解理解和区别


下一篇:Android 基础-2.0 拔打电话号码