HOWTO: Install GNS3 in Gentoo Linux
Since I recently switched to Gentoo Linux, I had a bit of a learning curve in getting my must have apps installed. One of those applications is GNS3, a graphical network simulator application that sits on top of Dynamips. Dynamips is an Open Source Cisco router simulator. Dynamips isn't exactly user friendly to those with little command line experience. If you read my previous article on getting Dynamips installed under Ubuntu, you can see why. Getting a single router up and running isn't too hard. When it comes time to simulate a network with several routers and interconnections, it gets tricky. The companion program, Dynagen, helps to ease this somewhat. You basically start a Dynamips Hypervisor (think virtual machine) and create several router instances which you can then telnet to. But even that can be a pain.
This is where GNS3 comes in. GNS3 (Graphical Network Simulator 3) is a graphical frontend to Dynamips. It makes router simulation as easy as just dragging routers on to a network map and interconnecting them (think Visio). Below is a picture of GNS3 as it looks when first started (click the image to zoom):
Installing GNS3 is easy enough in Debian-based systems. A simple
% sudo apt-get install gns3
does the trick. Gentoo, due to its compiled nature, takes a little more work. Gentoo uses the Portage system for software management. Portage is highly configurable. You can configure exactly what gets installed, what doesn't, and how to optimize the software for your particular system.
Installing most software in Gentoo is as simple as using the emerge utility. You simply search for what you would like to install using
% emerge --search program
then type
% emerge program
(either as root or preferably with sudo) where program is something like Gnome, Apache, or even your favorite shell. This is all fine and dandy assuming that the software is in the portage tree. Unfortunately, GNS3 is not. However, all is not lost. Gentoo comes with a number of "Overlays" that allow the installation of additional software. Be advised, though, that since the overlays are not in the main portage tree, you could experience stability issues, though that's not terribly likely.
The first thing to do is to install layman, the overlays manager. First add subversion to your /etc/portage/package.use like so: "app-portage/layman subversion". The overlay we want to use requires subersion. Now, build layman with a simple
% emerge -av app-portage/layman
Once that's done, you'll first want to list the available overlays using
% layman -L
You should see a considerable list of overlays. The one we need is the sunrise overlay. You'll notice that most overlays use a different means of syncing code (either Git, Rsync, or Subversion). Portage uses rsync. In our case, the sunrise overlay uses Subversion, so before we go any further, install subversion using
% emerge -av dev-util/subversion
Once completed, you may now add the sunrise overlay using
% layman -a sunrise
Now, add the following line to your /etc/make.conf:
% source /usr/local/portage/layman/make.conf
Failing to add this line means your overlays will not build.
Once you've added the sunrise overlay, you'll want to sync it using '
% layman -S
'. You should see some text fly down your terminal as it downloads the build tree.
Before we build GNS3, you'll want to adjust your make flags. GNS3 uses the python QT api so you'll want to add qt3 and qt4 to your use flags if you don't already have them. If you built your Gentoo system using the default desktop profile you should already have them.
The last thing we need to do is to adjust the keywords flags for Dynamips. These specify which platform you will allow software to be built for (amd64, x86, etc...) You simply place the keywords in /etc/portage/package.keywords. I won't go into any detail since keywords can get complicated. All that is needed is to create an empty file called package.use and place the following in it:
net-misc/gns3 ** app-emulation/dynamips ~amd64
If you're on a 32 bit x86 processor, you'll want to adjust the dynamips keyword. It's also possible to specify versions of software and which platform to build for but that's beyond the scope of this article.
At this point, a simple
% emerge -av net-misc/gns3
should get you up and running. Due to the many different systems and quirks, you may experience some build errors. I've run into situations where a build failed but if I ran the build again, it worked. A simple Internet search should help to resolve any build issues.
When you start GNS3 for the first time, it'll ask you to locate your IOS images. I keep mine in ~/.gns3/images/ and store them by platform. Remember that you should have a license to run these images as they are not freeware. Simply following the prompts should get you up and running. The interface has pop-up help so if you hold your mouse over any of the buttons, you'll get an idea of what it does.
Drag a few routers onto the map and connect them with links. If you haven't already done so, emerge the telnet application so you can telnet to your routers.
Many complex configurations can be performed in GNS3. I've used it to study for a number of Cisco certification tests. For peak performance you'll want as much RAM as you can get. I'm running a 64 bit system with 6 Gigabytes of RAM and am able to run at least 12 Cisco 3640 routers in a BGP and MPLS mesh chock full of VRFs. Your only limit is your imagination!
Happy simulating!
For more information:
Dynamips: http://www.ipflow.utc.fr/index.php/Cisco_7200_Simulator
GNS3: http://www.gns3.net
Gentoo Overlays: http://www.gentoo.org/proj/en/overlays/userguide.xml
