LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-11-2012, 08: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, 09:50 AM   #2
blueh2o
Member
 
Registered: Jul 2011
Distribution: CentOS, Ubuntu, Fedora, Solaris, RHEL, Debian
Posts: 100

Rep: Reputation: 3
You could redirect the port using xinetd, or iptables could do this for you as well.
 
Old 12-11-2012, 10: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, 10:25 AM   #4
blueh2o
Member
 
Registered: Jul 2011
Distribution: CentOS, Ubuntu, Fedora, Solaris, RHEL, Debian
Posts: 100

Rep: Reputation: 3
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, 10: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, 10:42 AM   #6
blueh2o
Member
 
Registered: Jul 2011
Distribution: CentOS, Ubuntu, Fedora, Solaris, RHEL, Debian
Posts: 100

Rep: Reputation: 3
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



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

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

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