3

I'm trying to test a ethernet bridging device. I have multiple ethernet ports on a linux box. I would like to send packets out one interface, say eth0 with IP 192.168.1.1, to another interface, say eth1 with IP 192.168.1.2, on the same subnet.

I realize that normally you don't configure two interfaces on the same subnet, and if you do the kernel routes directly to each interface, rather than over the wire. How can I override this behavior, so that traffic to 192.168.1.2 goes out the 192.168.1.1 interface, and visa-versa?

Thanks in advance!

4

2 回答 2

2

这是一个猜测,但我希望它朝着正确的方向发展。

按照以下方式制作更具体的路由表条目:

route add -host 192.168.1.2 dev eth0
route add -host 192.168.1.1 dev eth1

您可能还需要调整两个接口的accept_local配置——或all设置。(打开它可能会使您的机器更容易受到 IP 源欺骗攻击;请确保您在其他地方有良好的入口防火墙规则以防止出现问题。)(请参阅sysctl -a | grep accept_local我在说什么。)

于 2012-07-27T00:41:31.337 回答
0

我认为你的 Linux 中需要类似 Mac-Vlan 的东西。这不能仅通过 NAT 完成。阅读:http ://www.linuxjournal.com/article/7268 。

于 2012-07-27T00:40:42.663 回答