Trying to understand relationship between Xinetd and Netcat - Networking

This is a discussion on Trying to understand relationship between Xinetd and Netcat - Networking ; Quick question. We have a xinetd entry that calls a script for service/port x/123. In the script a tunnel is started and then netcat is called by the following to redirect traffic from port 123 to 3322: nc localhost 3322 ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Trying to understand relationship between Xinetd and Netcat

  1. Trying to understand relationship between Xinetd and Netcat

    Quick question. We have a xinetd entry that calls a script for
    service/port x/123. In the script a tunnel is started and then netcat
    is called by the following to redirect traffic from port 123 to 3322:
    nc localhost 3322

    I know that netcat is redirecting traffic to localhost:3322, but how
    does IT know to redirect traffic from port 123 to netcat. After this
    is started I can see that netcat is started by ps -ef but it only
    shows "nc localhost 3322". How does netcat know to listen on port
    123. If it didn't know this then it should forward all traffic to
    localhost:3322.

    Any help is greatly appreciated,
    Brian

  2. Re: Trying to understand relationship between Xinetd and Netcat

    "cooper" schrieb
    > Quick question. We have a xinetd entry that calls a script
    > for service/port x/123. In the script a tunnel is started
    > and then netcat is called by the following to redirect traffic
    > from port 123 to 3322:
    > nc localhost 3322
    >
    > I know that netcat is redirecting traffic to localhost:3322,
    > but how does IT know to redirect traffic from port 123 to netcat.
    > After this is started I can see that netcat is started by ps -ef
    > but it only shows "nc localhost 3322". How does netcat know
    > to listen on port 123. If it didn't know this then it should
    > forward all traffic to localhost:3322.
    >

    netcat does not know, inetd(*) does. inetd is a wrapper that listens
    on a port and starts a program according to its configuration.
    The program that is started reads from stdin and writes to stdout,
    it is not aware that the input is coming from / going to the net.

    IMHO
    Martin

    (*) AFAIK xinetd behaves the same way.


  3. Re: Trying to understand relationship between Xinetd and Netcat

    On Fri, 14 Dec 2007 11:31:00 -0800, cooper wrote:

    > Quick question. We have a xinetd entry that calls a script for
    > service/port x/123. In the script a tunnel is started and then netcat
    > is called by the following to redirect traffic from port 123 to 3322: nc
    > localhost 3322
    >
    > I know that netcat is redirecting traffic to localhost:3322, but how
    > does IT know to redirect traffic from port 123 to netcat. After this is
    > started I can see that netcat is started by ps -ef but it only shows "nc
    > localhost 3322". How does netcat know to listen on port 123. If it
    > didn't know this then it should forward all traffic to localhost:3322.
    >
    > Any help is greatly appreciated,
    > Brian


    I'm not sure what your doing exactly... and since you can do port
    forwarding ( seems like that is what you are doing ) with xinetd...
    I really don't know what your doing...

    Anyway... xinetd ( and inetd ) are servers that listen on specified
    ports. When a tcp socket connection is made to one of these ports,
    they accept the incoming connection and they start a program
    ( or do something like port forwarding in the case of xinetd )

    It's the responsibility of the program to know what to do with the
    incoming data and when it sends data, it gets passed to xinetd ( or
    inetd ) and back to the client.... something like that.

    if you want to do simple port forwarding with xinetd... say that
    port 444 is open / available and you want connections to pubic_ip:444
    -> private_ip:123 then you'd do something like:

    service 444
    {
    flags = REUSE
    socket_type = stream
    protocol = tcp
    wait = no
    user = root
    redirect = 192.168.1.1 123
    disable = no
    }

    ( this probably won't work as is... but it's something like this.

    Not sure what your doing special / different with nc.

    jack

    --
    D.A.M. - Mothers Against Dyslexia

    see http://www.jacksnodgrass.com for my contact info.

    jack - Grapevine/Richardson

+ Reply to Thread