LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-02-2009, 04:37 PM   #1
nkhambal
LQ Newbie
 
Registered: Mar 2005
Posts: 8

Rep: Reputation: 1
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.
 
Old 09-03-2009, 02:10 PM   #2
nkhambal
LQ Newbie
 
Registered: Mar 2005
Posts: 8

Original Poster
Rep: Reputation: 1
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.
 
Old 09-03-2009, 03:36 PM   #3
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Rep: Reputation: 32
Quote:
Originally Posted by nkhambal View Post
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
 
Old 09-03-2009, 06:06 PM   #4
nkhambal
LQ Newbie
 
Registered: Mar 2005
Posts: 8

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by Hewson View Post
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,
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
building a router with multiple nics (no external switch) xtravar Linux - Networking 2 07-19-2009 01:39 PM
Linux router + route table + 3 identical nics props666999 Debian 2 02-08-2008 03:41 AM
Using two nics, need default route? pridefc Linux - Networking 5 03-12-2007 10:35 PM
route any traffic between two NICs thirumala Linux - Networking 0 03-24-2004 05:54 PM
2 NICs, 2 external IP's (1 behind a router) yskwong Linux - Networking 5 05-25-2001 07:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration