Best way to route traffic based on what interface it came in on

I have two interfaces on a machine (eth0 and a TUN), and the machine's only job is to pass traffic between these two interfaces. I need to send the packets across the two interfaces no matter the IP/originating sender's IP.

Here are my problems, and my assumptions:

The network is flat, which stops me from single table routing. The packets will stop going across in both directions if the netmask isn't closed (, because the machines are all on the same subnet (by design... not mine). Also, I can't make the routes static because I don't know what the machine's IPs are on either end (They can change quickly). I was planning to use multiple routing tables to have two default routes for each interface, but the kernel doesn't have those config options turned on (I'm working on changing that, but since I don't have full control of the system, it's taking a while).

What is the easiest way to take every packet coming in from one interface, and pass it to the other interface (eth0 -> TUN and TUN -> eth0), no matter the IP. If the answer is policy routing, then I'll just focus on getting the kernel fixed, but I wanted to know other ways if they exist. Thank you for reading.

1 Like

I believe that you should go with a couple of IP rules based on the incoming interface and custom routing tables with default routes for each interface respectively.
Perhaps this is the only possible way, given the conditions of the problem.