How to use Raspberry Pi as a serial console server for network switches

From time to time in my daily job i need very fast console access remotely to some network switches. This is not easy all the time.
Digging around i found a solution using minicom as a linux application but when you would like to use all 4 USB ports and you need to connect to multiple switches, this is a challenge.

Then i found another application called ser2net but the problem was related to USB RS232 adaptors. If you change USB between them, USB1 could be next time USB4 and so on so i have to figure out how to fix USB ports to be related to a single one even if you change USB cables.

Every time when you connect something to USB0 to Raspberry PI to be mounted to the same port. I used Symlink and Vendor ID and Product ID.

My RS232 adaptor was from Aten, model UC232A.

1. Change RPi hostname
"raspi-config"
2. Update and upgrade RPi
"apt-get update"
"apt-get upgrade"
3. Install Ser2net
"apt-get install ser2net"
4. Edit Ser2net conf file to configure telnet port, add logs file and Banner details:
"nano /etc/ser2net.conf"
BANNER:banner:Raspberry-CONSOLE
 
TRACEFILE:tr1:/var/log/ser2net/tr-\p-\Y-\M-\D-\H:\i:\s.\U
TRACEFILE:tr2:/var/log/ser2net/tr-\p-\Y-\M-\D-\H:\i:\s.\U
TRACEFILE:tr3:/var/log/ser2net/tr-\p-\Y-\M-\D-\H:\i:\s.\U
TRACEFILE:tr4:/var/log/ser2net/tr-\p-\Y-\M-\D-\H:\i:\s.\U
4001:telnet:0:/dev/ttySLABport1:9600 8DATABITS NONE 1STOPBIT banner tr=tr1 timestamp
4002:telnet:0:/dev/ttySLABport2:9600 8DATABITS NONE 1STOPBIT banner tr=tr2 timestamp
4003:telnet:0:/dev/ttySLABport3:9600 8DATABITS NONE 1STOPBIT banner tr=tr3 timestamp
4004:telnet:0:/dev/ttySLABport4:9600 8DATABITS NONE 1STOPBIT banner tr=tr4 timestamp
5. Configure Symlink for USB to enable static USB ports.
"nano /etc/udev/rules.d/99-usb-serial.rules"

SUBSYSTEM=="tty", ATTRS{idVendor}=="0557", ATTRS{idProduct}=="2008", ATTRS{devpath}=="1.2", SYMLINK+="ttySLABport1"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0557", ATTRS{idProduct}=="2008", ATTRS{devpath}=="1.3", SYMLINK+="ttySLABport2"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0557", ATTRS{idProduct}=="2008", ATTRS{devpath}=="1.4", SYMLINK+="ttySLABport3"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0557", ATTRS{idProduct}=="2008", ATTRS{devpath}=="1.5", SYMLINK+="ttySLABport4"

After reboot, looking with ls -als /dev | grep ttyUSB you can see:
0 lrwxrwxrwx 1 root root 7 Apr 10 10:29 ttySLABport1 -> ttyUSB0
0 lrwxrwxrwx 1 root root 7 Apr 10 10:29 ttySLABport2 -> ttyUSB1
0 lrwxrwxrwx 1 root root 7 Apr 10 10:29 ttySLABport3 -> ttyUSB2
0 lrwxrwxrwx 1 root root 7 Apr 10 10:29 ttySLABport4 -> ttyUSB3

Now you can use telnet to ip of the Raspberry Pi and port 4001 to USB0, 4002 to USB1, etc…
Source.

Leave a reply:

Your email address will not be published.

Site Footer