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!

1
  • This question is ill-suited to SO. But I'll take a stab anyways: use a NAT somewhere in the chain and you may be able to accomplish this. (not a traditional SNAT btw) Commented Jul 27, 2012 at 0:34

2 Answers 2

2

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.)

Sign up to request clarification or add additional context in comments.

2 Comments

I think the accept_local parameter is the key. I will report back
Any luck? If this isn't it, please flag your question and ask a moderator to migrate it to Server Fault. (I think it is also on-topic here, but the SF audience may know the kernel tunables better.)
0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.