LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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-02-2010, 11:02 AM   #1
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
Rinetd, socat or iptables - redirection question


Dear All.

I need redirect connections,which made to one IP of my Linux box but to about 100-200 different ports, let say from 50000 - 50150, to a different IPsort.
I want to choose destination IP by incoming connection port.

So I found rinetd, socat and, of course, iptables, also can do it with DNAT.

The question is - I need to set up about 100~200 rules for iptables, and for the rinetd. But rinetd will listen all those ports. I do not really know about socat, but think it will be something the same.

I need advice about it, what is better.
May be someone gives me better ideas.

Thanks in advance.
 
Old 12-02-2010, 04:20 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by nimnull22 View Post
I need to set up about 100~200 rules for iptables
Would using "-m multiport --dports 50000:50150", feeding into a chain composed of "-j REDIRECT" but without using "--to-ports" (ensuring not altering the destination port), work?
 
Old 12-03-2010, 02:55 AM   #3
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Original Poster
Rep: Reputation: 92
Sorry, but idea is to redirect different port to certain IP. For example: if connection comes to 50020 port of my router it forward it to 172.16.116.20:80, but if it comes to 50021 it will forward it to 172.16.120.30:3128...
I want to try to hide internal network IPs and ports from external visitors and I thought it will work.
It will be the long rules list, but iptables wont keep ports in "listen" state, rinetd will be listening all 100~150 ports.
I do not really care about it since connection to those port anyway goes through Linux box.

I do not know how iptables will like my 100~150 DNAT rules, but would prefer to use iptables.

Thanks.
 
Old 12-04-2010, 08:21 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by nimnull22 View Post
idea is to redirect different port to certain IP.
Ah OK, I misread that.


Quote:
Originally Posted by nimnull22 View Post
I do not know how iptables will like my 100~150 DNAT rules, but would prefer to use iptables.
As filtering is done on a "first match wins" basis you could optimize things by putting the most accessed rules first (like having "--state ESTABLISHED,RELATED" in the filter table above "-state NEW") after a while and while filtering requires CPU and RAM adding 100 to 150 rules should not pose a problem unless it's an underspecced machine swamped in traffic. I don't see however why you would want to obfuscate ports too (you've hidden the LAN IP already) as many services are expected on default ports (try 'getent services http' to see what I mean). For example forwarding external traffic on port TCP/80 to internal host 172.16.116.20 TCP/50020 makes sense but forwarding external traffic on port TCP/50021 to internal host 172.16.120.30 TCP/3128 doesn't as no client would expect a service to reside on ephemeral port TCP/50021.
 
Old 12-05-2010, 03:31 AM   #5
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Original Poster
Rep: Reputation: 92
Quote:
Originally Posted by unSpawn View Post
As filtering is done on a "first match wins" ...
Thank you for your suggestions. I really appreciate it. I will try it.

Quote:
Originally Posted by unSpawn View Post
...172.16.120.30 TCP/3128 ...
It was just an example. I wanted to be more clear.

Thanks again.
 
  


Reply



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
iptables redirection rexjenny Linux - Networking 2 03-26-2010 08:55 AM
IPTables redirection hazza96 Linux - Networking 8 02-16-2009 01:57 AM
iptables redirection? prayag_pjs Linux - Newbie 3 04-16-2008 11:10 PM
iptables redirection mallikk_in Linux - Networking 11 09-02-2007 01:00 AM
Help:iptables redirection swmok Linux - Networking 2 11-24-2004 07:47 AM

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

All times are GMT -5. The time now is 03:06 AM.

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