Operating System - Linux
1827918 Members
2284 Online
109971 Solutions
New Discussion

netcat started from xinetd vs. netcat on the command-line

 
Christian Deutsch_1
Esteemed Contributor

netcat started from xinetd vs. netcat on the command-line

Hi folks,

I'm trying to use netcat on the command line instead of netcat using xinetd and it is not yet working for me.

RHAS3U5 in a VM on an ESX server

Configuration in a file in /etc/xinetd.d:

service ovoagt383
{
disable = no
id = testserver_ovoagt383
flags = REUSE
bind = 19.157.64.64
socket_type = stream
protocol = tcp
wait = no
user = nobody
server = /usr/bin/nc
server_args = -w 3 192.168.105.3 ovoagt383
instances = 10
}

this setup works, I can issue a bbcutil -ping from another machine.

However, when I remove this entry from the file in /etc/xinetd.d and start netcat on the command line I get this error:

# nc -lnvv -p 383 -s 19.157.64.64 -w 3 192.168.105.3 383
listening on [19.157.64.64] 383 ...
invalid connection to [19.157.64.64] from (UNKNOWN) [19.157.71.118] 33021

As always points for helpful answers.

Thanks for any helpful insights or hints!

Christian
Yeshua loves you!
2 REPLIES 2
Stuart Browne
Honored Contributor

Re: netcat started from xinetd vs. netcat on the command-line

You're trying to use NC as a TCP proxy ?

I'm pretty sure that 'nc' can't do that using '-l'.

I did some tests with various different versions, and couldn't get it to work at all in this manner.

It's quite happy to listen on a port and display the text on STDOUT.. so maybe using a pipe you could achieve this.

If you do just want a TCP proxy, then get a dedicated service to do this (they exist, but I usually end up writing something in perl).
One long-haired git at your service...
Christian Deutsch_1
Esteemed Contributor

Re: netcat started from xinetd vs. netcat on the command-line

Dear Stuart,

Thank you very much for taking the time to comment!

As I mentioned, netcat IS working as a proxy when called by xinetd but it is NOT working properly when called from a shell using the -l option.

If I understood you right, maybe netcat works better accepting input from stdin via xinetd vs. listening on a port using the -l option? For our testing maybe we could use a perl script that listens on a port and forwards everything from that port to stdout, piped into netcat and vice versa? Do you think this might work?

We are testing/debugging some network behaviour and would like to understand precisely WHY netcat is failing us in certain situations (use case A vs. use case B even when both use cases are via xinetd).

Thanks for any helpful insights, Christian
Yeshua loves you!