mikepell
Posts: 1
Joined: Tue Jul 23, 2013 11:25 pm

Serial Console Server

Wed Jul 24, 2013 12:00 am

I have seen numerous recipes for turning a pi into a serial server using a single USB-serial adapter. For my server room, I wanted multiple serial ports to connect to all of my switches, firewalls, etc. I could easily utilize at least 8 serial ports. 8-port serial console servers run round $500+US.

I figured I would build one with a raspberry pi for much less (and have a lot more fun). My total cost was about $225US.

Parts:
-1 pi (case, power supply, sd card) - $70
-1 small powered USB hub -$14
-1 Startech ICUSB2328 8-port usb to serial (it has a jack for optional power supply, but my usb hub supplies enough power) - $137

Software:
-raspbian
-screen
-putty for access from Windows machines

I thought the setup would be rather trivial until I discovered the device nodes did not match up with the physical ports on the ICUSB2328. After a couple of reboots, I realized it was worse than that, the device node to physical port mappings were pretty random on each boot.

udev to the rescue! Thanks to this blog entry http://hintshop.ludvig.co.nz/show/persi ... l-devices/, I was able to ensure that I had device nodes consistently mapped to the physical ports. By reviewing lsusb and /var/log/messages, I created the corresponding udev rules to use each port's serial number to map to a symlinked device node, serial[0-7] with the following /etc/udev/rules.d/99-usb-serial.rules:

Code: Select all

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AH018GUC", SYMLINK+="serial0"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AH018GUB", SYMLINK+="serial1"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AH018GU9", SYMLINK+="serial2"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AH018GU6", SYMLINK+="serial3"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AH018GU7", SYMLINK+="serial4"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AH018GU8", SYMLINK+="serial5"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AH018GUD", SYMLINK+="serial6"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AH018GUA", SYMLINK+="serial7"
You will have to collect the port-specific serial numbers specified with ATTRS{serial}== from /var/log/messages.

The pi's ethernet is connected to a separate management network and is accessible via ssh. I also decided to create a user and set the login shell to ~/menu, for a very rudimentary menu. Just in case I leave a session timeout, I added the option to reconnect to an existing screen session:

Code: Select all

#!/bin/bash
# menu

while [ answer != "0" ]
do
clear
echo -e "\r\n\r\n"
echo -e "To exit from any terminal, press <CTL>-a + k\r\n\r\n"
echo "Select device to which to connect"
echo -e "\n"
echo "   1)       firewall1"
echo "   2)       firewall2"
echo "   3)       switch1"
echo "   4)       switch2"
echo "   5)       switch3"
echo "   6)       pdu1"
echo -e "\n"
echo "   99      exit"
echo "   00      shell"
echo "    0      reconnect to timed out session"
echo -e "\n"
read -p " ?" answer
        case $answer in
                99) exit ;;
                 0)
                        screen -x ;;
                 1)
                        screen /dev/serial0 ;;
                 2)
                        screen /dev/serial1 ;;
                 3)
                        screen /dev/serial2 ;;
                 4)
                        screen /dev/serial3 ;;
                 5)
                        screen /dev/serial4 ;;
                 6)
                        screen /dev/serial5 ;;
                00)     clear && bash ;;
                 *) screen -x ;;
        esac
#        echo "press RETURN for menu"
#        echo -e "\n"
#       read key
done
exit 0
I'm sure there are plenty of other ways to do this, and look forward to hearing others' successes and improvements.

JungleBoogie
Posts: 35
Joined: Thu Sep 06, 2012 12:06 am
Location: Simi Valley, California
Contact: Website Yahoo Messenger AOL

Re: Serial Console Server

Sun Jul 28, 2013 4:11 am

I don't have that many switches but the pi is connected to a router via usb to serial connection and then serial to console access. I'll be looking for a USB male to USB female with multiple connections so I can connect to the switch and just ssh into the pi. I've created an alias so I don't have to type out the full minicom path.
Happy Hacking!

bnorling
Posts: 1
Joined: Mon Oct 21, 2013 2:21 am

Re: Serial Console Server

Mon Oct 21, 2013 2:26 am

I have a similar situation, however I don't need to access any one device at the same time. Therefore, I want to use the serial port available through the GPIO header and come up with an external switching mechanism. I'm thinking opto-isolators or something. Has anyone thought about doing this?

vspence
Posts: 5
Joined: Mon Apr 08, 2013 12:05 am

Re: Serial Console Server

Sun Jan 05, 2014 7:15 am

While a very neat project, on ebay various access servers can be bought for ~100 bucks. I'm referring to the DigiCM32 and Cisco 2509. The 2511 is more expensive, but is still at the price that was for all the equipment for the pi.

gdt
Posts: 85
Joined: Thu Jul 19, 2012 10:19 am

Re: Serial Console Server

Wed Jan 08, 2014 10:53 pm

I'm not sure I'd be buying a Cisco 2511 in this day and age. If the hardware doesn't support the IOS version then you're in trouble as larger flash memory requires a new ROM. There isn't any software with a modern SSH server.

A nice thing about using a RPi is that you can bring some heavier processing to the task. For example you can log all traffic when the port has no user, thus catching crash dumps. Have a look at conserver to see a nice application.

yaconsult
Posts: 33
Joined: Fri Mar 23, 2012 2:29 pm

Re: Serial Console Server

Fri Feb 21, 2014 8:04 am

Nice job on the project!

I am planning to do something similar but also add a relay board to allow power cycling the equipment connected to the console server. There are some cheap boards full of relays available like this one: http://www.amazon.com/SunFounder-Channe ... 00DR9SE4A/

Most of my systems are running fedora and have encrypted filesytems by default. So remote booting of these systems requires selecting the desired operating system at the grub prompt and then entering the encrypted filesystem password. All but the /boot partition are encrypted by default.

Return to “Networking and servers”