Port Redirector

© Anton Voronin (, 2000-2001.

The package consists of two programs - PortRedorector and PortTest.

PortRedirector is a daemon that runs telnet to the remote port of the terminal server and redirects its input and output to a virtual terminal device (/dev/pty*). The corresponding slave device (dev/tty*) then can be used by an application that expects a local async terminal port.

Although this approach doesn't let to pass line signals (CD, DCR, etc) or manipulate them via ioctl calls, most application don't need it. For example, I successfully use this tool to monitor UPS units (connected to AUX ports of Cisco routers) with the nut software on a Unix server.

Whenever telnet subprocess terminates on any reason, it is restarted as soon as any data received from the terminal device.

Upon receiving SIGTERM PortRedirector terminates telnet subprocess and terminates itself.

If you prefer to restrict access to your terminal server's port, PortRedirector can enter username and password when establishing connection with it. Username, password and the prompt strings to wait for before sending them are specified in the configuration file (by default, /usr/local/etc/PortRedirector.conf). Be sure to keep this file secured (unreadable for regular users).

The process id for each daemon is stored by default in /var/run/PortRedirector-devname, where devname is the terminal device file it uses. The location can be changed in the configuration file.


PortRedirector [-f configfile] device host [port]
where configfile is an alternative configuration file; device is a master device (/dev/pty*) corresponding to the terminal device you will then specify to a client application (/dev/tty*); host is a hostname or ip address of the access server; port is a tcp port that the access server maps to its physical port you need to access to. If port is not specified, PortRedirector connects to standard telnet tcp port 21 (useful for test purposes).

After the thing is run you can test the connection using cu program or PortTest script. For example (assuming you have specified device /dev/ptyq0 to PortRedirector):

cu -l /dev/ttyq0
PortTest /dev/ttyq0

Download v1.1