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 10.20.30.11. If I want to get to the physical serial port from my laptop, I only need to do this:

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

C3560#
C3560#

What about a USB cable?

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

C3550#
C3550#

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

flattr badge large Why buy a terminal server when an old PC will do
Tagged with:  

47 Responses to “Why buy a terminal server when an old PC will do”

  1. errtime says:

    This one is handy indeed. Nice find!

  2. Laurent says:

    Just curious:
    – any particular reason you don’t use a dedicated management VLAN to connect yourself to your switch ?
    – what connection model do you choose to connect your dynamips routers to your switches ? Quad-NICs or Q-in-Q ?

    Thanks !

  3. Darren says:

    Laurent
    - Yes. In labbing environments you always use the console. Mainly as every lab would require you to start from scratch. That means at the end of every lab you’re going to be doing a wr erase. This means every lab you’ll have to log back on via the console and have to redo your management vlan configuration again. With the console, you never have to worry about losing connection in the middle of your lab

    - I’m using Quad NIC’s. I don’t want to have to buy an extra switch just to do QinQ. The NIC’s are cheaper and they just look better

  4. funkychild says:

    Hi,
    There is something I don’t understand in the cabling.
    The USB-Serial cable is plugged into the serial port of the dynamips box.
    The roll over cable is plugged into a switch console port.
    What happens between this two ends ?

    Thanks.

  5. Darren says:

    Hi Funkychild.

    Slightly Incorrect.

    The rollover cable is plugged into my single serial port and into 1 switch console port.

    The 3 USB cables are plugged into USB ports. Each USB/Serial cable is then plugged into a rollover cable which goes to the other 3 switch console ports.

    So:
    PC–>Serial–>Switch
    PC–>USB–>Serial–>Switch
    PC–>USB–>Serial–>Switch
    PC–>USB–>Serial–>Switch

  6. funkychild says:

    My mistake.

    I thought rollover cable had one rj45 connector on each side.
    The famous blue console cable with a rj45 at one end and a serial at the other end is also called rollover cable. Am i right ?

    Now it all make sense.
    The USB-Serial cable is plugged into the USB port of the dynamips box. The serial connector is linked to serial connector of the rollover cable and finally the rj45 connector of rollover cable is plugged into the console port of the switch.

    Sorry for the misunderstanding.

  7. Darren says:

    You are correct. The rollover cable has an rj45 connector and a serial connector :)

    No problem about the misunderstanding. I hope the post helps people, as while terminal routers can be cheap, the NME cards needed for the console connections are damn expensive.

  8. Marco Rizzi says:

    Nice one Darren!
    installed in 1 min and it works like a charm.

    thanks!

    Marco

  9. Daniel says:

    Good post Darren. I’m putting together a terminalserver for my job and the HWIC-16A cards don’t come cheap :D

  10. Darren says:

    Hey Daniel.

    Indeed! The routers are cheap, it’s those damn cards that are so expensive. I’m just using my dynamips box itself as the terminal server. Nice and easy :)

  11. Matt says:

    Thanks, I was looking how to set this up with “cu”, but this is MUCH easier.
    You rock!!
    M

  12. Dariush says:

    I’d been puzzling over how to solve this one cheaply for a while (and kicking myself for selling that 2511RJ sometime back). I ended up buying a couple of USB to 4x Serial adapters. (eg http://www.amazon.co.uk/NEWLink-Serial-Quad-Cable-Adaptor/dp/B003DA5TG4) There are also USB to 8x Serial available.
    Whilst not the tidiest of solutions it’s better than a usb hub plus multiple single usb to serial adapters. Works a treat with cisco serial cables or a null modem cable (for those pesky olives ;-)
    Using /usr/bin/screen to drive the whole thing is also a big win over minicom or cu. Simply screen /dev/ttyUSBx and you’re there. (if you need a different data rate put it after the device eg screen /dev/ttyUSB3 115200
    HTH

  13. Darren says:

    Nice Dariush. I had no idea that you could get a single usb to multiple serial cable. If only I had known!

  14. [...] I have no terminal server, so I’ve just done this: Why buy a terminal server when an old PC will do [...]

  15. Vim says:

    Hi Darren,

    I’m trying to implement a rack rental facility for study purposes at my university. Your post really helps as I can avoid buying an access server. However, would you have any ideas as to how I could perhaps do what you have done and interface with a WAN environment. For instance, have several terminal sessions running, each connected to one device’s console – any idea how I could say provide users with my IP address and a port number so that when they telnet/ssh, they’re straight into the terminal?

    Many thanks. :)

  16. Darren says:

    Hi Vim.

    I don’t see why this couldn’t be extended to multiple racks. The big thing is you would need enough serial ports for all your devices. I would probably go for those 4 port serial to 1 port usb devices. Get a bunch of them in.

    Then let’s say you have Rack1 going to ports 2000-2010, Rack2 going to 2011-2020 and so on.

    People then just need to telnet to your public IP address and the port number and they’ll be right on the device :)

  17. Vim says:

    Thanks Darren,

    …and perhaps do port forwarding on my router yes?

    E.g. :2000 :2000 ?

    I know how to do static NAT on a cisco router, can you also do port forwarding?

    Thank you.

  18. Darren says:

    Hi Vim.

    No port forwarding should not be required, though it depends on how your set up is exactly.

    If you have your Internet —> router —> server – then yes your router would need to forward the required ports to the server.

    Also yes a Cisco router can do port forwarding. A quick google search will show a number of configuration that people have done.

  19. Vim says:

    Great stuff! Thanks Darren.

    Out of curiosity, as you’ve mentioned it, how would you accomplish the same without port forwarding?

    Thank you.

  20. Darren says:

    Without port forwarding your server would need to be directly connected to the internet, or your would need 1 to 1 natting set up if you had multiple public IPs

  21. Vim says:

    Gotcha!

    Thanks a bunch :)

  22. Tom says:

    Hello Darren,

    I have one question about ser2net. I have now installed it and configured, so when I tested it I received the following when I tried to connect:

    Trying CAT1 (10.10.10.1, 4051)… Open

    ser2net port 4051 device /dev/ttyUSB0 [9600 N81] (Debian GNU/Linux)

    ààààààààààààààààààààààààààààààààààààààààààààààààààààààààà

    as you can see all I receive is “àààààà” but not the console access as it should appear…

    Any idea why this happens ??
    and BTW: can i use USB HUB on my laptop on Ubuntu to connect the 5 switches ? with console ? as I have the USB HUB with 7 USB ports… is it possible ?

    Thank You

  23. Darren says:

    Tom, looks like your console speed settings on your switch doesn’t match. Have you changed it from the defaults?

  24. Tom says:

    Hi Darren, thank You for reply, no I have not changed it…
    do we need to to so ? if yes how ?

    Thank You

  25. Tom says:

    line con 0
    speed 9600

    I assume this will be correct ?

  26. Darren says:

    Looks correct yes

  27. Tom says:

    now I tried to set the 9600 on the switch and now I received only:

    Trying CAT1 (10.10.10.1, 4051)… Open
    ser2net port 4051 device /dev/ttyUSB0 [9600 N81] (Debian GNU/Linux)

    and nothing happens….

    but as far as I know the speed 9600 baud is the default speed on all cisco switches, correct me if I am wrong ?

  28. Darren says:

    Odd…

    Is it just a single switch having this problem?

  29. Tom says:

    no it`s the same for all of the 4 switches…. very wired it should work..

    can I connect all the switches to USB HUB should it work ? now I am changing the console cable each time while I am testing….

  30. Darren says:

    No that won’t work.

    If you console directly into the switch from your laptop, does it work?

  31. Tom says:

    yes than it works…

  32. Tom says:

    but why it will not work using USB HUB ? in this case how can I access 4 switches at the same time from the laptop ?? I am running virtual routers in GNS and 4 physical switches.. I am able to access all virtual routers via console from the telnet router and I will access all 4 physical switches from the same telnet router just typing the SW1 etc…

  33. Tom says:

    finally it`s fixed and it`s working fine…. just restarted the Ubuntu…

    and about the USB HUB, this is also tested I use the USB HUB with 7 USB ports and I connected 5 physical switches to the HUB and it works like a charm…
    Each time I connect the new USB I receive USB0, USB1, USB2 etc….

    I am using the USB-to-SERIAL converter model: ATEN (RS-232) ..

    and the config below is used in the “ser2net” which I have installed in Ubuntu:
    apt-get install ser2net

    4051:telnet:0:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT banner
    4052:telnet:0:/dev/ttyUSB1:9600 8DATABITS NONE 1STOPBIT banner
    4053:telnet:0:/dev/ttyUSB2:9600 8DATABITS NONE 1STOPBIT banner
    4054:telnet:0:/dev/ttyUSB3:9600 8DATABITS NONE 1STOPBIT banner
    4055:telnet:0:/dev/ttyUSB4:9600 8DATABITS NONE 1STOPBIT banner

    cheers

  34. Darren says:

    Glad it’s working :)

  35. AddyR says:

    I installed ser2net and edited the ports, but didn’t know how to save changes, and exited terminal by closing it. Sorry I’ve been searching around and I am lost! Now every time I try the command sudo vi /etc/ser2net.conf it gives me an error: “swap file etc/.ser2net/conf.swp already exists” and I don’t know how to delete that file either!!! I got about 5 swap files… any ideas?? sorry I am just trying new things and I am breaking others!!!! Any help really appreciated

  36. Darren says:

    Hi Addy. The swp file is there because you have closed your terminal session with the file still open. vi can be a little bit funny to use so I would reccomend using gedit if you’re using a gui. Open the file there and save. Then reload ser2net and it should work

  37. Brendan says:

    This works great with my switch lab! I had to remove the banner option, though. It was giving me connection refused.

  38. Javin says:

    Hey Darren,

    I was working on this exact same thing. I am glad you posted how you set yours up. I was curious if you had any issues with the Com ports remaping themselves (eg, after a reboot). Are you able to consistently reach the same adapter? I am just nervous that after mapping all of my devices I would have to figure out what one is what if I shut down my machine. I would appreciate your imput. Thanks.

    Javin

  39. Darren says:

    Hi Javin.

    I’ve had no problems with the serial ports remapping to different port numbers. Both the on-board and the usb ones. As long as you keep the usb serial plug in the same socket, it’ll survive a reboot

  40. Tim says:

    Darren,

    Good Afternoon!

    Thanks for the advice. Saved me money on a console server.
    I am running into a problem. Everytime I reboot my ubuntu box my usb adapters get new USBtty numbers. Is there anyway to statically assign a USBtty number to a usb to serial adapter?

    thanks

    Tim

  41. Vishal says:

    Hi Darren

    Any option to do this on window 7 ???
    I am not a fan of ubuntu.

  42. Darren says:

    Vishal. No.

    I would not use windows 7 for this anyway. Setting this up in linux takes a few minutes anyway

  43. [...] learn how to set up Ser2Net with Serial-USB cables yourself, check out Darren’s post here: http://mellowd.co.uk/ccie/?p=1314 Share this:TwitterFacebookLike this:LikeBe the first to like this. This entry was posted in [...]

  44. [...] my studies for SWITCH and thought that I would share it with you. Thanks to a post from Darren at http://mellowd.co.uk/ccie/?p=1314 I was able to set it up to be remotely accessed via console port using an old laptop as my [...]

  45. Emil H says:

    Hi Darren.

    Do you know if you can use SSH instead of telnet for security?

  46. Darren says:

    You can’t directly, which shouldn’t be an issue for a lab set up like this. I would not use this in production.

    If you do, you could do something like this: http://seclists.org/firewall-wizards/2002/Sep/104

  47. clefty says:

    I set this up on a raspberry pi using two quad serial to USB adaptors hanging off a powered USB hub on the Pi, then made up 7 serial to RJ45 socket rollover adaptors and run straight through cat-5 to each console port on the switches, worked a treat – Thanks for this info – really helped me out!

Leave a Reply

© 2009-2014 Darren O'Connor All Rights Reserved