Random Information ...others might find it interesting too.

Remote logging using tcpdump and netcat

Quite useful if you have a low-powered device such as an OpenWRT device or a device that's low on space and need to log.

On the server, a common misunderstanding is that you should use both -l and -p which is wrong.
nc -l 9999 > fullcap.pcap

Client, disables login on ports 22, 53, 80, 443 and 9999.
tcpdump -s 0 -U -n -w - -i eth0.2 port not 9999 and port not 53 and port not 80 and port not 443 and port not 22 | nc 9999

Remote serial port connection on FreeBSD

For debugging purposes I needed to provide serial access to a device attached to a remote machine without giving any other type of remote access. This doesn't sound too hard but surprisingly it's quite confusing and information is sparse. Making Google do it's magic I ended up with these three options:

  • ser2net
  • socat
  • remserial

ser2net: Follows the RFC 2217 standard which is good, unfortunately there doesn't seem to be many clients around. The only ones I could find that were free was Kermit (Open Source) and HW VSP by the HW-Group (Freeware).

socat: Seems to be awesome and very versatile if you know what you're doing, honestly the documentation put me off...

remserial: Emulates a serial port remotely, proprietary, very minimalistic (doesn't really output any errors) and doesn't run on Windows unfortunately.

As Windows wasn't a requirement in this case I ended up running remserial as it just worked and did what it was supposed to do without any additional applications.

On the server (-p port (TCP), -s speed raw, /dev/cuau0 being the serial device in my case):
remserial -d -p 32323 -s "115200 raw" /dev/cuau0 &

On the client (-r remoteipadress, -p port (TCP), -l redirected-serial-port):

kldload ptmx
remserial -d -r <ipaddress> -p 32323 -l /dev/remser1 /dev/ptmx &

All set, now you just need to connect as you usually do but using /dev/remser1 as the serial port instead.

Tested on FreeBSD 10.1