Well for the longest time there was no generally available way to emulate a cisco L2 switch. right beforeÂ Dynamips was abandoned, in 0.28RC1, there was actually some work on the the Catalyst 6000 Supervisor 1 line card, although no interfaces are supported, and it was largely seen as impossible at the time.
While there may have been leaks of the internal IOU or IOS on UNIX, these are even more dubious than buying your own cisco 7200 and running that IOS on Dynamips. Â Indeed in the old days you’d no doubt find people with home labs that look something like this:
So yeah, I know it’s not new but it was new to me. Â But yes, VIRL is something us mere mortals can buy without a CCIE on hand, or a multi-million dollar contract on hand. Â Although it isn’t free, but compared to everything else cisco sells it’s cheap…
So VIRL comes in a few different flavors. Â They do have an ISO to run on bare metal x86 machines, OVAs for deployment on VMWare Workstation, and ESXi (Although for player you’ll have to get VIX and the vmnet config util from workstation, as I went through here & here).
Although that’s not so much what I’m interested in. Â As always I’m more interested in something that lets me run it on my own.
So as of today, the latest file isÂ vios_l2-adventerprisek9-m.vmdk.SSA.152-4.0.55.E, with the MD5 checksum ofÂ 1a3a21f5697cae64bb930895b986d71e.
So as a first test, you can run the L2 image with Qemu/KVM! Â I found it works better renamingÂ vios_l2-adventerprisek9-m.vmdk.SSA.152-4.0.55.E toÂ vios_l2-adventerprisek9-m.vmdk.SSA.152-4.0.55.E.vmdk otherwise there was some issues with Qemu picking up the image.
The command line for a switch can be a little crazy so it’ll break some of it up onto separate lines. Â This way you can see that I bound a few interfaces to listen on UDP, while most of them are unbound, but you get the idea. Â Naturally it being a cisco product, it drives with a serial console.
-net none -device e1000,mac=00:2e:3c:92:26:00
-device e1000,mac=00:2e:3c:92:26:06 -device e1000,mac=00:2e:3c:92:26:07
-device e1000,mac=00:2e:3c:92:26:08 -device e1000,mac=00:2e:3c:92:26:09
-device e1000,mac=00:2e:3c:92:26:0a -device e1000,mac=00:2e:3c:92:26:0b
In some ways, this is very much like running Solaris on QEMU via a serial console. Â Once booted up, if you grab the console you’ll see:
Now, while I think it’s interesting to play with, but I know many people don’t like to setup and run a dozen programs manually, so how do we get this to run underÂ GNS3!
As of right now the current version is 1.5.3, so let’s step through this real quick
First when you fire it up (by default) you’ll get the option to specify using a local server
Next you will want to check the box to add a Qemu VM
give it a name like adventerprisek9-m.vmdk.SSA.152-4.0.55.E… Or anything else you wish to call it.
Next I set the emulator to qemu-system-i386.exe and give it 768MB of RAM.
hit next, and then it’ll prompt to select a disk image. Â In this example, remember I had renamed the downloaded VIRL image to have a VMDK extension.
Then GNS3 will prompt to add it to the default images directory
After that the wizard is complete.
However there is still a bunch of settings that still need to change. Â If you don’t make these changes you’ll have a switch with a single Ethernet port, and you will only be able to deploy a single switch, so that won’t be any fun!.
Once the wizard has finished you’ll be in the Preferences. Â Just hit edit, on the template we just added, or otherwise it’s under Edit->Preferences.
First thing is kind of cosmetic, but go ahead and set the Category to Switches, so that way it ‘flows’ nice in the UI.
Next hit the Network tab, and then add some adapters.
I’ve set the switch to 12 adapters. Â The default of 1 isn’t too useful. Â Next up hit the Advanced settings tab. Â Be sure to un-check the ‘Use as a linked base VM’ . This will let you deploy multiple copies. Â On Windows there is some weird issue where changes are seemingly not saved, so be sure to have a config backup strategy beyond saving the config locally.
Great, hit OK, and now we’ve got our L2 template for GNS3!
As a bonus, I put it on Linux, and it’ll run under KVM, however if you use the cisco downloaded files, you’ll see this error while booting:
-Traceback= 1DBB7C8z 8DBFE5z 90522Ez 904F50z 904D5Dz 900F45z 901B7Bz 901B0Fz 8D7C0Dz 8D7B0Dz 887061z 8BAE73z 8B9FD7z 8B7827z 8BCCC4z 8C0587z – Process “Async write process”, CPU hog, PC 0x008D7D62
Over and over, and it’ll be generally slow. Â For some reason KVM/Qemu on Linux is struggling with the VMDK. Â So the solution is to simply convert it from a VMWare VMDK into a Qcow2 image with:
qemu-img convert -f vmdk -O qcow2 vios_l2-adventerprisek9-m.vmdk.SSA.152-4.0.55.E.vmdkÂ vios_l2-adventerprisek9-m.vmdk.SSA.152-4.0.55.E.qcow2
Now using the qcow2 file, the switch will boot up just fine!
For any reference I’m runningÂ Ubuntu 16.10
and the KVM version is:
# kvm –version
QEMU emulator version 2.6.1 (Debian 1:2.6.1+dfsg-0ubuntu5.3), Copyright (c) 2003-2008 Fabrice Bellard