VyOS Installation on Qemu

VyOS is a community fork of Vyatta, a Linux-based network operating system that provides software-based network routing, firewall, and VPN functionality. The VyOS project was started in late 2013 as a community fork of the GPL portions of Vyatta Core 6.6R1 with the goal of maintaining a free and open source network  operating system in response to the decision to discontinue the community edition of Vyatta.

VyOS runs on both physical and virtual platforms. It supports paravirtual drivers and integration packages for virtual platforms. It is completely free and open source.

The aim of the tutorial is to show VyOS installation on Qemu virtual machine and  get it working on GNS3.

VyOS Qemu and VirtualBox virtual disks can be downloaded here.

I have created a Bash script deploy_vyos.sh for an automatic deployment of VyOS to Vmware image. The script downloads stable VyOS ISO image from the Internet,  creates VMware disk and starts Qemu virtual machine with attached ISO image. When a virtual machine boots up, you must start Expect script install_vyos.exp which automatically installs VyOS network OS without user intervention.

You just need to copy both scripts to the same directory and assign execute privileges to the scripts with the command below.

$ chmod +x deploy_vyos.sh
$ chmod +x install_vyos.exp

Then run the script deploy_vyos.sh  first and the script install_vyos.exp as the second.

$ ./deploy_vyos.sh
$ ./install_vyos.exp

Software and Hardware Prerequisites

  • Host OS - any 64 bit Linux OS
  • Hypervisor - Qemu emulator and virtualizer compiled with x86_64 support
  • KVM
  • GNS3 1.0 beta3 and later - the first new GNS3 version that has built-in support for Qemu hypervisor
  • VyOS Installation ISO image
  • CPU with hardware virtualization support (AMD-V or VT-X  extensions)
  • RAM minimum - 512 MB
  • Storage - 2 GB

1. Download VyOS x64 Installation ISO

$ wget http://0.uk.mirrors.vyos.net/iso/release/1.1.0/vyos-1.1.0-amd64.iso

2. Create VMware Virtual Disk

$ /usr/local/bin/qemu-img create -f vmdk vyos-1.1.0-amd64.img 1G

3. Start Qemu Disk with Attached VyOS ISO

$ /usr/local/bin/qemu-system-x86_64 -boot d -cdrom ./vyos-1.1.0-amd64.iso -hda vyos-1.1.0-amd64.vmdk -enable-kvm -m 1G -serial telnet:localhost:3355,server,nowait

Connect to VyOS console with the telnet command:

$ telnet localhost 3355

4. VyOS Installation

Login as user vyos with the password vyos. Issue the command install system to install a new system to hard drive and follow installation instructions.  When installation is finished, do not reboot the system as we are going to adapt VyOS to support GNS3. To make changes in VyOS that is installed on the /dev/sda1 disk we first have to mount it the disk.

vyos@vyos:~$ sudo su
root@vyos:/home/vyos# mount -t ext4 /dev/sda1 /tmp

Now our VyOS installation is mounted to the /tmp directory.

5. Stop Generating New Name for Ethernet Interfaces with Changed MAC Address

The script that controls Qemu VMs inside GNS3 is called Qemuwrapper. It starts Qemu virtual machines with randomly generated MAC addresses. VyOS with underlying Debian Linux is programmed to remember MAC address of existing Ethernet interfaces. When a new MAC address is assigned to the interface by Qemuwrapper), VyOS increases the number of interfaces.  As a result, the number of  interfaces is doubled every time VyOS is rebooted.

The workaround below makes VyOS to keep the interface name when MAC is changed:

Rename the file vyatta_net_name to  vyatta_net_name_backup.

vyos@vyos:~$ sudo su
root@vyatta:/home/vyatta# mv /tmp/lib/udev/vyatta_net_name /tmp/lib/udev/vyatta_net_name.bak
root@vyatta:/home/vyatta# mv /tmp/lib64/udev/vyatta_net_name /tmp/lib64/udev/vyatta_net_name.bak

6. Change Boot Order

They are several boot options available in Grub menu window when VyOS is booted after its installation. Depending how VyOS was installed, the default option is configured by VyOS itself. For instance if we issued a command install system from a Qemu window, an option KVM console would be chosen as the default option. In our case, installation was done from the telnet window (serial console) so the option Serial console is chosen as the default boot option.

Picture1_Grub_Menu_Windows

Picture 1 - VyOS Grub Menu Window

As we want to integrate VyOS Qemu virtual machine with GNS3 and use a serial console to connect VyOS instances running inside GNS3, we will do such as configuration which ensures that an option  Serial console is always selected regardless of the type of installation.

root@vyatta:/home/vyatta# sed -i 's/set default=0/set default=1/g' /tmp/boot/grub/grub.cfg

The command replaces the default option 0 (KVM console) with the default option 1 (Serial console).

VyOS Integration to GNS3 Project

7. Configure GNS3 to Run VyOS Virtual Machine

Start GNS3 and create a new project. Navigate to Edit -> Preferences -> Qemu VMs.  Configure VyOS Qemu settings as following.

Picture2_Qemu VyOS Settings

Picture 2 - Qemu VyOS Settings

Click Advanced Qemu VM Settings tab and configure following parameters.

Picture3_Advanced_Qemu_VyOS_Settings

Picture 3 - Advanced Qemu VyOS Settings

VyOS User Guide:
http://vyos.net/wiki/User_Guide

End.

6 thoughts on “VyOS Installation on Qemu

  1. Great tutorial!

    I adapted to MacOSX and it is working.
    I have one question. When I boot VyOS on GNS3 and I open the console I can´t see the VyOS boot messages. I only see something when the boot end with login prompt.
    It is possible to put some options to see the boot messages? I think that it is important because the boot is very slow.

    Regards,

    1. Hi,
      let's have a look at the available options in Grub menu. As you can see, the first default option is to boot VyOS in KVM console. That's why you cannot see boot messages in serial console window but you can see it in Qemu window. There is a Qemu option -nographic configured in my tutorial (Picture 4) that prevents Qemu popup window to open.
      In fact, they're three options here. Either change the default boot options to Serial console in OS or manually select boot to Serial console during the boot when the Grub menu appears. The third option may be to delete -nographic option and check messages in Qemu window.
      To change the default boot order from kvm to serial console permanently, navigate to /boot/grub/grub.cfg and change line set default=0 to set default=1.

      GNU GRUB version 1.98+20100804-14-vyatta6+hydrogen1

      +--------------------------------------------------------------------------+
      |VyOS 1.0.4 linux (KVM console) |
      |VyOS 1.0.4 linux (Serial console) |
      |VyOS 1.0.4 linux (USB console) |
      |Lost password change 1.0.4 (KVM console) |
      |Lost password change 1.0.4 (Serial console) |
      |Lost password change 1.0.4 (USB console) |
      +--------------------------------------------------------------------------

  2. Hello! Thanks for your tutorial. Have you tried this on 1.0.5 in GNS3? I tried it as the tutorial described but I can't ping between the interface and a cisco router. Also, after rebooting VyOS the interface names will still change.

    Is there more we need to do for 1.0.5?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.