Linux系统多线、三线、双线路由配置出口

问题概述

我们使用一台机器,接入多根网线,并配置多个运营商网络,需要指定相关出口

操作步骤

1、在末尾加入三张路由表

vi /etc/iprou***/rt_table

252 cucc
251 cmcc
250 tel

2、执行脚本设置路由(自行替换IP和网卡接口)

电信 IP地址:58.218.33.177 网关:58.218.33.1 网卡em2
移动 IP地址:36.149.88.37 网关:36.149.88.1 网卡em3
联通 IP地址:157.0.217.180 网关:157.0.217.1 网卡em4

把下面内容粘贴到:vi /etc/rc.local(在exit之前,保存)

#电信
ip route flush table tel
ip route add default via 58.218.33.1 dev em2 src 58.218.33.177 table tel
ip rule add from 58.218.33.177 table tel

#移动
ip route flush table cmcc
ip route add default via 36.149.88.1 dev em3 src 36.149.88.37 table cmcc
ip rule add from 36.149.88.37 table cmcc

#联通
ip route flush table cuc
ip route add default via 157.0.217.1 dev em4 src 157.0.217.180 table cucc
ip rule add from 157.0.217.180 table cucc

3、执行以下步骤

chmod +x /etc/rc.d/rc.local
systemctl enable rc-local.service
systemctl start rc-local.service

4、reboot 重启验证

THE END