Have you ever had the need to have a terminal server to access your serial devices? Maybe it's a Cisco switch, a Juniper router, maybe some HP equipment. If it is accessed through a serial connection, you can make your own Linux-based serial terminal server, without having to purchase OpenGear or Perle, or building a Cisco terminal access server from an old 2500 octal cable. All you need is a Linux system, and some serial ports.
Now-a-days, 9-pin serial ports are hard to come by, even on today's desktop systems. Even if you are lucky to find an older system, chances are, you'll have at most, 2 ports. Here is where USB-to-Serial converters come into play. Buy some, and plug them in. Linux will recognize them, and create the serial devices for them. Don't have enough USB ports? Buy a 10-port USB hub! :)
- TRENDnet TU-S9 USB-to-Serial adapter - Ebay - $9.00 new
- CentOS 5.8 desktop system
Step 1: Install SER2NET in CentOS/RHEL. This is a proxy service that allows your network telnet sessions to be redirected to locally attached serial devices
- Install Extra Packages for Enterprise Linux (EPEL)
- For CentOS/RHEL 5.x
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
- For CentOS/RHEL 6.x
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
- For CentOS/RHEL 5.x
- Install ser2net
yum install ser2net
Step 2: Identify your serial adapters in CentOS
This seems to be a bit of a frustration to some users. Finding *which* USB port goes to which device. There are a couple of ways to do this, but the easiest is to plug in one-at-a-time and identify what the Operating System identified it to be. As you plug in your usb device, within a second or two, you can run the following command:
dmesg | grep tty
This will pull up all the messages associated with the serial ports. The last line would be the one you just added:
[root@sys1 ~]# dmesg | grep tty serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A 00:07: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A usb 4-1: pl2303 converter now attached to ttyUSB0 usb 4-2: pl2303 converter now attached to ttyUSB1 usb 3-1: pl2303 converter now attached to ttyUSB2 usb 2-2: pl2303 converter now attached to ttyUSB3 usb 3-2: pl2303 converter now attached to ttyUSB4
In this case, the last device I added was attached to "ttyUSB4", which would make the virtual device /dev/ttyUSB4 used in the configuration steps below.
Step 3: Configure ser2net
The configuration files are located in /etc/ser2net.conf. Here is a snippet of my configuration:
NOTE: The "##" lines define comments, and are not needed
## This defines a banner called "cisco-sw1". Places some line breaks, tells me a message, and the device I'm connected to
BANNER:cisco-sw1:\r\n\r\n\r\nYou are connected to C-SW1 on device \d \r\n\r\n
BANNER:cisco-sw2:\r\n\r\n\r\nYou are connected to C-SW2 on device \d \r\n\r\n
BANNER:cisco-sw3:\r\n\r\n\r\nYou are connected to C-SW3 on device \d \r\n\r\n
BANNER:juni-sw1:\r\n\r\n\r\nYou are connected to J-SW1 on device \d \r\n\r\n## This creates a telnet port 4001, with no timeout, to go to /dev/ttyS0 with a speed of 9600 baud and use the banner named "cisco-sw1"
The BANNER is optional, but it tells me what I've connected to, once I establish my telnet session. Be sure to restart ser2net service after changing your configuration file! "
service ser2net restart"
So, now, I just: "telnet <ip of your server> 4001" to gain access to the console port of that switch/router. See below for tweaks.
So, you want to use this in your production environment? Using Telnet may not be the best way, unencrypted passwords/text and all. Just use SSH into your system, and telnet to the local host port:
telnet localhost 4001
Don't want to remember all those ports? Write up a quick alias:
alias SW1="telnet localhost 4001" alias SW2="telnet localhost 4002"
If you don't remember what you called an alias, because you are a slacker and haven't console'd in awhile, just use the "alias" command by itself, and it will list all the entries for you.
Juniper 2200EX-C Fanless switch December 9, 2013
Using OpenGear Console server with SSH December 8, 2013
Custom Functions for HP IMC June 18, 2013
Servers aren't for big business anymore June 13, 2013
Juniper Gear - Got some work to do June 9, 2013
UCCX Scripting - Iterating Different Recordings June 7, 2013
Static Mapping of Serial Devices in Linux June 6, 2013
Add a drive to an existing Linux LVM June 6, 2013
Accessing Cisco ASA using SSH January 17, 2013
Accessing Cisco ASA using SSH 27975 Views
The ASA version of PIX 'alias' command 19100 Views
HP Gen8 Proliant Servers 17849 Views
How I use Juniper 4200 for Servers 16804 Views
Is Cisco Losing in Switching/Routing? 16077 Views
Juniper's QFabric Innovations 15483 Views
UCCX Scripting - Iterating Different Recordings 15372 Views
Installing HP iMC with remote SQL Server 14266 Views
Static Mapping of Serial Devices in Linux 11609 Views