Tag Archives: terminal

Why buy a terminal server when an old PC will do

My lab will require me to console into 4 switches. I don’t want to buy another router to be my terminal server, and I also don’t want to have to swap out console cables every 2 minutes.

Thankfully I don’t have to. Linux has a handy tool to turn a regular PC with a bunch of USB serial ports into a terminal server.

All you need is a bunch of USB ports (a USB hub will do), some rollover cables and a bunch of these which I found on ebay:
usb to serial Why buy a terminal server when an old PC will do

I bought 3 of the above, as the PC itself already has 1 serial port.

The app I’m going to use is called ser2net. Let’s install it

darreno@CCIE:~$ sudo apt-get install ser2net

Now let’s see if Ubuntu 10.10 has reconised my USB serial cables:

darreno@CCIE:~$ dmesg | grep tty
[    0.000000] console [tty0] enabled
[    0.932016] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    0.932314] 00:05: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    6.625434] usb 6-1: ch341-uart converter now attached to ttyUSB0
[    6.649441] usb 6-3: ch341-uart converter now attached to ttyUSB1
[    6.672443] usb 3-2: ch341-uart converter now attached to ttyUSB2

Looks good so far. ttyS0 is my physical serial port and the ttyUSBx ports are the 3 USB-Serial cables. I’ll now configure ser2net to map TCP ports to my onboard port and my 3 USB ports.

darreno@CCIE:~$ sudo vi /etc/ser2net.conf

At the bottom of that file you’ll see this:

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

Let’s change it to this:

2000:telnet:600:/dev/ttyS0:9600 8DATABITS NONE 1STOPBIT banner
2001:telnet:600:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT banner
2002:telnet:600:/dev/ttyUSB1:9600 8DATABITS NONE 1STOPBIT banner
2003:telnet:600:/dev/ttyUSB2:9600 8DATABITS NONE 1STOPBIT banner

save and quit, then restart ser2net:

darreno@CCIE:~$ sudo /etc/init.d/ser2net restart
 * Restarting Serial port to network proxy ser2net                                                          [ OK ]

Now to test!

My dynamips box has an IP of If I want to get to the physical serial port from my laptop, I only need to do this:

C:\Users\Darren>telnet 2000
ser2net port 2000 device /dev/ttyS0 [9600 N81] (Debian GNU/Linux)


What about a USB cable?

C:\Users\Darren>telnet 2003
ser2net port 2003 device /dev/ttyUSB2 [9600 N81] (Debian GNU/Linux)


I use a tabbed telnet/SSH app called ZOC. From there I can specify the telnet ports and which switch they map to. I can now console into all of them without the need of a terminal server. The actual USB-Serial cables only cost me £2 each, and you can have loads of them.

(2011/02/19) EDIT: Dariush below mentioned that you can get multiple serial adaptors through a single USB port. This is an example: http://www.amazon.co.uk/NEWLink-Serial-Quad-Cable-Adaptor/dp/B003DA5TG4

If you don’t want to go the USB hub root, this could certainly work. Serial cables aren’t exactly high bandwidth. I’ve even found an 8 port model here, but no price: http://www.delock.com/produkte/gruppen/USB+Adapter/Delock_Adapter_USB_8x_Serial_61519.html

Set up wireless in Linux via the command line

I recently bought an Acer Revo 3600 to replace my ageing PopcornHour A100. I’ve installed a minimal version of Ubuntu Linux on it as well as xbmc. As this is in my bedroom far away from my router, I only wanted to use the wireless chip.

As I have no gui, I have to manually set this up. If you do happen to be in some sort of gui and want to get out of it quickly, just press ctrl+alt+f1 or ctrl+alt+f2 and so on. This will just open up another terminal session for you.

You’ll need to know the name of your SSID as well as your password of course. In my case here I’m using WPA2. You’ll need to have wpasupplicant installed. If you have a wired connection it’ll be easy to install. If not you’ll need to get it elsewhere and copy it on your box. I am using Ubuntu, so the same method should work with Debian. Just use your distro’s packet manager to get it installed.

sudo apt-get install wpasupplicant

If not already root, you’ll now need to log in as root

sudo su -

Now you need to type wpa_passphrase ssid password > /etc/wpa_supplicant.conf. This is my example:

wpa_passphrase Cisco Thisisyourpassk\$y > /etc/wpa_supplicant.conf

As this is Linux, you need to remember to use break characters when using special characters. My ssid is named Cisco and my password is Thisisyourpassk$y. I’ve used the break character just before the $ sign. You will see if you have this correct by opening up the /etc/wpa_supplicant.conf file like so:

vi /etc/wpa_supplicant.conf

You should see that the break character worked as the psk over here shows the correct password in full.

Copy the psk value as you’ll need it in the next step.

Open your interface config file (in Ubuntu/Debian it’s over here):

vi /etc/network/interfaces

Add the following to this file:

#The wireless interface
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "Cisco"
wpa-ap-scan 1
wpa-key-mgmt WPA-PSK
wpa-psk "357b62bf79a0d096901fe32d3138b6d962b95675976f08d044d117970b04d0fa"

Save and exit. Now restart your network:

/etc/init.d/networking restart

You should now be connected, and can monitor it via ifconfig and iwconfig:

root@XBMCLive:~# iwconfig 

wlan0     IEEE 802.11bg  ESSID:"Cisco"
          Mode:Managed  Frequency:2.472 GHz  Access Point: 00:1D:A2:E7:56:30
          Bit Rate=54 Mb/s   Tx-Power=20 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:7B16-2A4A-9A61-158A-9537-84FE-3F90-E275 [3]
          Power Management:off
          Link Quality=36/70  Signal level=-74 dBm  Noise level=-94 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
root@XBMCLive:~# ifconfig
wlan0     Link encap:Ethernet  HWaddr 0c:60:76:68:60:25
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::e60:76ff:fe68:6025/64 Scope:Link
          RX packets:649 errors:0 dropped:0 overruns:0 frame:0
          TX packets:677 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:94586 (94.5 KB)  TX bytes:123349 (123.3 KB)

This only works if your kernel actually has the driver of course. If not, you may need to download the windows driver and use ndiswrapper. I’ve got an exmple of doing this in my post over here: http://mellowd.co.uk/ccie/?p=114

I would also suggest deleting your /etc/wpa_supplicant.conf file to prevent anyone in future getting your password.