How to get rid of VNC and use telnet access for your Linux image?

We are, network engineers, have many *nix tools at our disposal: exaBGP, nmap, tcpdump, to name a few. And with UNetlab its very easy to run a linux system inside a topology (not to mention that you could use cloud pnet interface to bridge unetlab topology with the real world). By default UNetLab’s linux template opts to VNC access, which is cool if you have a GUI, but for a networker – CLI is the only love. In this post I will share with you a method to get telnet access to a linux image inside the UNetLab.

All credits go to my colleague – Anatoliy Kolpakov.

Tuning your image

At first you have to add serial port to your linux image to use it later in a unetlab topology. We did it for ubuntu linux, but I believe that you can find specific guides for you distributive of choice.

To add a serial port to Ubuntu linux we have to perfom a couple of easy steps:

These actions should be performed prior to adding a linux image to the unetlab. For example use VirtualBox to run linux qcow2 image and make these changes.
  1. Create a file called /etc/init/ttyS0.conf  containing the following:

  2. Ask upstart to start the getty –  sudo start ttyS0
  3. Now reboot and check that system starts normally

Full guide available on Ubuntu HowTo page.

Creating linux template

Now when you have a linux.qcow2 image equipped with serial port its time to create your own template for it, I covered the steps on this matter in details. The contents of the new template should be like these:

Now your are good to go to add linux image on a topology. Note that this time this linux image will try to connect via telnet (and should succeed).

Hope this will help you guys, use comments to ask questions if any.

Roman Dodin

Network engineer at Nokia
Eagerness to learn multiplied by passion to share.
You can reach me at LinkedIn

You Might Also Like

  • Alex

    Для 16.04 (and higher) етот метод не работает, там нужно всего лишь поменять некоторые строки в grub и обновить его.

    Ubuntu 16.04 uses systemd instead of upstart. To configure systemd for serial console, you only need to update grub2 to use the serial console, and systemd will also be configured for serial console.

    0) Add the serial port to your virtual machine and reboot it
    1) Modify the lines in the ‘/etc/default/grub’ file

    GRUB_CMDLINE_LINUX_DEFAULT=”console=tty0 console=ttyS0,115200n8″
    GRUB_SERIAL_COMMAND=”serial –speed=115200 –unit=0 –word=8 –parity=no –stop=1″

    2) Execute ‘update-grub’ command. Make sure you use ttyS0. It’s case-sensitive, otherwise you’ll only see the grub boot menu, and you won’t get an actual console.
    3) Shutdown the virtual machine, connect your favorite client (like socat, pipe, putty etc.) to the VM serial port and run the instance. You should see the output in the connected client’s screen.

    И, кстати, лучше сделать отдельную категорию для Линукса с консолью (я обозвал ее clinux):

    Add the following definition to file ‘/opt/unetlab/html/includes/init.php’
    ‘linux’ => ‘Linux’,
    ‘clinux’ => ‘Linux with serial port’, # this one
    ‘mikrotik’ => ‘MikroTik RouterOS’,