Port forwarding using netcat.


This example shows how to create a custom xinetd service, in this case to forward radmin (port 4899) to another server using netcat.

Create a file in /etc/sysconfig/xinetd.d/ (call it what you want – but for this example radmin would be a good choice)

Create a definition in your /etc/services file contains a mapping for the port you wish to forward, e.g.

radmin 4899/TCP # Remote admin

And then create the xinetd listener in /etc/xinetd.d/

service radmin
  flags = REUSE
  protocol = tcp
  socket_type = stream
  port = 4899
  wait = no
  user = nobody
  server = /usr/sbin/nc
  server_args = -w 10 4899
  disable = no

This will redirect any requests to the local machine on port 4899 to the remote server

A ‘poor mans’ proxy really!