LinuxQuestions.org
Review your favorite Linux distribution.
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 12-07-2011, 06:59 AM   #1
adamk75
Senior Member
 
Registered: May 2006
Posts: 3,091

Rep: Reputation: 399Reputation: 399Reputation: 399Reputation: 399
Routing return traffic based on the NIC of the incoming traffic?


I have host A with two NICs. One NIC(1) is at 192.168.0.36, the other NIC(2) is directly on the internet. The default route for host A is the router on the internet (so traffic is routed through NIC(2). Host B is at 192.168.0.10 and is a firewall connected to the internet, on a completely different subnet from host A, NIC(2). Host A and B have no problems connecting to each other over the 192.168.0.0 network.

I have a web server running on host A, bound to both NICs. I can connect to the server over the internet using the IP address for host A, NIC(2). The firewall on host B is configured to forward port 80 to 192.168.0.36. If I try to bring up the web page by connecting to the external IP address on that firewall, though, it never comes up. Packets obviously reach host A, though, as tcpdump on host A shows:

Code:
07:50:16.582844 IP some-remote-machine-on-the-internet-that-I-am-testing-from.34458 > 192.168.0.36.www: S 1006697601:1006697601(0) win 14600 <mss 1460,sackOK,timestamp 1027543073 0,nop,wscale 4>
Now, if I change the route for some-remote-machine-on-the-internet-that-I-am-testing-from to 192.168.0.10, the page will come up. If I change the default route for all network traffic to 192.168.0.10, anyone connecting to the external IP address on the firewall will get the web page. But then, of course, any attempted connection to the IP address on NIC(2) will fail.

Is it possible to have host A route data through a specific route/nic depending on the NIC the connection originates from?
 
Old 12-07-2011, 03:08 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,130

Rep: Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639
I am not sure I fully understand this. For the most part you can't easily select a nic for outgoing and a nic for incomming. IT can be done but this isn't what I think you are asking.

You can only use tcp/ip rules to route traffic. If nic a connects to a server then it has to by the rules of routing. Same for nic b. Nic a and nic b can't usually connect to this server because of rules both in hardware and software. Only one nic will take over.


We get back to a few issues. One is how tcp/ip works and how routers work and how a layer 7+ can work. My guess is you could use a layer 7+ router or some specialized device to then choose routes but a normal linux install doesn't easily allow that. And there is no normal reason.

Again I may misunderstand what you are trying to do.
 
Old 12-07-2011, 03:11 PM   #3
adamk75
Senior Member
 
Registered: May 2006
Posts: 3,091

Original Poster
Rep: Reputation: 399Reputation: 399Reputation: 399Reputation: 399
Yeah, I don't think I made it very clear, but that's alright... I've configured the firewall to route port 80 to a machine that is only on the internal network, and has squid running a reverse http proxy to connect to the webserver in question.

Now to see if I can find a reverse ftp proxy. That would make my day :-)

Adam
 
Old 12-11-2011, 04:27 AM   #4
TimothyEBaldwin
Member
 
Registered: Mar 2009
Posts: 249

Rep: Reputation: 27
You can use "ip rule" to select an alternative routing table by source address.
 
  


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
[SOLVED] 2 NIC's 2 seperate networks, traffic routing kamaradski1 Linux - Networking 5 12-26-2011 07:01 AM
Routing incoming traffic to NAT'ed VM on a hired dedicated server merlininthewood Linux - Networking 2 05-21-2010 03:30 PM
[HELP] redirect traffic to spesific port based on Traffic Content using iptables summersgone Linux - Server 2 06-22-2009 11:26 AM
port based routing for local traffic houska Linux - Networking 2 05-24-2009 07:10 AM
Allow Incoming Traffic clarence1720 Mandriva 15 12-06-2004 11:26 PM

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

All times are GMT -5. The time now is 03:36 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