LinuxQuestions.org
Register a domain and help support LQ
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-11-2012, 09:42 AM   #1
abentkov
LQ Newbie
 
Registered: Dec 2012
Posts: 3

Rep: Reputation: Disabled
Simple port forwarding question


Hi folks,
Not a guru by any means and everything i have learned on linux is from google and search. Now this one i cant seem to find an answer to.

Scenario: Centos 5.
I have a service running on port 11111 and 22222. I have incoming connections from different IPs to these two ports. Now I need to merge them and forward all incoming 11111 to 22222.

So from different perspective, a user connecting on 11111 would connect to xx.xx.xx.xx:11111 but would be connected to xx.xx.xx.xx:22222

Any help would be appreciated.
 
Old 12-11-2012, 10:50 AM   #2
blueh2o
Member
 
Registered: Jul 2011
Posts: 63

Rep: Reputation: 2
You could redirect the port using xinetd, or iptables could do this for you as well.
 
Old 12-11-2012, 11:10 AM   #3
abentkov
LQ Newbie
 
Registered: Dec 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
could you please let me know which method is easier? is there a guide i can read to quickly set this up?
 
Old 12-11-2012, 11:25 AM   #4
blueh2o
Member
 
Registered: Jul 2011
Posts: 63

Rep: Reputation: 2
To use xinetd, you would drop a file in to /etc/xinetd.d with a name of your choosing, containing something like the following:

Code:
service some-useful-name
{
    disable = no
    port = 11111
    socket_type = stream
    protocol = tcp
    wait = no
    user = nobody
    redirect = xx.xx.xx.xx 22222
}
Make sure xinetd is set to start at boot and is running:
Code:
# chkconfig xinted on
# service xinetd start
Here's a useful guide for redirecting with iptables:

http://www.cyberciti.biz/faq/linux-p...with-iptables/
 
Old 12-11-2012, 11:32 AM   #5
abentkov
LQ Newbie
 
Registered: Dec 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by blueh2o View Post
To use xinetd, you would drop a file in to /etc/xinetd.d with a name of your choosing, containing something like the following:

Code:
service some-useful-name
{
    disable = no
    port = 11111
    socket_type = stream
    protocol = tcp
    wait = no
    user = nobody
    redirect = xx.xx.xx.xx 22222
}
Make sure xinetd is set to start at boot and is running:
Code:
# chkconfig xinted on
# service xinetd start
Here's a useful guide for redirecting with iptables:

http://www.cyberciti.biz/faq/linux-p...with-iptables/
So if I have user db that are strictly for 11111 and migrate them over to db on 22222 anyone connecting on 11111 should be able to hit port 22222 correct?

also

for redirect = xx.xx.xx.xx 22222 would I do 127.0.0.1 22222 ?
 
Old 12-11-2012, 11:42 AM   #6
blueh2o
Member
 
Registered: Jul 2011
Posts: 63

Rep: Reputation: 2
Quote:
Originally Posted by abentkov View Post
So if I have user db that are strictly for 11111 and migrate them over to db on 22222 anyone connecting on 11111 should be able to hit port 22222 correct?
Yes.

Quote:
for redirect = xx.xx.xx.xx 22222 would I do 127.0.0.1 22222 ?
Try that.
 
  


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
simple port forwarding with iptables ratcateme Linux - Networking 1 01-12-2009 05:05 PM
simple port forwarding SPEEDEX Linux - Networking 1 09-28-2007 12:20 PM
Simple Port Forwarding Firewall - not forwarding MadTurki Linux - Security 14 04-09-2006 01:08 PM
Simple enough...iptables..port forwarding pembo13 Linux - Networking 4 07-19-2003 03:08 AM
How can I do simple port forwarding on RH9? yetalu Linux - Networking 4 07-14-2003 08:44 PM


All times are GMT -5. The time now is 12:52 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration