Cisco Virtual IOS on GNS3

The tutorial discuss the use of  GNS3 software to run Cisco Virtual IOS (vIOS). Cisco vIOS is  shipped and supported as a part of the Cisco's One Platform Kit (onePK) that is distributed in form of virtual machine. It might be downloaded with Cisco.com account. Currently, it is not required to have Cisco account associated with service contracts, Bill-to IDs, or product serial numbers in order to download onePK.

Software Prerequisites

  • Host OS - any 64 bit Linux OS
  • Qemu emulator and virtualizer compiled with x86_64 support
  • KVM
  • GNS3 0.8.7
  • Cisco all-in-one-VM-1.2.1-194.ova virtual machine

Minimum Hardware Requirements

  • CPU with hardware virtualization support (AMD-V or VT-X virtualization extensions)
  • Storage - 10 GB
  • RAM - 2000 MB
  • RAM vIOS - 384 MB

Script for Extracting vIOS from All-In-One VM

Here is a Linux bash script that helps you to extract vIOS  vios-adventerprisek9-m.vmdk  from  all-in-one VM file. Download all-in-one.ova file and assign executable privileges to the script.

$ chmod +x extract_vios.txt

Then you can run the script as it is shown below.  The only user input is selecting path to all-in-one VM file and entering a root password needed for temporary mount of raw image.

$ ./extract_vios

Script Requirements

  •  VirtualBox or Qemu installed
  • +21GB free hard disk space to convert vmdk to raw format
  •  Root password to mount raw image

Configuration Steps for Extracting vIOS from All-In-One VM

1. Download the onePK All-In-One Virtual Machine

2. Extract Files from Virtual Machine

$ tar xvf all-in-one-VM-1.2.1-194.ova

Picture1-Content_of_OVA

Picture 1 - Content of OVA Tarball

The virtual disk all-in-one-VM-1.2.1-194-disk1.vmdk contains vIOS image that we are going to extract from the disk.

3. Extract vIOS from Virtual Disk

We can directly extract the vios image out of all-in-one-VM-1.2.1-194-disk1.img file.

a) Convert vmdk to raw disk

Use qemu-img utility to convert vmdk disk type to raw disk.

$ /usr/local/bin/qemu-img convert -O raw all-in-one-VM-1.2.1-194-disk1.vmdk all-in-one-VM-1.2.1-194-disk1.img

b) Check the available partitions inside the virtual disk

$  fdisk -l all-in-one-VM-1.2.1-194-disk1.img

Picture2-Available_Partitions

Picture 2 - Available Partitions 

c) Determine where the partition with vIOS image starts inside the virtual disk 

The first partition flagged with boot option contains vIOS image. The partition starts at the sector 2048. The sector size is 512 bytes. When we multiple the starting sector number and the sector size we calculate the offset where the partition starts ( 512 x 2048 = 1048576 ).

$ echo '2048 * 512' | bc
1048576

d) Mount the partition and extract vIOS image from partition

Thanks the computed offset we can mount the partition and extract  vIOS image from partition.

$ mkdir mount-point
$ sudo mount -o loop,ro,offset=1048576 all-in-one-VM-1.2.1-194-disk1.img mount-point/
$ tar xvf ./mount-point/usr/share/vmcloud/data/images/vios-adventerprisek9-m.ova -C /home/brezular/

The expected result is the file vios-adventerprisek9-m.vmdk located in a directory /home/brezular/.

4. Configure GNS3 to Run vIOS Disk

Start GNS3 and create a new project. Navigate to Edit -> Preferences -> Qemu -> General Settings. Configure Qemu general parameters and click test button.

Picture3-Qemu_General_Settings

Picture 3 - Qemu General Settings

Go ahead and configure GNS3 Guest settings. Navigate to Edit -> Preferences -> Qemu -> Qemu Guest. Configure vIOS parameters according to the picture below.

Picture2-Qemu_Guest_Settings

Picture 4 - Qemu vIOS Guest Settings

Picture3-Show_Version_Command

Picture 5 - Show Version Command

According to the show version command, vIOS distributed with onePK virtual machine is only demo version.

5. Testing Connectivity

The topology consists from the two routers running vIOS that are connected via GigabitEthernet0/0 interfaces.

Picture4-Topology

Picture 6 - Testing Topology

Configure vIOS routers as following.

Router>en
Router#conf t
Router(config)#hostname vOS-I
vIOS-I(config)#interface GigabitEthernet 0/0
vIOS-I(config-if)#ip address 172.16.1.1 255.255.255.0
vIOS-I(config-if)#no shutdown
vIOS-I(config-if)#do wr

Router>en
Router#conf t
Router(config)#hostname vIOS-II
vIOS-II(config)#interface GIgabitEthernet 0/0
vIOS-II(config-if)#ip address 172.16.1.2 255.255.255.0
vIOS-II(config-if)#no shutdown
vIOS-I(config-if)#do wr

Successful ping issued on the vIOS-I router proves that connectivity is established between virtual IOS instances.

Picture5-Ping_the_router

Picture 7 - Ping Between vIOS Instances

End.

42 thoughts on “Cisco Virtual IOS on GNS3

  1. Thanks for this very interesting article. Slight glitch:
    Start onePK Qemu Virtual Machine

    $ /usr/local/bin/qemu-system-x86_64 ./all-in-one-VM-1.2.1-194-disk1.vmdk-enable-kvm -m 2G

    needs to be replaced by
    $ /usr/local/bin/qemu-system-x86_64 ./all-in-one-VM-1.2.1-194-disk1.img -enable-kvm -m 2G

    1. I'm not sure about the features it offers. You must test it by your own. But I'm 100% sure that some features that are normally done by ASICs can't be emulated by the image.

  2. You can directly extract the vios image out of all-in-one-VM-1.2.1-194-disk1.img
    Replace step 3 to 5 with the following:

    $ qemu-img convert -O raw all-in-one-VM-1.2.1-194-disk1.vmdk all-in-one-VM-1.2.1-194-disk1.img
    $ /sbin/fdisk -l all-in-one-VM-1.2.1-194-disk1.img

    Disk all-in-one-VM-1.2.1-194-disk1.img: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0005a663

    Device Boot Start End Blocks Id System
    all-in-one-VM-1.2.1-194-disk1.img1 * 2048 37750783 18874368 83 Linux
    all-in-one-VM-1.2.1-194-disk1.img2 37752830 41940991 2094081 5 Extended
    all-in-one-VM-1.2.1-194-disk1.img5 37752832 41940991 2094080 82 Linux swap / Solaris

    # Partition 1 is the main partition
    $ mkdir mnt-dir
    $ echo '2048 * 512' | bc
    1048576
    $ sudo mount -o loop,ro,offset=1048576 all-in-one-VM-1.2.1-194-disk1.img mnt-dir
    $ cp -p mnt-dir/usr/share/vmcloud/data/images/vios-adventerprisek9-m.ova
    $ sudo umount mnt-dir

    Cleanup

  3. root@Pc:/home/Downloads/onepk# /usr/local/bin/qemu-img convert -O raw all-in-one-VM-1.3.0.181-disk1.vmdk all-in-one-VM-1.3.0.181-disk1.img
    qemu-img: Could not open 'all-in-one-VM-1.3.0.181-disk1.vmdk': Operation not permitted
    qemu-img: Could not open 'all-in-one-VM-1.3.0.181-disk1.vmdk'

    Is this something Cisco has blocked in 1.3 version cause i see you guys playing with 1.2 only... any suggestions???

    1. In fact, the name of the downloaded file is all-in-one-VM-1.3.0.181.ova so you have to use the command:
      /usr/local/bin/qemu-img convert -O raw all-in-one-VM-1.3.0.181.ova all-in-one-VM-1.3.0.181.img

  4. Does it work in Windows? I got it running but Only with graphic option, which is CPU intensive. otherwise I got connection refused! error.

    1. Yes, it works also on Windows. To troubleshoot it on Linux try this:
      1) get the console port e.g 5001
      left click on device, or issue the command show device name_of_your_device in GNS3 console
      2) start device and issue the command netstat -ano | grep 5001. If no output is displayed, socket is not created - check your configuration. If there is an output like this a socket is created and waiting for connection:
      tcp 0 0 127.0.0.1:5001 0.0.0.0:* LISTEN off (0.00/0/0)
      Then you can connect to console port of your device with the command:
      telnet 127.0.0.1 5001.
      Issue the command netstat -ano | grep 5001 and noticed Established connection from 127.0.0.1:50216 to your device 127.0.0.1:5001 and vice versa.

      tcp 0 0 127.0.0.1:5001 0.0.0.0:* LISTEN off (0.00/0/0)
      tcp 0 0 127.0.0.1:50216 127.0.0.1:5001 ESTABLISHED off (0.00/0/0)
      tcp 0 0 127.0.0.1:5001 127.0.0.1:50216 ESTABLISHED off (0.00/0/0)

      Note: if the GNS3 device is not started and there is output displayed after the command netstat -ano | grep 5001, another application is using the socket 127.0.0.1:5001.

  5. Hi,

    I use the GNS3 beta 4 in a Ubuntu 14.04 64 VM. The vIOS works, but the boot takes forever. Once it is started it is responsive on the console, so it does not appear slow, but the interfaces are not working. In GNS3 the interfaces are Ethernet0 and in vIOS Ethernet0/0.
    The capture is not working as well, but work fine for IOS and IOU on the same system.
    Any idea?

      1. Hi, i don´t use KVM and NIC type e1000. I also noticed that the interface status in GNS3 is alway up, even if the NIC are shutdown in vIOS.
        I have now tried to use the gns3 patched qemu version 0.14.1 for Linux 64bit from the GNS3 website.
        The boot process is much quicker now, but the same problem with the interfaces.

          1. Hi,

            I tried the old qemu version from the GNS3 website as I was not sure if the never versions did include the patches mentioned on the GNS3 website. Now I compiled the latest qemu by my self (v2.1.2) and the interfaces work now fine.
            The only annoying thing is the messages about the tftp in the vIOS console:

            %Error opening tftp://255.255.255.255/cisconet.cfg (Timed out)
            %Error opening tftp://255.255.255.255/router-confg (Timed out)
            %Error opening tftp://255.255.255.255/ciscortr.cfg (Timed out)
            %Error opening tftp://255.255.255.255/network-confg (Timed out)

            "no service config" does not seem to have any effect to disable it.

            But let me thank you for the real good blog and all your work!

          2. To get rid of the messages you have to save your configuration. After reboot, messages have gone. I don't know how to stop sending messages on running system as it really seems that the command "no service config" has no effect.

  6. I'm missing a basic step - I can't seem to figure out how open a console sessions to the boxes. When I do the test in Figure 3, all components start except pemu.
    I do the configuration of the vIOS guest settings. But when I try to open a console, I see:
    ~ cwr$ telnet 127.0.0.1 3003 ; exit
    Trying 127.0.0.1...
    telnet: connect to address 127.0.0.1: Connection refused
    telnet: Unable to connect to remote host
    logout

    [Process completed]

    Suggestions?

    thanks in advance!

    1. I forgot to mention - I'm running on a Mac OS X 10.9.5. And running 0.8.7. I have been trying to figure out path qemu on my Mac, but I probably need a strong hint.

  7. Another slight glitch:

    +21GB free hard disk space to convert vmdk to raw format

    +2.1GB free hard disk space to convert vmdk to raw format

  8. Hi Sir,

    Can you provide me a all-in-one-VM-1.2.1-194.ova file or all-in-one-VM-1.2.1-194.img or the vIOS file? I have export the vIOS from the VM-1.3.0-181 that only download from cisco. According to my lab & checking, vIOS works. But it can not be able to ping between the connected link. Thanks very much.

    From one loyal fans

    1. Hi, seems that my free Cisco account have no sufficient privileges to download all-in-one-VM anymore. I get Your account does not have the appropriate access to display the requested page. Please contact your Cisco account representative for further direction message. Anyway, I sent to en mail.

      1. Hi , it's not my Cisco Account problem.
        Firstly I want to ask some questions for help. During vIOS initial running, it has some pre-config such as tftp for startup.config, right?
        Secondly all the vIOS version are the same? for example, all-in-one-VM-1.2.1-194 & all-in-one-VM-1.3.0-187. I think maybe the version is reason that can not be able to ping using straingt link. Could you give some solutions? I only can download the 1.3.0-187 version and can not find the 1.2.1-194 version from cisco.
        Many thanks

        1. Firstly I want to ask some questions for help. During vIOS initial running, it has some pre-config such as tftp for startup.config, right?

          Yes.

          Secondly all the vIOS version are the same? for example, all-in-one-VM-1.2.1-194 & all-in-one-VM-1.3.0-187.

          I'm not sure. You need to check it by your own.

          I think maybe the version is reason that can not be able to ping using straingt link. Could you give some solutions?

          I don't think so. Probably a problem in your configuration?

  9. I also using Cisco ViOS with version all-in-one-VM-1.3.0.181.ova

    There's no option for creating VLAN

    and then interface Gi0/0 get IP DHCP 10.0.2.15

    When i'm using int Ge0/1 between to vIOS , i cann't get it to ping each other

    Any Clue ?

    1. Hi,
      you are using vIOS Layer3 image that's why you can't create VLANs. IP address 10.0.2.15 is IP assigned from Qemu built-in DHCP server. You should configure a static IP address for Ge0/1.

  10. Could you please also share how to get IOSv-L2 image?
    Does Cisco provide that in a different package?

    Thanks!!

  11. unable to download from cisco website getting this error.
    our account does not have the appropriate access to display the requested page. Please contact your Cisco account representative for further direction.

  12. Running 10x IOSv via qemu on windows keeps my CPU at 100%.

    Understand KVM option is only for linux, Have you tested whether this IOSv+qemu runs stable on linux with 10-20 routers? CPU utilization?

    Awesome post/tutorial by the way. Thank you

  13. How to save config one the vIOSs are booted? I do copy run flash:start. When I try to stop and start them, they always come up without any config.

    Is there a way to make Qemu+vIOS+GNS3 on Windows to persist the config changes?

  14. Hey friends, copy running-config startup-config is not working what can i do???
    Thanks

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.