Saturday, December 19, 2015

Using the GNS3 IOU VM on Hyper-V

 on  with No comments 
In ,  
I wanted to install GNS3 on one of my VM hosts because I leave those running and it would be convenient to have my topology always running.  Unfortunately for this idea, the VM hosts are already running Hyper-V, and as we all know, Hyper-V and VirtualBox do not play together nicely. So I started thinking about how I could get the IOU VM running in Hyper-V rather than VirtualBox. The problem is that every time I tried to put the VM on anything but a host-only network, IOU devices would not pass traffic to or from any non-IOU device. Normally I just use VirtualBox because it works, and it integrates nicely with GNS3. So after a lot of tinkering, here's how I got it working.

First, go into Hyper-V and create an internal virtual switch. As you can see in the screenshots, I went ahead and set up a few so I can use them for tying in other Hyper-V VMs into my topology later. In the Hyper-V manager, select the Hyper-V server that you've installed GNS3 on, and then under actions, select Virtual Switch Manager.  Hilight Internal and click Create Virtual Switch.


Next, we'll assign an IP address to the new interface. First, open up Network and Sharing Center by right clicking on the network icon in your system tray and selecting the obvious choice. In my screenshot, you'll notice that I have a network interface for each virtual switch present in Hyper-V. I'm using "Internal vSwitch 1" for this.


Click on the appropriate interface and drill down to the IPv4 settings. To keep everything consistent with what you'll see in the existing documentation, I chose 192.168.56.1.


OK your way back out of this, and you now have a virtual network ready to connect your VM to.

Next, grab a copy of the IOU VM. I've moved mine from GNS3 install to GNS3 install for some time, so I don't remember where I downloaded it from or what version it originally was. It's version must match the version of GNS3 you're using it with, but it is editable if it doesn't. When you download the VM, it comes in .ova format, which is the Open Virtualization Format. Wikipedia says this is "an open standard for packaging and distributing virtual appliances or, more generally, software to be run in virtual machines." Unfortunately we can't use this directly in Hyper-V, but it can be converted relatively easily.

To convert the VM, you'll need access to a computer with VirtualBox installed on it. You should be able to install it in another of your Hyper-V VMs, but I haven't tried this, I just used another computer that had VirtualBox on it. VirtualBox comes with a great command line tool called VBoxManage that can perform dozens if not hundreds of tasks involving your VM library. We'll be using this to convert the VM. Import the .ova you downloaded into VirtualBox,then note where VirtualBox stores it's files. From a command line, execute:
   VBoxManage clonehd --format hvd oldfile.vmdk newfile.vhd
And after a few minutes, you'll have the new .VHD file.  Transfer this file to your Hyper-V server and store it where your virutal harddisk files are.

Next, we'll build a VM using this newly created .VHD file. In the Actions pane of Hyper-V Manager, select New, and then Virtual Machine. Give it a name on first screen and hit next. Select Generation 1 if you are running a newer version of Hyper-V and hit next. For starting memory, I went with the VM's default of 2GB, but you can give it more if you have it available and will be running a lot of devices out of it.  For configure networking, you can just leave it as not connected for now because we won't be using this interface. Hit Next. For Connect Virtual Hard Disk, Select "Use an existing virtual hard disk," Hit Browse, and find your .vhd file.  Hit next.  On Installation Options, leave Install an operating system later selected, and hit Next. On the summary screen, review your settings and then hit Finish.  The VM will be created now.

Now that the VM has been created, we'll make a couple minor edits to it's configuration. Hilight your new VM, right click on it and select settings. The left field shows your options.  Find your network adapter and click on it. Then in the settings for that Adapter, find Remove and click it. Next, back on the left side, find Add Hardware and select Legacy Network Adapter. In the settings, bring down the list under Virtual Switch. If your version of the IOU VM matches your GNS3 version, you can select the internal virtual switch created earlier and skip the next section. If your IOU VM does not match the GNS3 version, select your real network virtual switch. Press OK.


This is the section on updating your IOU VM if it doesn't match the GNS3 version.  Start up the VM, and wait for the login prompt.  Login with the user root and password cisco.  Move to /etc/network and open the interfaces file.  You'll want these two lines for the eth0 interface:
     auto eth0
     iface eth0 inet dhcp
Then restart networking with the command 
     /etc/init.d/networking restart
Once your VM picks up an IP address, run these two commands in order to update your vm, using the version number of your version of GNS3.
     pip3 install gns3-server==1.3.13
     pip3 install gns3-gui==1.3.13
Note that I recieved an error on the second command. I rebooted the VM and ran it again, and it completed cleanly, so I didn't bother making a note of the error. Now that your VM is up to date, go back to /etc/network and change out the config for eth0 to:
     auto eth0 
     iface eth0 inet static
     address 192.168.56.101
     netmask 255.255.255.0
Restart networking again. Finally, back at the Hyper-V Manager, change the network adapter of your VM to connect to the Internal virtual switch rather than the live network virtual switch. 

Configuring GNS3 is no different than if you were using the IOU VM in VirtualBox. Go to Edit > Preferences and then select Server in the left pane. Under Local Server, change  your Host Binding to 192.168.56.1. Then go to the Remote Servers tab. Enter 192.168.56.101 under Host and 8000 TCP under port, then press Add. Hit OK, and you're ready to roll.

You now have a GNS3 IOU VM working in Hyper-V and presenting itself to GNS3 exactly the same as it would with VirtualBox running as a "Host-only Adapter." 

One note about connecting to GNS3 cloud devices. You will need to add a GNS3 generic switch between an IOU device and a cloud device. Other than that, IOU devices can connect directly to any other device you add into GNS3.
Share:

0 comments:

Post a Comment

Discuss this post!