How can configure linux routing to send packets out one interface, over a bridge and into another interface on the same box

拥有回忆 提交于 2019-12-09 19:29:40

问题


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!


回答1:


This is a guess, but I hope it is in the right direction.

Make more-specific routing table entries, along the lines of:

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

You may also need to fiddle with the accept_local configuration for both interfaces -- or the all setting. (Turning this on may make your machine more susceptible to IP source spoofing attacks; be sure you have good ingress firewall rules elsewhere to prevent trouble.) (See sysctl -a | grep accept_local for what I'm talking about.)




回答2:


I think you need something like Mac-Vlan in your Linux. This cannot be done with NAT only. Read this: http://www.linuxjournal.com/article/7268.



来源:https://stackoverflow.com/questions/11679814/how-can-configure-linux-routing-to-send-packets-out-one-interface-over-a-bridge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!