(E-Mail Removed) wrote in message news:<vbyOa.492$(E-Mail Removed)>...
> |> |I'm trying to redirect udp:514 (syslog) via tcp 19999 on a remote
> |> |host, to tcp 19999 via udp:514 on a local syslog server.
> |>
> |> I don't see how this would work right off. Does netcat can do the
> |> conversion from UDP to TCP, as well as preserve information about packet
> |> boundaries for the reverse conversion?
> |
> |Yes it does...
> |http://www.atstake.com/research/tool...ork_utilities/
> |
> |"Netcat has been dubbed the network swiss army knife. It is a simple
> |Unix utility which reads and writes data across network connections,
> |using TCP or UDP protocol. It is designed to be a reliable "back-end"
>
> Yeah sure it can handle each protocol separately, I see nothing in there
> that suggests it will translate UDP to TCP and the reverse.
>
> Syslog messages are one per UDP message. Unless message boundaries are
> noted and preserved in the translation, the logger will not be able to
> find the beginning of messages in the stream.
Well according to this message on Security focus this contradicts what
you say... Netcat (or cryptcat) will redirect, or more correctly,
tunnel, udp through tcp...
http://www.securityfocus.com/infocus/1613
"One way to facilitate instant access to logs is tunneling. Some say
this is inelegant but it works. Using Netcat one can tunnel UDP over
Secure Shell by redirecting the syslog traffic to TCP tunnel,
protected by Secure Shell. The directions can be found at
http://www.patoche.org/LTT/security/00000118.html Make absolutely sure
that the syslog is not receiving messages from other hosts, or message
looping will occur.
In fact, by replacing Netcat with Cryptcat, one can eliminate SSH from
the equation. In this case the setup is as follows:
On log-generating host:
1. edit /etc/syslog.conf to have:
*.* @localhost
2. run command:
# nc -l -u -p 514 | cryptcat 10.2.1.1 9999
On log collecting host:
1. run syslog with remote reception (-r) flag (for Linux)
2. run command:
# cryptcat -l -p 9999 | nc -u localhost 514"
*******
and from
http://www.patoche.org/LTT/security/00000118.html
"Netcat will happily pipe UDP into a TCP stream. On the client
machine,
you would want to do something like:
nc -l -u -p syslog | nc localhost 9999
(as root, to bind to the syslog port)
On your syslog server end, you'd do something like:
nc -l -p 9999 | nc localhost -u syslog
Setup your ssh tunnel from port 9999 on the client machine to
port 9999 on the syslog server machine.
Setup syslogd on the client to log the messages to localhost. Also,
make sure that the client syslogd is set up to not receive messages
from the network.
You'll want to filter on the TCP listening port on the server to
prevent
people from DoS'ing you with spurious messages."
*******************
and perhaps this from the netcat readme will help...
"UDP connections are opened instead of TCP when -u is specified.
These aren't
really "connections" per se since UDP is a connectionless protocol,
although
netcat does internally use the "connected UDP socket" mechanism that
most
kernels support. Although netcat claims that an outgoing UDP
connection is
"open" immediately, no data is sent until something is read from
standard
input. Only thereafter is it possible to determine whether there
really is a
UDP server on the other end, and often you just can't tell. Most UDP
protocols
use timeouts and retries to do their thing and in many cases won't
bother
answering at all, so you should specify a timeout and hope for the
best. You
will get more out of UDP connections if standard input is fed from a
source
of data that looks like various kinds of server requests."
**********************************
**********************************
But we digress.... The real question is why netcat is not 'grabbing
the udp[514]' port on the server sending syslog messages to the remote
loggin server.
Could it be this? - again from the netcat readme?
"Netcat can bind to any local port, subject to privilege restrictions
and ports
that are already in use. It is also possible to use a specific local
network
source address if it is that of a network interface on your machine.
[Note:
this does not work correctly on all platforms.] Use "-p portarg" to
grab a
specific local port, and "-s ip-addr" or "-s name" to have that be
your source
IP address. This is often referred to as "anchoring the socket".
Root users
can grab any unused source port including the "reserved" ones less
than 1024.
Absence of -p will bind to whatever unused port the system gives you,
just like
any other normal client connection, unless you use -r [see below]."
However, I have tried to 1) stop syslog server, 2) start nc
redirection [udp[514] -> tcp [19999]], 3) restart syslog server but
the traffic still travels over udp[514].
So, debates over whether nc works or not (and as it has been for 7
years I doubt it would not be doing this...) aside, and in fact I
could (and will experiment with) udp[19999] through nc instead.
Can anyone helps me or are there any netcat experts out there?
Kind regards
James