GNS3 is a very popular network simulation tool that runs on the major operating systems: Windows, Mac OS, and Linux. GNS3 is primarily used to emulate networks of Cisco routers and is used by professionals studying for Cisco certification exams.
GNS3 supports Cisco router software images running on the Dynamips hardware emulation program. GNS3 also supports other hardware emulation and virtualization technologies that can run Linux virtual machines: Qemu and VirtualBox.
Our interest is to emulate networks of open-source routers and switches using open-source technologies. While there are many web sites and online tutorials dedicated to using GNS3 to emulate Cisco networks and Juniper networks, I found only a small amount of information about using GNS3 to emulate a network of Linux virtual machines running open-source routing and switching software.
In this post, we show how to install and set up GNS3 and VirtualBox to emulate a network consisting only of open-source routers and hosts.
This procedure describes how to install GNS3 and its supporting software on a Linux host computer running Xubuntu 13.10. Procedures to install GNS3 in Windows or Mac OS are available in the GNS3 documentation.
GNS3 can be installed using the Ubuntu Software Center but the version available in the standard Ubuntu repositories is not the latest version of GNS3. To install the latest version of GNS3, Dynamips, Qemu, and Wireshark, do the following:
- Add the GNS3 PPA to the Xubuntu software repository
$ sudo add-apt-repository ppa:gns3/ppa
- Update repository information
$ sudo apt-get update
- Install GNS3 package from new, updated PPA repository
$ sudo apt-get install dynamips gns3
Installing the GNS3 package also installs most supporting software.
- I noticed the installer recommends two other packages be installed but does not install them because they are optional, so I installed them:
$ sudo apt-get install snmp-mibs-downloader wireshark-doc
- Next I installed the virtual PC simulator program, vpcs which is in the same PPA:
$ sudo apt-get vpcs
We successfully installed GNS3. Next, we need to install software to support running the Linux virtual machines that will be managed by GNS3.
Many users of GNS3 choose to use VirtualBox to run Linux virtual machines because, like GNS3, it works the same on Windows, Mac OS, and Linux operating systems. VirtualBox can also utilize the hardware virtualization support technologies available on most computers while Qemu can only access these features in the Linux operating system (via KVM), with restrictions. Access to hardware virtualization support makes very noticeable improvement in performance.
The procedures I demonstrate using GNS3 and VirtualBox on my Linux system should also be usable on computers running either Windows or Mac OS.
When emulating nodes other than Cisco routers, GNS3 can use VirtualBox to manage the virtual machines that run linux (or other PC operating systems).
Install from Ubuntu Software Center
The easiest way to install VirtualBox in an Ubuntu Linux-based system (I am using Xubuntu) is to use the Ubuntu Software Center program. Search for VirtualBox in the Ubuntu Software Center and click on “install”.
Install from downloaded package
The version of VirtualBox available in the Ubuntu Software Center is not the latest version available from VirtualBox’s developer, Oracle. The version available from the Ubuntu repositories is good enough. You don’t need the latest version. However, if you — like me — always want the latest and greatest version on your computer, follow the steps described below to install the most recent available version of VirtualBox.
To install the latest version of VirtualBox, download the latest package from the Oracle VirtualBox web site.
Then, in your File Manager, double-click on the .deb package you downloaded. The Ubuntu Software Center will automatically start and install the latest version VirtualBox from the downloaded .deb package.
In my case, I chose to install the latest version of VirtualBox, version 4.3, using the procedure described above. At the time of writing this post, the latest VirtualBox package was: virtualbox-4.3_4.3.6-91406~Ubuntu~raring_amd64.deb.
The Oracle web site also recommends installing the dkms package to ensure that VirtualBox is properly updated if the Linux kernel version changes during the a system upgrade. To install the dkms package, execute the command:
$ sudo apt-get install dkms
After installation is completed, the Oracle VirtualBox virtual machine manager will appear in the Xfce menu under “System”.
Initial GNS3 setup
In the Xubuntu start menu, GNS3 appears under “Education” and Wireshark appears under “Internet”. To start using GNS3, click on the menu command:
Start → Education → GNS3
We see a setup menu wizard appear. Just click on the “OK” button at the bottom of the wizard window. We do not need any of these setting when working exclusively with Linux virtual machines in GNS3.
Now, we see the blank GNS3 application window. At this point, we still cannot use GNS3 because we need to create the virtual machines that GNS3 will use in the emulated network.
Download Linux virtual appliances
the GNS3 web site provides a set of prepared Linux appliances that can be used to emulate routers, servers, and hosts in a virtual network. Navigate to the Appliances page on the GNS3 web site and download the appliances you will use to create virtual machines in your network emulation scenario.
For our simple tests, we will download two VirtualBox appliances from the GNS3 web site:
- Linux Core 4.7.7 (link)
- Linux Core Layer 3 switch with Quagga 0.99.22.4 and Openvswitch 1.11.0 (link)
Create virtual machines in VirtualBox
We must create virtual machines using the appliances we downloaded earlier. We need to create a new VirtualBox virtual machine for every node we plan to use in the virtual network.
The first virtual router
Start VirtualBox and then click the “New” icon in the VirtualBox VM Manager window to start the Create Virtual Machine wizard.
For the first machine, we will create the router VM. In the dialogue box, enter the name “Quagga-1”. The VM Type is “Linux” and the Version is “Other Linux”.
Then, click “Next”.
Set the memory size. Change the value to 128 MBytes. This can be changed later if we need to.
Choose the option to “Use an existing virtual hard drive” and then select the VDI file we downloaded earlier: linux-core-4.7.7-openvswitch-1.11.0_guagga-0.99.22.4.vdi.
The virtual machine is now created in VirtualBox.
The first virtual host
To create the second virtual machine, which will be used to emulate a host computer in the virtual network, repeat the steps we used to create the virtual router with the following changes:
- The VM name is Host-1
- The memory can be reduced to 64 MB
- The appliance image is linux-core-4.7.7.vdi
Just as a check, to ensure we have the basic VM working, we will start it. Click on the Host-1 virtial machine in the Oracle VM VirtualBox Manager window and then click on the green “Start” arrow. The machine will start up and you will see a terminal window with a login prompt.
Additional virtual machines
To create more virtual routers and hosts, we use VirtualBox’s Clone feature to create clones of the router and host virtual machines we previously created.
Click on the virtual machine you wish to clone, then choose the VirtualBox Virtual Machine Manager menu command:
Machine → Clone...
VirtualBox will open a dialogue box asking you for the name of the new virtual machine. If you are cloning the Host-1 virtual machine, enter Host-2 as the new machine name.
Check the box, Reinitialize the MAC address of all network cards so that the MAC addresses on the new virtual machine’s network interfaces will be different from the MAC addresses on the cloned virtual machine. This will prevent problems when using both virtual machines in the same virtual network. Then, click Next.
Then, you can choose the clone type: either a Full clone or a Linked clone. The Full clone creates a fully independent virtual machine with its own virtual disk image that is a copy of the original virtual machine. The Linked clone creates a smaller virtual disk image that is “linked” to the original virtual machine’s disk image. This linked virtual disk image will contain only the changes made to the second virtual machine so it takes up much less disk space. The Linked clone is dependent on the original virtual machine and it will break if the original virtual machine is modified.
In our case, we should use the full clone type because we have lots of disk space and our disk images are very small (less than 30 MB), and we avoid the problems that can occur if we accidentally modify the original virtual machine that is the source of all the linked clones. Select Full Clone and click Clone.
Repeat this process to create more hosts with the name, Host-x, and more routers with the name, Quagga-x, where x is a number. In my case, I create a total of three hosts and two routers.
Set up VirtualBox devices in GNS3
Each virtual machine we created in VirtualBox needs to be set up in GNS3, so that they will appear in the GNS3 user interface. We need to update the VirtualBox preferences in GNS3. Open teh Preferences dialogue box with the GNS3 menu command:
Edit → Preferences...
Then click on VirtualBox in the preference list.
In the VirtualBox preferences panel, click on the VirtualBox Guest tab. In the VirtualBox Guest panel, first click on the Refresh VM List button to load the virtual machines available in VirtualBox. The describe the first VirtualBox virtual machine you wish to use in GNS3:
- In the Identifier name field, enter name of device as you want it to appear in GNS3 (choose same as in VirtualBox)
- In the VM list field, choose the VirtualBox VM from the drop-down menu
- In the Number of NICs field, choose the number of network interfaces for the device:
- Hosts get 1 interface
- Routers get 8 interfaces
Now set up the console access for each virtual machine. The VirtualBox VMs must be configured to enable serial console access. The appliances we downloaded have this configuration enabled.
- Uncheck Reserve First NIC for VirtualBox NAT with Host OS
- Check Enable console support
- Check Enable console server (for remote access)
- Check Start in headless mode (without GUI)
Click Save to create the Host-1 VirtualBox device in the preferences panel.
Repeat for each of the other devices until all devices are created. The preferences panel will look like the screenshot below:
Create a new custom device symbol in GNS3
It is helpful to have a custom device symbol to represent the VirtualBox device running one of the router virtual machines. To create a new custom symbol, open the Symbol Manager dialogue box with the GNS3 menu command:
Edit → Symbol Manager
Select a symbol you want to re-use (I chose the router symbol). Then, click on the “>” button to move a copy of the symbol over to the Customized Nodes box.
Now we see the router symbol in the Customized nodes box. Click on the new router symbol and change the Name to something descriptive, like “router-virtualbox”, and Type to “VirtualBox guest”.
The click the Apply button to make the changes. You now see a customized node, router-virtualbox in the Customized nodes box.
We do not need to create a customized node for the hosts. There is already a virtualbox host symbol in the symbol library: vbox_guest.
Click OK to close the Symbol Manager window.
Now, when you click on the Browse all devices button on the GNS3 user interface, the custom node, router-virtualbox is available.
Conclusion and next steps
After completing the procedure described above, GNS3 is prepared to set up a network that will include up to two Linux routers and three Linux hosts.
GNS3 provides a lot of functionality that we do not use when we work exclusively with Linux virtual machines as routers and hosts in the GNS3 simulated network. However, there are some specific details that users need to know when setting up and using Linux virtual machines to create a simulated network. In this post, we covered those set up procedures.
We will discuss the details related to using the Linux virtual appliances provided by the GNS3 project in a simulated network in a future post.