How to set up custom routes with 3 NICs

This is my network topology:

enter image description here

I want every data proxy incoming request to eth0 to reply via eth0 , as well eth1 will reply to the data coming into eth1 too...

Active Route :

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.110.1 0.0.0.0 UG 15 0 0 eth2
192.168.110.96 * 255.255.255.248 U 0 0 0 eth2
192.168.200.0 * 255.255.255.248 U 0 0 0 eth0
192.168.200.96 * 255.255.255.248 U 0 0 0 eth1

I tried with these commands but it's not working... :(

ip route flush table 2002
ip route flush table 2001
ip route add 10.10.8.0/22 dev eth0 src 192.168.200.2 table 2002
ip route add 192.168.100.0/24 dev eth0 src 192.168.200.2 table 2002
ip route add default via 192.168.200.1 table 2002
ip route add 10.10.8.0/22 dev eth1 src 192.168.200.101 table 2001
ip route add 192.168.100.0/24 dev eth1 src 192.168.200.101 table 2001
ip route add default via 192.168.200.100 table 2001
ip rule add from 192.168.200.2 table 2002
ip rule add from 192.168.200.101 table 2001

How should I proceed?

4

1 Answer

Now I know why I didn't understand... Routing is done on a network level and not on a port level. You need to sub-segment your network in 3 separate networks and bind each network to each network card and then have your router route the packets to the correct Ethernet port.

As each network card has its own network address, any packets coming in with a certain address will also go back out on that network.

E.g.:

  • eth0: 192.168.100.0/24 LAN
  • eth1: 192.168.101.0/24 Access Point
  • Eth3: Default gateway/24: ADSL modem

Then all traffic that is not for 192.168.0.0/16 will go out to the Internet and all local traffic will stay local.

To do port forwarding you have two options:

  1. If you add an additional piece of hardware like a Big-IP between the router and the server, that will be able to inspect the packets and depending on ports send stuff to Eth0 and Eth1 by changing the IP address on-the-fly and then the server will then again send it out on the correct interface, and the BigIP will then convert it back to whatever it was...

  2. You can also drop the router entirely and use the server as a router to accomplish the same thing, and then you just use iptables to inspect the packets and route them around.

But what you're trying to do is impossible (only using a hardware router and software routing in the server) as there is no notion of "HTTP/FTP" as that is on a port level... :-(

6

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like