Next Previous Contents

55. Serial Linux Consoles and Reverse TELNET

One great thing about good rackmount PCs is their ability to be completely controlled via serial port and NOT require a VGA output and keyboard control. This is all done via the machine's BIOS and it just works. Unfortunately, if you're like me, you don't have a machine that supports this in the BIOS. Don't fret!

Linux also has the ability to display and manipulate the full LILO boot section process, show the full kernel bootup sequence, and ultimately allow for system login via any serial port. In addition to this, you can take any serial port and make it available as a Reverse TELNET port. Reverse TELNET is the same thing as console ports on terminal server such as a Cisco 2511, etc. You just telnet to a specific TCP port or a specific IP address on the Linux machine and you are then directly communicating to that other host via a serial port through TELNET. Very simple and a LOT cheaper than real terminal servers.

55.1 Lilo and Daemon Boot Logs via a Serial Port

Enabling LILO and boot logs via a local serial port is pretty simple. Modern Linux distributions should have this automcatically enabled but just in-case, follow these kernel compile-time options. After you have enabled these options, follow the instruction in Section 14: Kernel Compiling section.

The following example is for a Linux 2.2.x based kernel:


Character Devices 

    --> Standard/generic (dumb) serial support
    ----> Support for console on serial port

Optionally, if you are trying to use a Multi-port serial card like a Cyclades unit, simply enable it under a the same kernel configuration section:


Character Devices 

    --> Non-standard serial port support 

If you are trying to setup a Reverse TELNET server, you'll need one of these higher density serial cards if you want to control more than one or two serial devices. I'm using a Cyclades card without any major issues.

Anyway... once you configured/compiled/booted your new kernel (if required), you then need to edit the lilo.conf file.

NOTE: This config assumes the use of COM1 running at 9600Kbps, No partiy, 8 bit / 1 start bit / 1 stop bit. Other serial ports like Cyclades ttyC* are legal as well as other serial speeds and settings.

/etc/lilo.conf


#This puts LILO over the serial port - this is an interactive prompt if desired
serial=0,9600n8


#The following sends the kernel boot messages to --BOTH-- the serial port
#  and the console CRT screen.  The system daemon bringup logging is 
#  --ONLY-- sent to the console CRT screen.
#
# I recommend this setting
#
append="console=ttyS0,9600 console=tty0"


#Like above, the kernel messages go to the console CRT and serial port.  But 
#  now, the system daemons bringup logs now --ONLY-- display to the serial 
#  port.
#
#   -- If you are aware how to send the system daemon bringup logs to both 
#      the CRT and serial port, please email me.
#
# Disabled by default.
#
#append="console=tty0 console=ttyS0,9600"

That's it. Just re-run "lilo" as root and make sure LILO run cleanly.

Ok, one more step. You need to enable the "login" daemon on this serial port. To do this, edit the /etc/inittab file and find the lines that look like:


1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2 
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6 

At the end of this text section, add the line:


7:2345:respawn:/sbin/mingetty ttyS0

Please note the unique number "7" at the beginning and the updated TTY port "ttyS0". Save that file and restart the "init" process by running the command telinit q.

That's it! Just to make sure things are running correctly, run a serial COMM program on another machine that will be communicating over the serial connection. Make sure the port, speed, etc. is all correct and just hit the ENTER key a few times? Hopefully you will see a login prompt from the Linux host.

As a final test of everything, reboot the Linux machine and watch the LILO, possible kernel logs, and login prompt show up at 9600 baud.

As like all TrinityOS sections, I don't go very deep into troubleshooting things. If you need more detailed help, please see Section 5 - Serial Consoles and Reverse TELNET for additional help URLs. If you are still stuck, feel free to send me an email.

55.2 Reverse TELNET terminal services

Terminal servers are great for controlling remote network devices, etc. All you do is TELNET to some IP address or some specific TCP port on a particular IP address and you are then transparently communicating to a different device via it's console (serial) port. Unfortunately, terminal servers like Cisco 2500s, Livingston Portmasters, Cyclades, etc. are expensive. Fortunately with the use of a multi-port serial card from vendord like Cyclades, Digi, etc., you can turn a Linux server into a Reverse TELNET device very cheaply:

For this documentation, it assumes the following (PLEASE READ):

Currently, the knowns issues with this method are:

Ok, getting down to it. Make sure that the serial card is installed and working in desired the Linux machine (not currently covered in TrinityOS). I recommend to use a COMM program like Linux's "minicom" to verify that the card and serial cabling is working correctly FIRST.

For example, the Cyclades Cyclom-Y 8-port serial card uses ports /dev/ttyC0-7. To test, load up Minicom, change it to use the proper serial port ("Control-A", "o" - for Options, "Serial Port Setup", and change the port, speed, etc.). Once changed, save your settings as "dfl" (default), exit out of Minicom, and reload it. Hit enter a few times to make sure you get a login prompt.

So, first thing to do is register these new TCP ports. Please note that I've used ports TCP ports 300 through 307. These are legal available ports accordind to the IANA but you can use anything you'd like. Just make sure something else isn't using your proposed ports first (run "netstat -an" to check).

/etc/services


# Local services
console0        300/tcp       # Reverse TELNET console service - TrinityOS
console1        301/tcp
console2        302/tcp
console3        303/tcp
console4        304/tcp
console5        305/tcp
console6        306/tcp
console7        307/tcp

Next, we will use XINETD to start and re-start the individual ports when under use. If you would like to see INETD examples, let me know via email.

NOTE: You will need to re-create each individual files /etc/xinetd.d/console0 through console7 from this one example. Please also be sure to change the "console0" and "ttyC0" text to reflect the proper XINET service and serial port.

/etc/xinetd.d/console0


# default: off
# description: The reverse telnet console server serves console sessions via
#              telnet sessions; it uses unencrypted communications and is NOT
#              authenticated.
service console0
{
         flags           = REUSE
         socket_type     = stream
         wait            = no
         user            = root
         server          = /usr/bin/cu 
         server_args     = -E+ -l /dev/ttyC0 -s 9600
         disable         = no
}

Ok, once you created all 8 files (in this example for a Cyclades 8-port card), restart XINET by running:


/etc/rc.d/init.d/xinetd restart

So, that should be it. From the server, try it out:

To disconnect, just use TELNET's <Control-]> escape sequence, then type in "close" and that's it!


Next Previous Contents