Networking Forums

Networking Forums > Computer Networking > Linux Networking > Trying to understand relationship between Xinetd and Netcat

Reply
Thread Tools Display Modes

Trying to understand relationship between Xinetd and Netcat

 
 
cooper
Guest
Posts: n/a

 
      12-14-2007, 06:31 PM
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
 
Reply With Quote
 
 
 
 
Martin Blume
Guest
Posts: n/a

 
      12-14-2007, 06:49 PM
"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.

 
Reply With Quote
 
Jack Snodgrass
Guest
Posts: n/a

 
      12-14-2007, 07:54 PM
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 With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use netcat??? Kolyn_Kryw Windows Networking 1 04-11-2008 04:14 PM
netcat for win2k Mike - EMAIL IGNORED Linux Networking 3 03-09-2006 10:57 PM
Netcat broadcasting Riddic Linux Networking 1 10-17-2005 07:57 PM
Netcat problem - please help Piotrek Linux Networking 4 03-03-2004 06:37 PM
netcat problem Oliver Cole Linux Networking 2 09-15-2003 11:04 PM



1 2 3 4 5 6 7 8 9 10 11