LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-13-2009, 07:46 PM   #1
baba_jaga
LQ Newbie
 
Registered: Oct 2007
Posts: 1

Rep: Reputation: 0
2 NIC's - one gateway, setup Static route to Host


Dear All,

Situation:
Box (kernel 2.6.27) with 2 NIC's behind a router(gw).

eth1 (NIC1):
192.168.1.100/16

gw (to the net):
192.168.0.1/16

the gw properly set up as the default gateway for eth1.

I would like to use eth2 (NIC2) to connect to one specific remote internet server: www.remoteserver.com:443

The catch is that I need to be able to connect with eth1 to the internet,
as well as / or at least to the same www.remoteserver.com:993

Since there seems to be no applications for 2 NIC's accessing the same gateway I couldn't find any useful Howto's or solutions.

I made two attempts to solve this task:
First was:
# ifconfig eth2 192.168.0.100 netmask 255.255.0.0 up
# route add -host IP<www.remoteserver.com> gw 192.168.0.1 eth2

however, there is no way to access www.remoteserver.com from eth1 (since eth2 becomes the preferred route for accessing remoteserver.com)

so I tried an experiment by erasing the default route for eth1 and instead adding
# route add -host IP<www.remoteserver.com> gw 192.168.0.1 eth1

which left me with 4 entries in the routing tab. 2 of them to access the subnet and the other 2 for accessing www.remoteserver.com from eth1 and eth2 via 192.168.0.1(gw)

In both cases I then tried to establish a connection with stunnel and bind it to a the eth1 and eth2 IP

$ stunnel -c -f -I 192.168.0.100 -d localhost:10443 -r www.remoteserver.com:443

$ stunnel -c -f -I 192.168.1.100 -d localhost:10993 -r www.remoteserver.com:993

but the result was always that one of the devices was chosen by the kernel to perform the both data transfers. (which is the default behavior of the linux kernel, so I'm not whining about it

Is there a way to do such a 'static' load balancing by dest. IP that I'm looking for, and can I make both NIC's talk to the gw?

I'm guessing there is, if and only if I don't attempt to access the same IP (www.remoteserver.com) with both NIC's.
If I do, the only way seems to be to filter the incoming packets with iptables by dest. port.

Sorry for the long post, I tried to make it as clear as I could.
Thanks for any help.
 
Old 04-14-2009, 02:05 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
iptables and packet marking is probably the best way to do this. You say that if you see a packet looking to leave the system which hits an iptables rule matching the ip and dest port then mark it with "2" or something, then use a seperate routing table which just throws everything out of your 2nd nic, bearing in mind that nothing will use that table by default.
 
  


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
can I setup a personal route through a server to a gateway using iptables wastingtime Linux - Networking 1 04-20-2008 07:41 PM
Two NIC's on same subnet/gateway TBKDan Linux - Networking 4 04-06-2007 10:20 PM
IP_forward? Static route (-host)? HELP! haiders Linux - Networking 2 09-18-2006 01:45 PM
Two NIC's for filtered gateway Markild Linux - Networking 8 12-04-2005 11:22 AM
nfs setup on slack 9.1 - no route to host daceo Slackware 2 02-19-2004 05:04 PM


All times are GMT -5. The time now is 01:51 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration