«

»

Oct
20

Build and configure you own linux serial console server (reverse telnet)

One of the locations I look after has a stack of 16 Cisco switches that I manage remotely via the Internet. These switches often undergo some very complicated reconfigurations for certain customers of the site and from time to time I have found myself locked out via Telnet and have had to visit site with a serial console cable to put the configurations right.

To avoid any more of these unplanned site visits I decided to sort out a serial console server for this site. If your reading this you probably realize that a Serial Console server is basically a computer with a number of Serial Interfaces and an Ethernet port. You can connect to the console server and the out over one of its serial ports to control the attached devices.

I needed a device with 16 ports. Proper 16-port console servers like those produced by Avocent cost upwards of £1500, so I decided to build my own. I put together the cheapest barebones PC system i could find with a spare PCI-Express slot. Into this spare PCI-E Slot i Installed a Startech 16-port PCI-E Serial Card. (PEX16S952LP) shown below.

Startech PEX16S952LP

I then dug around the storerooms and found 16 standard blue Cisco Serial console cables and connected them from the 16-port breakout cable coming from the serial card and into each of the switches. I installed Ubuntu Server on the system. I could see 16 ttySx devices in /dev/ and i could use minicom to connect to the switch on the end of each /dev/ttySx port. The next stage, expose these serial ports via Reverse Telnet for easy remote management.

The ubuntu package ser2net package describes itself as:

 This daemon allows telnet and tcp sessions to be established with a
unit’s serial ports. Combined with a terminal emulation like xterm or
the Linux console, this can be a very simple means of communicating
with routers, other systems’ serial consoles and other equipment with
a serial port. This is remarkably similar to the reverse telnet
feature of some Cisco routers.

I installed the package with:

sudo apt-get install ser2net

The next step is to configure which TCP ports you want ser2net to listen on and which serial ports to map these to. This is done in /etc/ser2net.conf  my configuration file looks something like this:

BANNER:banner:\r\nser2net port \p device \d [\s] (Debian GNU/Linux)\r\n\r\n

2000:telnet:600:/dev/ttyS0:9600 8DATABITS NONE 1STOPBIT banner
2001:telnet:600:/dev/ttyS1:9600 8DATABITS NONE 1STOPBIT banner
2002:telnet:600:/dev/ttyS2:9600 8DATABITS NONE 1STOPBIT banner
2003:telnet:600:/dev/ttyS3:9600 8DATABITS NONE 1STOPBIT banner
2004:telnet:600:/dev/ttyS4:9600 8DATABITS NONE 1STOPBIT banner
2005:telnet:600:/dev/ttyS5:9600 8DATABITS NONE 1STOPBIT banner
2006:telnet:600:/dev/ttyS6:9600 8DATABITS NONE 1STOPBIT banner
2007:telnet:600:/dev/ttyS7:9600 8DATABITS NONE 1STOPBIT banner
2008:telnet:600:/dev/ttyS8:9600 8DATABITS NONE 1STOPBIT banner
2009:telnet:600:/dev/ttyS9:9600 8DATABITS NONE 1STOPBIT banner
2010:telnet:600:/dev/ttyS10:9600 8DATABITS NONE 1STOPBIT banner
2011:telnet:600:/dev/ttyS11:9600 8DATABITS NONE 1STOPBIT banner
2012:telnet:600:/dev/ttyS12:9600 8DATABITS NONE 1STOPBIT banner
2013:telnet:600:/dev/ttyS13:9600 8DATABITS NONE 1STOPBIT banner
2014:telnet:600:/dev/ttyS14:9600 8DATABITS NONE 1STOPBIT banner
2015:telnet:600:/dev/ttyS15:9600 8DATABITS NONE 1STOPBIT banner

Once ser2ner has been restarted with /etc/init.d/ser2net restart i was able to telnet into ports 2000 through to 2015 and gain direct access to the serial port connected to each switch.

You should really at this stage add some restrictive firewall rules to your serial console server, or onto whatever hardware firewll device you use. An article detailing how to easily and effectively manage an ipTables firewall will follow on this site in a couple of days time.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">