LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-11-2014, 11:42 PM   #1
jazaman
LQ Newbie
 
Registered: Apr 2004
Posts: 3

Rep: Reputation: 0
Xinetd starting a daemon and redirecting


I want to forward xinetd connection to another local port (say 12345). I based my solution on CentOS/Redhat documentation Chapter 17. [TCP Wrappers and xinetd, article 17.4.3.3]. In the example the configuration starts a daemon and also redirects the traffic to a host: port. The doco say it should be able to forward to different port on the same system too.

My current goal is to starts a daemon (say testsmpp) at any connection on port 12345 and redirect the stream to a particular port (say 54321). The tricky bit is I don't want the daemon (testsmpp) to read from STDIN, instead it should be able to read from the port where the xinetd is forwarding the traffic to.

I created a service under /etc/service e.g

Code:
testsmpp    12345/tcp
And my xinetd configuration for the daemon is
Code:
    service testsmpp
    {
        sock_type =     stream
        protocol =      tcp
        wait =          no
        user =          root
        server =        /home/me/bin/testsmpp        
        redirect =      54321
    }
testsmpp listens on port 54321. The problem is when a connection made from outside, xinetd starts the daemon but do not forward the traffic to 54321. Once the server started I can connect directly to 54321 port but the connection made via xinetd (at port 12345) is not forwarded.

Is server and redirect tags are mutually exclusive? I looked at the discussion about xinet forking concurrent server but my motivation are slightly different. I want to listen for incoming connection on another port as the other application will communicate with the daemon on that port too in a distributed computing environment.

Any clues much appreciated.

Last edited by jazaman; 02-12-2014 at 03:25 AM. Reason: :P turned to an icon
 
Old 02-12-2014, 01:11 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,929

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
I believe the redirect needs to have an IP address i.e.
redirect = 127.0.0.1 54321
 
1 members found this post helpful.
Old 02-13-2014, 02:08 AM   #3
jazaman
LQ Newbie
 
Registered: Apr 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
I believe the redirect needs to have an IP address i.e.
redirect = 127.0.0.1 54321
Thanks michaelk, you are right that the IP address or the hostname needs to be present. After updating the config I ran into another issue.

I just found from the xinetd.conf man pages that if both the 'redirect' and 'server' attributes are present, 'redirect' attribute takes priority. So the binary specified with 'server' attribute will not start and I am observing exactly that. It sort of prevents me from achieving what I originally wanted to. I wanted to start testsmpp bound to a predefined port (say 54321) by the xinetd and redirect traffic to that port.

Is it achievable? Any other suggestions?
 
Old 02-13-2014, 08:35 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,599

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
why not just specify the port with "port=54321"
 
Old 02-13-2014, 11:29 PM   #5
jazaman
LQ Newbie
 
Registered: Apr 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jpollard View Post
why not just specify the port with "port=54321"
I am starting up a service(daemon?) and according to the xinetd.conf man page "if this attribute is specified for a service listed in /etc/services, it must be equal to the port number listed in that file"

The service listens to 12345 and any connection made to that port should be forwarded to 54321.

Last edited by jazaman; 02-13-2014 at 11:31 PM. Reason: fix port number
 
  


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
NTP and xinetd time daemon fakie_flip Linux - Software 8 11-17-2012 03:01 PM
Who invetn xinetd daemon and why lincoln.runwal Linux - Newbie 1 03-18-2009 06:11 AM
Regarding xinetd daemon rajesh_b Programming 5 01-19-2005 06:29 AM
using vsftpd through xinetd or as standalone daemon (performance) markus1982 Linux - Software 0 02-11-2003 01:35 PM
xinetd network daemon for Redhat 7 CaliKid Linux - General 1 11-20-2000 02:27 PM


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