Running a serial console server over ESXi

Since I'm building a hybrid systems/networking lab, one of the key features I'll need is a serial console server to administer the lab switches. There are a few options here:

  • Find an old Cisco Router and some async octal cables (Rare, takes up rack space)
  • Purchase a serial console server like MRV, Perle, Internetwatchdogs, etc ($$$)
  • Build a RPi as the console server (current solution, consumes 1 outlet)
  • Build a VM, and connect the USB-to-Serial Adapter

The last one is interesting, here's why. I have an ansible server that I intend to use for most patching/administration tasks, and to trial out certain aspects of network automation, and ansible lists a very interesting feature, proxies:

https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html

I could plausibly list the ansible VM's loopback address as a proxy, allowing me to use it to automate early-stage network provisioning without network connectivity. I know it's a petty thing to want to automate, but that particular aspect of network devices provisioning is pretty tedious, you have to:

  1. Upgrade to your baselined code revision
  2. Configure basic networking
  3. Download baseline config, and then customize it
  4. Restart to new config

Step 1 is a pretty slow task, and I'd like to automate it - it'd be great to let ansible babysit switches while they provision instead of having to be right there building on it the entire time. These are pretty simple tasks for most route-switch platforms - typically only requiring a binary copy and a reboot or two.

Anyhow,  let's get down to configuring the basics. I'm performing this from the vCenter 6.7 GUI, so YMMV on user interfaces. All you have to do is plug in your USB-to-Serial adapter, and then add it to the VM as a "Host USB Device." I'd recommend FTDI-type adapters, they don't typically require any driver install to work on either ESXi or Linux.

USB Pass-Through

Now, let's see if they show up:

1ansible:~ # ls /dev/ttyU*  
2/dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2  /dev/ttyUSB3  

We're all set! I typically use screen as a direct console emulator, but they all more or less do the same thing. At this point we're really just trying to test the console ports to see if they work:

 1ansible:~ # screen /dev/ttyUSB0  
 2         --- System Configuration Dialog ---  
 3Would you like to enter the initial configuration dialog? [yes/no]:  
 4ansible:~ # screen /dev/ttyUSB1  
 5User Access Verification  
 6Username:  
 7ansible:~ # screen /dev/ttyUSB2  
 8Would you like to terminate autoinstall? [yes]: yes  
 9ansible:~ # screen /dev/ttyUSB3  
10Switch>  
11ansible:~ # killall screen  

Looks like we're fully functional on all serial ports - I have 3 unprovisioned WS-C3560-24-TS-E for future lab use. The last commmand was to ensure that the proxy software wouldn't have to compete with screen for ownership of a serial device.

We'll be installing ser2net next - it only supports telnet, but you can tunnel SSH in a prod environment. Honestly, if you want this in your work environment it'd be much better to use a dedicated console server - 48 ports will net you less than a Dell R430, and can connect to phone lines. They're worth it.

 1ansible:~ # zypper in ser2net  
 2Loading repository data... 
 3Reading installed packages... 
 4Resolving package dependencies... 
 5  
 6The following NEW package is going to be installed:  
 7  ser2net  
 8  
 91 new package to install. 
10Overall download size: 92.3 KiB. Already cached: 0 B. After the operation, additional 200.1 KiB will be used. 
11Continue? [y/n/...? shows all options] (y): y  
12Retrieving package ser2net-3.5-2.2.x86_64                                          (1/1),  92.3 KiB (200.1 KiB unpacked)  
13Retrieving: ser2net-3.5-2.2.x86_64.rpm ...........................................................................[done]  
14Checking for file conflicts: ----------------------------------------------------------------------------------------[done]  
15(1/1) Installing: ser2net-3.5-2.2.x86_64 ----------------------------------------------------------------------------[done]  

Then we create a config file:

 1#  ::::  
 210000:telnet:3600:/dev/ttyUSB0:9600  
 310001:telnet:3600:/dev/ttyUSB1:9600  
 410002:telnet:3600:/dev/ttyUSB2:9600  
 510003:telnet:3600:/dev/ttyUSB3:9600  
 6  
 7BANNER:banner:SERIAL EMULATED PORT \p\r\n  
 8BANNER:banner1:TCP port \p device \d\r\n  
 9BANNER:banner2:TCP port \p device \d\r\n  
10BANNER:banner3:TCP port \p device \d  serial parms \s\r\n  
11TRACEFILE:tw1:/tmp/tw-\p-\Y-\M-\D-\H:\i:\s.\U  
12TRACEFILE:tr1:/tmp/tr-\p-\Y-\M-\D-\H:\i:\s.\U  
13OPENSTR:open1:Open str\r\n  
14CLOSEON:closehtml:  
15# Default value settings. The given values are the defaults. For non  
16# boolean values the possible values are given above. 
17#  
18#** serial device and SOL **  
19# speed: standard speeds shown above  
20#DEFAULT:speed:9600  
21# databits: 5,6,7,8  
22#DEFAULT:nobreak:false  
23#** serial device only **  
24#DEFAULT:databits:8  
25# stopbits: 1,2  
26#DEFAULT:stopbits:1  
27# parity: none, even, odd  
28#DEFAULT:parity:none  
29#DEFAULT:xonxoff:false  
30#DEFAULT:local:false  
31#DEFAULT:hangup_when_done:false  
32#DEFAULT:kickolduser:false  

And we're set! Systemd will automatically start ser2net with the VM.