Shorewall 4 接口设置

Shorewall 4 接口设置

我正在尝试使用 Arch 上的 shorewall 来管理具有 2 个本地网络和 2 个 ISP 连接的设置。最终,我希望来自本地网络 1(192.168.1.0/24 接口 enp5s0)的流量使用 ISP 1(76. ... 接口 enp6s0),来自本地网络 2(192.168.0.0/24 接口 enp7s0)的流量使用 ISP 2(99 ...接口enp3s0)。目前,我可以使其中一个工作,但不能同时工作,具体取决于哪个默认路由先出现:

output of `ip route ls` with sensitive information redacted:
default via 76.[rd].1 dev enp6s0  src 76.[rd].78  metric 203  mtu 576
default via 99.[rd].1 dev enp3s0  src 99.[rd].190  metric 205
76.[rd].0/24 dev enp6s0  proto kernel  scope link  src 76.[rd].78  metric 203  mtu 576
76.[rd].78 dev enp6s0  scope link  src 76.[rd].78
99.194.48.0/21 dev enp3s0  proto kernel  scope link  src 99.[rd].190  metric 205
99.[rd].190 dev enp3s0  scope link  src 99.[rd].190
192.168.0.0/24 dev enp7s0  proto kernel  scope link  src 192.168.0.1  metric 204
192.168.1.0/24 dev enp5s0  proto kernel  scope link  src 192.168.1.1  metric 202

通过上述输出,本地 1 将能够到达外部,但本地 2 则不能。如果第一行消失了,则反之亦然。我很确定多个默认路由是禁忌,即使有多个 ISP,但这就是 shorewall 的做法。

由于任何地方都没有这方面的示例,因此我将其基于 shorewall 的三接口示例。为了避免这篇文章过长,这里有每个相关海岸墙配置的粘贴链接:

Shorewall 关于此事的页面没有帮助,因为他们示例中的目标与我的目标非常不同。任何正确方向的指示将不胜感激。

答案1

确保不在 netctl 文件或任何其他文件中设置默认网关。如果使用 DHCP 获取 IP 地址,请确保禁用获取默认网关 (dhcpcd -G)。运行“ip route ls”应该不显示任何默认网关。只有“ip route show table all”才能列出每个 ISP 表的默认网关。像这样的东西:

default via 10.1.1.1 dev enp3s0  table ITC1  src 10.1.1.10
10.1.1.1 dev enp3s0  table ITC1  scope link  src 10.1.1.10
default via 10.1.2.1 dev enp4s0  table ITC2  src 10.1.2.10
10.1.2.1 dev enp4s0  table ITC2  scope link  src 10.1.2.10
default via X.X.X.X dev enp5s0  table MPLS  src X.X.X.X
X.X.X.X dev enp5s0  table MPLS  scope link  src X.X.X.X
default  table balance
    nexthop via X.X.X.X  dev enp5s0 weight 1
    nexthop via 10.1.1.1  dev enp3s0 weight 2
    nexthop via 10.1.2.1  dev enp4s0 weight 2

您还可以从 mangle 文件中删除条目,因为 rtrules 条目应该足以满足您的需要

相关内容