Linux 多线接入路由器设置求教

2020-02-24 14:57:13 +08:00
 gearfox
想用 centos 搭个软路由,不想使用现有的软路由程序,查了下需要策略路由来实现,配了下没有通,请大家看看

比如服务器 4 个网卡接口,虚拟机拓扑为:
内网 192.168.1.254 网关是自身 网卡 eth0
电信 22.22.22.22 网关 22.22.22.1 网卡 eth1
联通 33.33.33.33 网关 33.33.33.1 网卡 eth2
移动 44.44.44.44 网关 44.44.44.1 网卡 eth3

/etc/iproute2/rt_tables 设置
100 LAN
101 Telecom
102 Unicom
103 Mobile

#内网
这里内网如何写规则呢??

#电信线路
/etc/sysconfig/network-scripts/route-eth1
default via 22.22.22.1 src 22.22.22.22 dev eth1 table Telecom
/etc/sysconfig/network-scripts/rule-eth1
from 22.22.22.22 table Telecom

#联通线路
/etc/sysconfig/network-scripts/route-eth2
default via 33.33.33.1 src 33.33.33.33 dev eth2 table Unicom
/etc/sysconfig/network-scripts/rule-eth2
from 33.33.33.33 table Unicom

#移动线路
/etc/sysconfig/network-scripts/route-eth3
default via 44.44.44.1 src 44.44.44.44 dev eth3 table Mobile
/etc/sysconfig/network-scripts/rule-eth3
from 44.44.44.44 table Mobile


还有个问题,请问如何匹配电信、联通、移动的路由表,实现内网访问某运营商,走特定线路呢?
谢谢大家了。
1025 次点击
所在节点    宽带症候群
2 条回复
gearfox
2020-02-24 20:36:05 +08:00
再求一次
JackMa888
2020-02-27 16:11:16 +08:00
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.254 eth0
route add -net 22.22.22.22 netmask 255.255.255.0 ge 22.22.22.1 eth1
route add default gw 22.22.22.1 eth1
指定网关即可!

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/647103

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX