LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Xinetd starting a daemon and redirecting (https://www.linuxquestions.org/questions/linux-newbie-8/xinetd-starting-a-daemon-and-redirecting-4175494596/)

jazaman 02-11-2014 10:42 PM

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.

michaelk 02-12-2014 12:11 PM

I believe the redirect needs to have an IP address i.e.
redirect = 127.0.0.1 54321

jazaman 02-13-2014 01:08 AM

Quote:

Originally Posted by michaelk (Post 5116331)
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?

jpollard 02-13-2014 07:35 AM

why not just specify the port with "port=54321"

jazaman 02-13-2014 10:29 PM

Quote:

Originally Posted by jpollard (Post 5116888)
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.


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