LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Route the traffic between two NICs via an external router (https://www.linuxquestions.org/questions/linux-networking-3/route-the-traffic-between-two-nics-via-an-external-router-752212/)

nkhambal 09-02-2009 04:37 PM

Route the traffic between two NICs via an external router
 
Hi,

I have this topology.

eth1 eth3
[Lnx1]<------>[RTR1]<-------->[RTR2]<------>[Lnx2]

Lnx1 and Lnx2 are 2 different NICs on same Linux box.

Lnx1 IP: a.b.1.2
Lnx2 IP: x.y.1.2

Their respective local gateways on the RTR1 and RTR2 are a.b.1.1 and x.y.1.1 respectively.

Now my requirement is to be able to route the traffic originated from Lnx1 IP to Lnx2 IP and vice versa via the 2 routers in the middle (instead of switching it internally within the box).

I followed some tutorial on internet and configured below commands.

Adding 2 new route tables.

echo 1 dhclient >> /etc/iproute2/rt_tables
echo 2 dhserver >> /etc/iproute2/rt_tables

Adding default and then host route for remote Lnx IP in each table.

Lnx1:
=====
ip route add default via a.b.1.1 dev eth1 table dhclient
ip route add x.y.1.2 via a.b.1.1 dev eth1 table dhclient
ip route add x.y.1.1 via a.b.1.1 dev eth1 table dhclient

Lnx2:
=====
ip route add default via x.y.1.1 dev eth3 table dhserver
ip route add a.b.1.1 via x.y.1.1 dev eth3 table dhserver
ip route add a.b.1.2 via x.y.1.1 dev eth3 table dhserver


Adding rules to route traffic for remote IPs

Lnx1:
=====
ip rule add to x.y.1.1/32 table dhclient

Lnx2:
=====
ip rule add to a.b.1.1/32 table dhserver

Everything looks correctly configured

[root@localhost root]# ip route show table dhclient
x.y.1.1 via a.b.1.1 dev eth1
x.y.1.2 via a.b.1.1 dev eth1
default via a.b.1.1 dev eth1
[root@localhost root]# ip route show table dhserver
a.b.1.2 via x.y.1.1 dev eth3
a.b.1.1 via x.y.1.1 dev eth3
default via x.y.1.1 dev eth3
[root@localhost root]#

[root@localhost root]# ip rule show
0: from all lookup local
32762: from all to a.b.1.1 lookup dhserver
32763: from all to x.y.1.1 lookup dhclient
32764: from all to a.b.1.0/24 lookup dhserver
32765: from all to x.y.1.0/24 lookup dhclient
32766: from all lookup main
32767: from all lookup 253
[root@localhost root]#


When I ping from Lnx1 to RTR2's IP from the interface towards Lnx2, the traffic seems to be taking correct path from Lnx1->RTR1->RTR1. However, when I ping the Lnx2's IP itself from Lnx1, the traffic seem to getting switched locally inside the box. I want it to take the path
Lnx1-->RTR1-->RTR2--->Lnx2.

Any idea how to do this?

I am wondering if this is because in rules hierarchy, it is looking up table "local" before my custom tables. Local table has the direct route for lnx1 and lnx2 IP addresses on the NICs.

If this is the case then is the a way to move the "local" table lookup at the end of the hierarchy?


Appreciate the inputs.

Thanks,
Nilesh.

nkhambal 09-03-2009 02:10 PM

Anyone???

I am about to give up now and put another Linux host in place of Lnx2. Have tried most of the things but could not make it work.

Hewson 09-03-2009 03:36 PM

Quote:

Originally Posted by nkhambal (Post 3667382)
I followed some tutorial on the internet and configured below commands.

Hi, looks like we are trying to achieve the same thing. Could you provide the guide you used?

Unfortunately I can't provide you with much of a solution

nkhambal 09-03-2009 06:06 PM

Quote:

Originally Posted by Hewson (Post 3668755)
Hi, looks like we are trying to achieve the same thing. Could you provide the guide you used?

Unfortunately I can't provide you with much of a solution

I tried this

http://linux-ip.net/html/index.html

Thanks,


All times are GMT -5. The time now is 11:41 PM.