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 12-01-2007, 02:35 PM   #1
ardora
LQ Newbie
 
Registered: Dec 2007
Posts: 3

Rep: Reputation: 0
Question Source based policy routing with one NIC


Greetings,

I know I am new here, but I have seriously tried for quite some time (weeks) to figure this out myself but I can't seem to get it to work.

Here's what I have:

- a Virtual Private Server (running Ubuntu) which I have root ssh access to

- a single external IP address to the internet

- a piece of server software that runs as expected right now, but I can select the ip address and port that it listens on
NOTE: This uses TCP packets, but does NOT use an HTTP layer.

- clients that need to connect to the server

What I want to do:
Run multiple copies of the server software on different ip addresses or ports and have different groups of clients connect to different processes.

How I want it to behave (ideally):
I now believe this is impossible (until IPv6 is the norm), but I want traffic directed to different copies of the software based on subdomains.

How I want it to behave (realistically):
Route the traffic to different copies of the software based on the source address of the client. I believe this is possible using the iproute2 package but I haven't been able to find a tutorial or example or any documentation relating closely enough to my situation. They mostly depend on having multiple NICs.

My questions:
How can I route based on source IP address to a specific port on either the NIC or the loopback, such that different copies will be able to listen on different ports?

Failing that, is it possible to set up multiple loopback adapters so that the different copies can listen on different IP addresses? How would I implement this? How would I route the traffic to these different IP addresses?


Thanks everyone in advance for your replies.

EDIT:
PS - The server needs to get data back to the clients as well, so this will probably require some additional routing rules.

Last edited by ardora; 12-01-2007 at 02:42 PM.
 
Old 12-01-2007, 04:15 PM   #2
rupertwh
Member
 
Registered: Sep 2006
Location: Munich, Germany
Distribution: Debian / Ubuntu
Posts: 297

Rep: Reputation: 49
Hi,

it's much easier than that. But it won't work based on subdomains (or hostnames in general), just based on ip addresses or subnets.

E.g.:
Code:
iptables -t nat -I PREROUTING -i eth1 --src 192.168.30.0/24 -p tcp --dport 3333 -j DNAT --to :8888
will redirect all tcp traffic coming from 192.168.30.x through eth1 from port 3333 to port 8888.
 
Old 12-02-2007, 07:57 AM   #3
ardora
LQ Newbie
 
Registered: Dec 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks, I'll give it a try today.

Hopefully it works, I'll post back here if it did or not.
 
Old 12-02-2007, 08:02 AM   #4
ardora
LQ Newbie
 
Registered: Dec 2007
Posts: 3

Original Poster
Rep: Reputation: 0
And yes, I was disappointed that you need http packets to process subdomains. We really need IPv6 now.
 
  


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
policy rule routing problem - help me pandanvn Linux - Networking 3 04-02-2007 06:24 PM
policy rule routing problem - help me pandanvn Linux - Networking 0 03-16-2007 12:03 AM
Policy routing using marks Xeta Linux - Networking 0 05-24-2006 06:22 PM
help with policy based routing GaijinPunch Linux - Networking 4 06-19-2005 06:35 PM
[help] RH Network Routing Policy princenux Linux - Networking 1 07-04-2004 10:34 AM

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

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