I have been working in Computer networking for more than 8 years now and the biggest fear I still harbor is losing access to a router by misconfiguration. During my first stint with Service Provider networks, losing access to a router or switch would mean running to the Data Centre and taking console to a router and revert the changes and this because we didn’t have console servers in our Data Centre. Our Data centre was just across the NOC so it would take less than a minute to reach the equipments. During my second stint, the Data centre was the largest in India and going to the Data Centre would take minimum of 15 minutes from the NOC. Although we had a management network connecting all networked equipments, this did not help when a router or switch was malfunctioning and the only option left was taking console. My third stint with Service Provider network had no option of running to the router as many of the PoPs were international. Few of the larger PoPs had Terminal Servers but not all had this. A question would run through anyones mind as to why someone would not provision a console server on a remote site? The primary reason is the cost. The second reason is that it does not make business sense to have a console server for a couple of routers.
Why Raspberry Pi?
Raspberry Pi is a small computer costing just $35 and yet fully functional. Kids from 8 till adults are making good use of it as it is very versatile. We are using a Raspberry Pi for the following reasons
- It is much cheaper as compared to a Cisco Terminal Server
- The connectivity options are much varied with Wired, Wireless, 3G, etc
- Expansion is easy as you can provision a USB Hub with higher number of ports
- Cisco Mini USB Consoles can be used
- The Raspberry Pi can be used for other services like MRTG, monitoring, etc
- Takes very less power and space
- Raspberry Pi Model B
- Powered USB Hub with as many ports as you want console cables
- USB Mini console
- USB to Serial Cable
- Cisco Console Cable
I am beginning with the assumption that your Raspberry Pi is already running Debian Wheezy. We will connect the USB Hub to the USB Port with the provided USB cable. We must use a powered USB Hub because the Pi is not able to drive the USB Hub and all the connected devices. If we do not use a powered hub, the devices keep on disconnecting. In this example, I am using 3 USB Mini Cable and 2 USB to Serial Cables connected with Cisco Console cable.
As soon as you connect the USB Hub and all the consoles, it should be detected and you can see it via the command lsusb.
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 008: ID 05a6:0009 Cisco Systems, Inc.
Bus 001 Device 009: ID 05a6:0009 Cisco Systems, Inc.
Bus 001 Device 010: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 05e3:0610 Genesys Logic, Inc. 4-port hub
Bus 001 Device 005: ID 05e3:0610 Genesys Logic, Inc. 4-port hub
Bus 001 Device 006: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 007: ID 05a6:0009 Cisco Systems, Inc.
Every Serial device detected will form a TTY port. You can see the Serial Port to TTY mapping by the command
dmesg |grep tty
[ 0.000000] console [tty1] enabled
[ 0.584224] dev:f1: ttyAMA0 at MMIO 0x20201000 (irq = 83) is a PL011 rev3
[ 0.908060] console [ttyAMA0] enabled
[ 6.283591] usb 1-1.2.2: pl2303 converter now attached to ttyUSB0
[ 6.449796] usb 1-184.108.40.206: pl2303 converter now attached to ttyUSB1
[ 7.232831] cdc_acm 1-1.2.3:1.0: ttyACM0: USB ACM device
[ 7.338627] cdc_acm 1-220.127.116.11:1.0: ttyACM1: USB ACM device
[ 7.405930] cdc_acm 1-18.104.22.168:1.0: ttyACM2: USB ACM device
It is best to keep the cables untouched after connecting it because we will be doing manual mapping of TCP port with TTY. If you remove the console and put it back, there is a very good possibility that the TTY will be different.
In order to connect to the routers via Terminal, we will require Kermit on the Pi. You can install Kermit with the following commands
sudo apt-get install ckermit
After installation of Kermit, you can connect to individual routers via the following command
kermit -l /dev/ttyUSB0 where ttyUSB0 is obtained from the output of the dmesg |grep tty command.
Enter “connect” and you will be prompted to enter “set carrier-watch off”. Enter “set carrier-watch off” and again enter “connect” and you will be taken to the router console. You can disconnect the router by the following key combinations ctrl / u
In order to redirect TCP connections to the serial, we will require Ser2net. You can install ser2net via the following commands
The version keeps on changing so you will have to go to sourceforge and check the latest version and change the name in the above command accordingly
Complete the installation with the following commands
tar xvfz ser2net-2.8.tar.gz
./configure && make && sudo make install
Go to the folder where you have installed the ser2net and edit ser2net.conf
sudo nano ser2net.conf
Add the following lines to the ser2net.conf file.
9001:telnet:0:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT banner1
9002:telnet:0:/dev/ttyUSB1:9600 8DATABITS NONE 1STOPBIT banner1
9003:telnet:0:/dev/ttyACM0:9600 8DATABITS NONE 1STOPBIT banner1
9004:telnet:0:/dev/ttyACM1:9600 8DATABITS NONE 1STOPBIT banner1
9005:telnet:0:/dev/ttyACM2:9600 8DATABITS NONE 1STOPBIT banner1
9006:telnet:0:/dev/ttyACM3:9600 8DATABITS NONE 1STOPBIT banner1
Keep a set of ports for the console connections. I have taken ports 9001 onwards.
Note that my port numbers and TTYs will be different from yours as it depends upon the console cables and types you have used and what your Pi has detected.
A very good feature with this setup is that you can log every command you enter to the console. After you have added the above lines, repeat the above lines as mentioned below
9001:telnet:0:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT banner1 tr=tr1 timestamp
9002:telnet:0:/dev/ttyUSB1:9600 8DATABITS NONE 1STOPBIT banner1 tr=tr1 timestamp
9003:telnet:0:/dev/ttyACM0:9600 8DATABITS NONE 1STOPBIT banner1 tr=tr1 timestamp
9004:telnet:0:/dev/ttyACM1:9600 8DATABITS NONE 1STOPBIT banner1 tr=tr1 timestamp
9005:telnet:0:/dev/ttyACM2:9600 8DATABITS NONE 1STOPBIT banner1 tr=tr1 timestamp
9006:telnet:0:/dev/ttyACM3:9600 8DATABITS NONE 1STOPBIT banner1 tr=tr1 timestamp
The logs will be saved at /var/log/
In order to run the setup, enter
/usr/local/sbin/ser2net -c /home/pi/ser2net-2.9.1/ser2net.conf -n
You can now take console to your router by telnetting at ip address of Pi at the specific port number
Example telnet 22.214.171.124 9001 where 126.96.36.199 is ip address of Pi and 9001 is the port of device connected to USB0
In order to make the setup persistent, you will have to edit rc.local file.
sudo nano /etc/rc.local
Enter /usr/local/sbin/ser2net -c /home/pi/ser2net-2.9.1/ser2net.conf -n at the end before exit 0
Again the folder naming might be different in your case depending on the version of ser2net
You can try consoling all the routers at the same time to check whether everything is working as expected.
I hope my post has been helpful in your life but the only guide which can help you in the hereafter is the Qur’an. You can download the English translation of the Qur’an here.