SBC Serial Port Device Console Server

Introduction

Have you ever had to drag your laptop with a serial port and cable into an extremely loud, freezing cold (or boiling hot), data center to program a new network device such as a router or firewall? In the time it takes to find the right drivers and COM port for the USB Serial Port adaptor you can make a small network based serial port console server for around $100. This allows you to do the same work on up to 4 devices from anywhere with a network connection.

Don’t be like this guy when you could be working remote over a vpn!

cloud-dedicated-tools.jpg

This blog post shows how to use a Raspberry Pi 3 single board computer (SBC) as a network based serial port console server.  Connect the Raspberry Pi to an Ethernet or wireless network then use SSH or telnet to open a terminal window. Since the SBC runs a real 64 bit Linux operating system normal applications such as IPERF3, NMAP, and SCREEN work just fine.

Total project cost depends on what parts you already have and what you need to purchase. It takes around 2 hours to download the latest operating system image and copy it to the flash chip during which time you can build the kit and get everything ready.

Alternatives

There are many popular Network Serial Port Console servers available on eBay and Amazon for hundreds of dollars.  They have limited feature sets with closed operating systems and cannot be upgraded or expanded.

Bill of Materials

Here is the list of parts (BOM) needed to complete the build out of the project.

NOTE: a reliable power supply and Micro SD Flash Memory Card are important to the stability of this solution. Skimping on these two items could cause unplanned trips to the data center for troubleshooting this solution which is supposed to save you time, not make things worse.

  1. Raspberry Pi 3 ~$40

    product_2704
    Case available from Adafruit
  2. Case for Raspberry Pi 3 ~ $10 (Optional but recommended)
  3. Micro SD Card – 8GB or larger ~$20 (get an enterprise grade “type 10” flash chip with fast read write speeds)
  4. Micro SD to SD Card adapter for your computer ~$10 (used to transfer the OS image)
  5. USB to Serial Port adapter(s) ~$15 (up to 4 can be used simultaneously if needed)
  6. USB Power supply (or PoE option below)
    1. MicroUSB to USB type A power cable ~$5 (same type use by most android phones)
    2. 5-10 Watt USB Power Supply Adapter ~$5 (2.5 Amps recommended for fully loaded setup) https://www.adafruit.com/products/1995 or…
  7. IEEE 802.3af Micro USB Active PoE Splitter Power Over Ethernet 48V to 5V 2.4A ~$10
  8. An “admin” computer to use for testing and setup – Mac, Windows, Linux
  9. For initial setup you would also need the following:
    1. HDMI cable
    2. HDMI capable display monitor 1080p
    3. USB Keyboard

Setup Process

Follow these steps to build the solution:

  1. Obtain all the needed components in one place to be assembled later.
  2. NOTE: this process works for many other SBC besides just raspberry pi – see some here: https://wiki.debian.org/RaspberryPi#Should_I_buy_a_Raspberry_Pi.3F
  3. For example: here is a Rock64 from Pine for USD$20 on Amazon that runs latest Debian with 4K HDMI support.
  4. Download the Operating System image to your admin computer.
    1. Open a web browser to: https://wiki.ubuntu.com/ARM/RaspberryPi and download the latest version. Be sure to check the SHA-256 checksum.
  5. Insert the MicroSD card into the admin computer.
  6. Checking microSD Card performance and check whether is counterfeit:
    – H2testw 1.4 – Gold Standard In Detecting USB Counterfeit Drives
    – F3 – an alternative to h2testw
    This will help determine if the Micro SD Card is worth using.
  7. Copy the OS image to the MicroSD card.
    1. The image file size is over 4.3GB so depending on the write speed of the MicroSD card this can take an hour or so.
    2. Open a terminal command line interface on the admin computer.
    3. Here are the steps for Mac OS:
      diskutil list
      diskutil unmountDisk /dev/disk4
      sudo dd bs=1m if=~/Downloads/ubuntu-16.04-preinstalled-server-armhf+raspi3.img of=/dev/disk4

      Press Ctrl-t to monitor copy progress.

    4. Instructions for other Operating Systems and images can be found here: https://www.raspberrypi.org/documentation/installation/installing-images/README.md
  8. While the copy process takes place complete the following…
  9. Remove the Raspberry Pi from the box and assemble with the case.
  10. Connect the Raspberry Pi unit to the following:
    1. Local Area Ethernet Network
    2. HDMI display
    3. USB keyboard
  11. Turn on the display.
  12. When the copy process on the Admin computer completes you can remove the MicroSD card from the adapter.
  13. Insert the MicroSD card into the Raspberry Pi 3.
  14. Use the Micro USB cable to connect the Raspberry Pi 3 device to the power adapter.
  15. The Raspberry Pi 3 will boot up. You should see the login prompt on the display.
  16. Login with user and pass ubuntu/ubuntu.
  17. Run ifconfig to see the local assigned IP address. This assumes there is a DHCP server on the LAN. You can also assign a static IP address if needed.
  18. You can also use arp from your admin computer to find the IP Address: https://www.raspberrypi.org/forums/viewtopic.php?t=74176
  19. Open a secure shell session from your admin PC to the IP Address.
  20. Update the Raspberry Pi and install the tools you need:
    sudo apt-get –y update
    sudo apt-get –y upgrade
    sudo apt-get –y install iperf3 nmap sendemail
  21. Note the Ethernet MAC address and make a label to identify the Raspberry Pi 3 when it’s being used in the field. You may want to note the default password and other contact info on the label as well.
  22. Optionally: Here’s a script that can email you the IP Address when the Raspberry Pi boots up. Edit /etc/rc.local and add a link to this file there.
    #/bin/sh
    now=$(date)
    IPADDRESS=$(/sbin/ifconfig eth0 | sed -n 's/.*inet addr:\([^ ]*\).*/\1/p')
    MACADDRESS=$(/sbin/ifconfig eth0 | sed -n 's/.*Link\([^ ]*\):*/\1/p')
    IPADDRESS="$IPADDRESS\n - $now \n -$MACADDRESS"
    echo "RaspberryPi3 IP address:\n - $IPADDRESS " | sendemail -o tls=yes username=iben.rodriguez@gmail.com password=qdfqraugzundgjzn -s smtp.gmail.com:587 -f iben.rodriguez@gmail.com -t raspberrypi3@ibenit.com -u "raspberrypi3 IP Address" -q

    Here is an example of what the email looks like:

        RaspberryPi3 IP address:
        - 192.168.123.456
        - Mon Nov  7 01:15:14 UTC 2016
        - encap:Ethernet  HWaddr b8:27:eb:12:34:56
  23. Once the setup steps are completed you can unplug everything and move the Raspberry Pi 3 device to its operational location in the field.

Operating Instructions

Once you have everything ready you can move the solution into place where the device with the serial port resides.  For example:  a data center with racks of network equipment that needs to have its initial networking configuration applied or changed.  The Raspberry Pi 3 has 4 USB ports that can each be used with a standard USB to RS-232 Serial Port adaptor.  With a USB hub you could connect even more serial port adapters if needed.

  1. Connect the serial ports to the serial port adaptors with the cables you’d normally use with your laptop.
  2. Connect the USB to RS-232 serial port adaptors to the Raspberry Pi 3.
  3. Make sure the Micro SD Card with the configured Operating System image is seated properly in the Raspberry Pi 3.
  4. Use the MicroSD USB cable to connect the Raspberry Pi 3 to the power supply adaptor.
  5. Based on the setup steps above you should know how to find the IP address using the MAC address and the DHCP server, ARP, or the email script.
  6. Using the IP address of the Raspberry Pi you can now establish an ssh secure shell session from your admin workstation.
    ssh ‪ubuntu@192.168.123.456
  7. Login with the user name and password established during the setup steps.
    ‪ubuntu@192.168.123.456's password: P@ss!23456789
  8. Find the device path to the USB Seral Port(s) with this command:
    ls -al /dev/ttyU*

    crw-rw---- 1 root dialout 188, 0 Nov  6 02:26 /dev/ttyUSB0

    With multiple USB to Serial adaptors you will see many tty entries. See this post for more details on this: http://raspberrypi.stackexchange.com/questions/12246/why-does-usb-port-enumeration-change

  9. Use the “screen” application to connect to the USB Serial Port
    screen /dev/ttyUSB0
  10. Press the enter key to wake up the console device and do your work.
  11. To quit the screen app, type CTRL-A, then \.
  12. You can also use the Raspberry Pi 3 as a remote linux administration workstation with commands such as iperf3 and nmap.

USB Device Power Usage

Run this command to see the maximum power utilization budget of the USB devices plugged into your Raspberry Pi 3.

ubuntu@ubuntu:~$ lsusb -v|egrep "^Bus|MaxPower"
Bus 001 Device 006: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
    MaxPower              100mA
Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
    MaxPower              100mA
Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
    MaxPower               44mA
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
    MaxPower                2mA

Obviously, the more USB devices you connect the more power you will need. Adjust the capacity of the USB power supply adapter accordingly.

Next Steps

On my wishlist of things to try next:

Raspberry Pi 3 Specifications

Raspberry Pi 3 Model B
Release date 29 February 2016
Introductory price US$35
Operating system Raspbian
Ubuntu MATE
Snappy Ubuntu Core
Windows 10 IoT Core[1]
RISC OS
Debian
Arch Linux ARM
System-on-chip used Broadcom BCM2837
CPU 1.2 GHz 64/32-bit quad-core ARM Cortex-A53
Memory GB LPDDR2 RAM at 900 MHz[2]
Storage MicroSDHC slot
Graphics Broadcom VideoCore IV at higher clock frequencies (300 MHz & 400 MHz) than previous that run at 250 MHz
Power 800 mA (4.0 W)
Website raspberrypi.org

Powershell script to create vsphere distributed virtual switch port groups

I used the following Powershell Powercli script to create a bunch of DVS Port Groups on a VSAN vSphere 6 cluster.  Using the command line speeds things up and eliminates minimizes the impact of human error – no more mouse clicking.
Based on the work from the following blog post – I adapted it for our environment:
Creating consistent Distributed Port Groups with PowerCLI  
I recently had to create a new vDS to replicate a standard vSwitch from another vCenter install. I wanted to create my vDS Distribute Port Groups (DPG) simply, but consistently. As I have a low number of DPGs to create, I could probably have done this manually, but scripting the creation ensures consistency. Plus, it’s a subset of PowerCLI that I wanted to familiarize myself with.
First, I created a vDS and a reference DPG through the vSphere Web Client. You can do this with PowerCLI, but you have to go down the rabbit hole of Views to touch some of the advanced settings, something that’s not well documented and would have been very time consuming for me to explore. I also didn’t mind creating the initial vDS and DPG as the visual view of the Web Client made it easy for me to verify the settings whereas a long string of PowerShell (PoSH) would have been a little more difficult to interpret.
 
 
————————-
Here is my script… it created 41 port groups with the name “VM Network 3500” and so on…
Iben Rodriguez – 2015
$vDS = “SNSJ-DSwitch”
$Reference_DPG = “DPortGroup”
$DPGs = @{
     “3500”  = “VM Network”;
     “3501”  = “VM Network”;
     “3502”  = “VM Network”;
     “3503”  = “VM Network”;
     “3504”  = “VM Network”;
     “3505”  = “VM Network”;
     “3506”  = “VM Network”;
     “3507”  = “VM Network”;
     “3508”  = “VM Network”;
     “3509”  = “VM Network”;
     “3510”  = “VM Network”;
     “3511”  = “VM Network”;
     “3512”  = “VM Network”;
     “3513”  = “VM Network”;
     “3514”  = “VM Network”;
     “3515”  = “VM Network”;
     “3516”  = “VM Network”;
     “3517”  = “VM Network”;
     “3518”  = “VM Network”;
     “3519”  = “VM Network”;
     “3520”  = “VM Network”;
     “3521”  = “VM Network”;
     “3522”  = “VM Network”;
     “3523”  = “VM Network”;
     “3524”  = “VM Network”;
     “3525”  = “VM Network”;
     “3526”  = “VM Network”;
     “3527”  = “VM Network”;
     “3528”  = “VM Network”;
     “3529”  = “VM Network”;
     “3530”  = “VM Network”;
     “3531”  = “VM Network”;
     “3532”  = “VM Network”;
     “3533”  = “VM Network”;
     “3534”  = “VM Network”;
     “3535”  = “VM Network”;
     “3536”  = “VM Network”;
     “3537”  = “VM Network”;
     “3538”  = “VM Network”;
     “3539”  = “VM Network”;
     “3540”  = “VM Network”;     
};
$DPGs.Keys | % {
     $VLAN = $_
     $DPG = $DPGs.Item($_) + ” ” + $VLAN
     New-VDPortgroup -VDSwitch $vDS -Name $DPG -ReferencePortgroup $Reference_DPG
     Set-VDPortgroup -VDPortgroup $DPG -VlanId $VLAN
}