Docker Gns3

 

Docker ubuntu with GNS3 v2https://www.gns3.com/marketplace/appliance/ubuntuhttps://github.com/GNS3/gns3-gui/releases/tag/v2.0.0rc3. Using the OpenSwitch Docker Appliance with GNS3. In order to use OpenSwitch as a container with GNS3, you have to main options: use an existing image (easier one), or build a custom one from scratch (useful for developers). Using an Existing OpenSwitch Container Image. GNS 2.2 now supports additional persistent volumes for Docker containers. This means you won't keep losing your installed applications and work!

In one of my previous articles,I elaborated on a setup to create DC fabric simulations with GNS3 and OpenSwitch.I also promised to follow up with some post about using Ansible with it.

This tutorial is for users who never used Docker, and would like to create a Docker container for GNS3. First, you need to connect to the GNS3 VM and open a shell. Press the Enter key while is highlighted: On the next screen, press the Down arrow key until Shell is. GNS3 now has a AAA Docker Container. This makes it really easy to add RADIUS and TACACS servers to your GNS3 topologies!For lots more content, visit http://w.

Docker Nspid

Well, I have been a bit distracted with some changes to the setup before moving intothe Ansible details (to say true, I got the Ansible article almost ready, but thingsare moving so fast, that I keep rewriting it).

One of the things that ‘change everything’ recently was therelease of GNS3 1.5.This is a great release that includes several features that makes using OpenSwitch with GNS3 awesome:

  • Support for Docker containers! This enables OpenSwitch to be a container instead ofa VM, allowing to scale better:
    • This obviously consumes less RAM memory and use it more efficiently.
    • We are no longer limited to 8 ports per node (VirtualBox’s restriction), butinstead we can have as many ports as you want. Even more, the OpenSwitch Appliancecontainer will change the number of ports available, based on the GNS3 configuration.
  • Support for portable projects! Now you can export your project and shared itwith others (restrictions apply).

Let’s see how to use this new release with OpenSwitch Appliance Container.

The first recommendation when using the container setup for GNS3, is to use theGNS3 VM (even when using a native Linux host). Why?

  • Well, for running containers on Linux or Windows, you need the GNS3 VM.
    Yeah, even if you have docker for Linux/Windows, GNS3 can create the virtual interfacesfor them on these platforms.
  • Right now the only way to create a portable way to connect to the external world is touse the GNS3 Internet VM Appliance,and this only works inside the GNS3 VM.
  • With GNS3 1.5, you can setup a remote GNS3 VM machine, allowing to deploya powerful VM for running your simulations without starving your laptop.
  • Also with the GNS3 VM, there is a simplified process for setting up a proxy whenworking in a corporate environment.

Since we will be using qemu appliances inside the GNS3 VM, you need a virtualizationplatform that supports nested virtualization. That means you are either using aVMware desktop solution (Workstation, Player or Fusion), or if using ESXi, be sureto enable the VHV flag.

Installing the GNS3 VM

Gns3 Documentation

Download the VM from here. Be sure to download theright image for either desktop solution or ESXi.

You will need at least version 1.5.0, but if you are behind a corporate firewall, you will need version1.5.1 that fixes a bug when configuring the proxy settings.

After downloading the GNS3 VM appliance, import it into your virtualization solution, and reconfigurewith this minimal hardware requirements:

  • 512MB of RAM for every OpenSwitch container that you plan to run. For our examples 6GB of RAM should be enough.
  • 2 CPU cores. If you can afford more, the better.

If you are behind a corporate firewall, be sure to turn on the VM, and using the menu displayed when the VM boots,configure the proxy settings.

Configure GNS3 to use the VM

If you haven’t already, install GNS3 downloading from here(be sure to use the same version as the VM image that you downloaded).

When configuring GNS3, the wizard doesn’t allow you to configure a remote server GNS3 VM, butyou can abort the wizard, and add it later from the preferences panel (the IP address ofthe VM is show on the information page displayed by the VM on boot, or available from thetext menu on the VM as well).

I found that when working behind a proxy, the VM only works well as a remote server,since somehow the communication with it cannot be established by the UI in the presenseof a proxy (I have only experienced this with OS-XmacOS environment, not sure ifhappens on Windows or Linux).

In order to use OpenSwitch as a container with GNS3, you have to main options:use an existing image (easier one), or build a custom one from scratch (useful for developers).

Using an Existing OpenSwitch Container Image

Let’s focus on the simple procedure first. Fortunately we no longer need to specify multipleparameters on the UI to create a template, since for Docker containers we can usea pre-defined template appliance (.gns3a file), that will do all the configurationfor you.

  • First, download a GNS3 appliance template from the listavailable here.

  • Next, import it into GNS3: there is a new ‘Import appliance template’ button underthe device panel.

    Select ‘Import an appliance template file’

    Select the template that you downloaded, and follow the rest of the wizard. Selectto run on the remote server running the GNS3 VM.

Once you are done with the import, you can download a custom stencil for OpenSwitchDocker Appliance from here,and customize the template to use it.

The template uses by default 8 ports, but that can be adjusted in per machine instance.

Docker

That’s all it takes, you are ready to drag & drop container instances into GNS3!

Creating a custom Container Image

In the previous step where we used the .gns3a file, it points to a published versionof the container in the Docker Hub, but you may want to create your own container fromscratch with the latest code or modifications. If that is not the case, you can skipthis section.

First you will have to build an image for the appliance target as explained inprevious articles (you can also download the tarball for a periodic build fromthe artifact archives).

An important clarification: if you are a developer from OpenSwitch, you may be usedto know the ‘genericx86-64’ target as the container image used for testing purposes. Howeveron GNS3, we actually use the OpenSwitch Appliance images. This have implications on thenaming of the ports (ports are called ethX).

Now, the default tarball created for the appliance is designed to run in a VM, soit needs some small modifications to run properly on a container. I have automatedthe steps in a docker file here.

Here are the example commands to create a custom image with the latest code frommaster and push into the docker hub (in this example I use my docker hub account):

Now you can modify the gns3a file provided in the previous step and point to yourcustomized image to import it into GNS3.

Now, let’s create a topology for creating a DC Fabric simulation with Ansible similarto the one described in the previous article using virtual machine appliances.

I have created a docker container that already automated all the steps detailed inthe previous article, and is suitable to be run as a systemd container. The Dockerfilecould be found here, andthe GNS3 template file here.

Unlike the previous examples using VirtualBox, we cannot longer use the cloud elementto get a NAT connection to the external world, so instead we will use theGNS3 Internet VM Appliance.

After installing those two templates, we can recreate the DC fabric similar to the onefrom the previous article, with the difference that is (almost) all containers.

Gns3 Docker Start Command

Now comes another cool part, you can export and import the project to share withothers.

Gns3
Yes, that means you can ignore everything I just said about importing templatesand drawing topologies and just download a file with everything ready.I know I could have started saying this, but where is the fun if not in do it byyourself?

So, you can export the project by using ‘Export portable project’ on the filemenu. It will ask you if you wan to include any base image, which for our exampleI would recommend we do (this will pack the qemu image used by the GNS3 Internet Appliance).Docker images won’t get included on the file, but instead will be automaticallydownloaded from the docker hub when someone imports the project.

Talking about importing the project back, there is currently a bug when importingthe project and downloading the docker images,where certain imports may timeout. This is fixed for 1.5.1, but in the meantime you can workaround by deleting theproject that failed to import and re-import it again (since the docker images shouldbe already downloaded, it won’t fail the second time).

Gns3 docker container

The portable project file for the example on this article ishere, in case youwant to get up an running.

Isn’t all of this really exciting? Thanks to the GNS3 team for their awesome workand their responsiveness to fix the bug/enhancements that I keep throwing at them.

In the next article I will continue with explaining how to use Ansible to deployconfiguration to the topology we build here.

Stay tuned.

While it’s quite complicated to access the data stored in a QEMU VM(see Inspect and modify QEMU Images),it’s relative simple to access the data in a Docker VM.

Attention:Please note, that you can only access the files of the persistent directoriesand that the Docker VM needs to be stopped.Access to a running VM will be refused with permission errors.

If you happen to run the Docker VM on your local Linux server,then you can simply right-click on the device andselect “Show in file manager”.But most of us use Docker in the GNS3 VM or in a remote VM.Using “Show in file manager” will result in a popup like this:

Confirm with “Yes” to accept, that the path will be copied to the clipboard,we will need it later.

But first we need to access the GNS3 server,hosting the Docker VM.That can normally achieved by SSH.So install a SCP client like WinSCP.

For making the connection we need the IP address of the server.For that have a look in the topology summary forthe console IP address of the device.That is also the server IP address.

Docker Gns3

Create Docker Image From Vm

Now login to the GNS3 server.The GNS3 VM uses the user gns3 with password gns3.If you want to connect to a remote GNS3 server,you have to find out it’s login credentials.

Now change to the VM’s directory,in WinSCP use “Open directory” .Paste the path from the clipboard,that was previously copied by the GNS3 “Show on file manager” function.

You will see the persistent directories.For the “ipterm” VM,that are the etc/network directory for the IP configurationand “root”, the home directory of user root.

Gns3 Qemu

Opening the “root” directories shows it’s content.You can now copy files from/to your local disks to this remote location.