Sunday, August 21, 2016

The Raspberry PI Terminal Server

When I bought my Raspberry Pi a year ago I had no idea the little computer that could would literally become a hobby platform as well as my go to workhorse. Because of its size, I have a raspberry pi that is a terminal and browser interface to my ASUS router. Now when the ol' homestead network expansion required a Cisco 2960 front end switch, it was time to expand the horizons of the pi.

After a quick search on google, I found the software of choice for this operation is ser2net (see Raspberry PI as Cisco Console). It's a good article on setting up the pi as a terminal server. I am going to give the quick low down of how I installed the ser2net software and how I brought up my switch using the pi as a terminal server. You will need a USB to 9-pin serial cable to connect to the blue 9-pin serial cable that comes with all Cisco networking hardware. I had one of these cables laying around from my days as an employee with Cisco (days of long gone that is...). The picture below shows my simple network setup.


Step 1. Install the software.

Login to your raspberry pi and open a terminal window. Install the ser2net software package.

 sudo apt-get install ser2net  

When the install is completed you will need configure the banner and the usb0 port command. I copied and pasted the details from Raspberry PI as a Cisco Console. But slightly tweaked the banner for my network use.

 sudo vi /etc/ser2net.conf  

Insert the configuration for your banner header and your usb0 port information.

 # BANNER:banner:\r\nser2net port \p device \d [\s] (Debian GNU/Linux)\r\n\r\n  
 BANNER:banner:Skynet Terminal Server TCP port p device d rn  
 2000:telnet:600:/dev/ttyS0:9600 8DATABITS NONE 1STOPBIT banner  
 2001:telnet:600:/dev/ttyS1:9600 8DATABITS NONE 1STOPBIT banner  
 3000:telnet:600:/dev/ttyS0:19200 8DATABITS NONE 1STOPBIT banner  
 3001:telnet:600:/dev/ttyS1:19200 8DATABITS NONE 1STOPBIT banner  
 4001:telnet:0:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT banner  

That's it for the configuration. Pretty painless, huh?

Step 2. Fire in the Hole!

Open a new terminal on your raspberry pi and execute the ser2net software package.

 ser2net -n  

Open a new terminal window and open a telnet session using the port number to the Cisco device. For laughs I logged in from my mac to see if everything was in place for the terminal server.
From a terminal window on my Mac I executed a connection request.

 telnet 10.0.0.22 4001  

The log in results to the switch looked like this.

 Last login: Sun Aug 21 15:36:40 on ttys001  
 TheM5:~ daystrum$ telnet 10.0.0.22 4001  
 Trying 192.168.1.201...  
 Connected to raspberrypi.  
 Escape character is '^]'.  
 Skynet Terminal Server TCP port p device d rn  
 Would you like to terminate autoinstall? [yes]: no  
      --- System Configuration Dialog ---  
 Would you like to enter the initial configuration dialog? [yes/no]: no  
 Would you like to terminate autoinstall? [yes]:   
 Switch>  
 00:35:02: %LINK-5-CHANGED: Interface Vlan1, changed state to administratively down  
 Switch>  
 Switch>en  
 Switch#  

That's all there is to it. Down the road I would love to start writing a Python library similar to what we had with TCL and csccon back in the golden era days of Cisco. Again, days of long ago...
 
The Raspberry Pi is an amazing little device. I know this was a brief interruption in discussing a 6502 MPU emulator. But like I said, the Raspberry Pi is an incredible little workhorse. And this is the Raspberry Pi Workbench blog, whatever is on the workbench that is of interest I put on the blog. Hope this helps others out there trying to setup a terminal server for their home, corporate, educational, or certification network.   Until next time....