17.9 C
Karachi
Monday, January 30, 2023

Network Automation Lab on GNS3

If you are new to the world of Network Automation, the first thing you need is to set the virtual lab environment. This step-by-step guide is all about setting up a Network Automation Lab for newbies who want to get their hands dirty with Network Automation Tools.

The main objective of this setup is to connect your home network to the emulator that will be running IOS images of real or virtual routers, switches, and other network devices. Eventually, you will be able to configure the IOS of the real network device from your home network, design a test network, and also run automation scripts on the same devices.

Required Tools for Network Automation Lab

All we need is IOS images of network devices, a virtual machine that runs these IOS (GNS3 VM), an application that allows running virtual machines (VMware), and an emulating software that combines everything to create complex networks (GNS3).

Downloading GNS3 all-in-one tool

The first thing we need is emulating software i.e GNS3. It is an open-source network emulator that allows virtual and real devices to be used to simulate complex networks.

We can download GNS3 for the operating system that is currently running on your PC, I will go for Windows.

network-automation-download-gns3

Download GNS3 Virtual Machine (VM)

When you install a GNS3 on Windows, then your OS acts as a Local Server but some emulators might not properly work on Windows. This is why, it is recommended with Windows as OS, you also need a Linux Virtual Machine that is running the GNS3 server inside i.e GNS3 VM.

Since I will be using VMware Workstation Pro to run GNS3 Virtual Machine in this article, so I will choose to download VMware Workstation and Fusion. You can download GNS3 VM.

network-automation-download-gns3-vm

Download VMware Workstation Pro

Finally, download VMware Workstation Pro for the OS of your choice that will be hosting your GNS3 Virtual Machine.

network-automation-download-vmware-workstation-pro

To work everything perfectly, GNS3 and GNS3 VM must have the same software version like in our case, we have the 2.2.12 version for both.

network-automation-downloaded-files

Installation and Configuration

Installing the GNS3 all-in-one tool

Click on the downloaded file to install the same. All we need to do is to keep clicking the Next button and leaving every option to default.

network-automation-gns3-installation

Most importantly, when you reach the step as shown below, leave the checkboxes to default. As we have already downloaded GNS3 VM, we do not need to click the checkbox here to download the same again.

network-automation-gns3-installation-gns3-desktop

Lastly, click Finish and there GNS3 2.2.12 is at your disposal to play around with.

network-automation-gns3-installation-finish

Running GNS3 for First Time

After finishing the installation process, you can start the GNS3 app. If the app is starting for the first time, you will be prompted for Setup Wizard for basic configuration. Follow the screenshots shown below while setting the options as suggested.

Once the Setup Wizard is finished, you should see the GNS3 App running. On the right side of the screen, you will find the Server Summary that is currently showing that your Local Machine (OS) is working as a Server for GNS3 Appliances. In the later part of the article, we will also configure to run GNS3 VM are server also.

network-automation-gns3-setup-wizard-finish

The Green Bubble means that the server is running fine without any issue. But if you see a Red Bubble along, then you might need to restart the GNS3 App, Operating System, or both to change it to green.

Installing the VMware Workstation Pro

network-automation-vmware-workstation-pro-1

Just keep on clicking the Next Button, leaving everything to default, unless you reach the final step as shown below.

network-automation-vmware-workstation-pro-finish

When you finish the setup, you will be prompted to restart your PC: click YES to restart.

network-automation-vmware-workstation-pro-restart

Configuring Virtual Adapters for VMware Workstation

After finning the installation of the VMware Workstation and restarting the operating system, go to Control Panel > Network and Internet > Network Connections. You should find two newly added Virtual Network Adapters (VMnet1 and VMnet2) by VMware.

If you do not find these virtual adapters for instance, then something might have gone wrong with the installation process.

network-automation-vmware-network-adapters-vmnet

Right-click both Virtual Adapters one by one and click Properties.

network-automation-vmware-network-adapters-vmnet-properties

We should make sure that we set to obtain IP and DNS addresses automatically for both Virtual Network Interfaces (VMnet1 and VMNet8) as shown below.

Importing GNS3 VM to VMware Workstation Pro

Now, we will import GNS3 Virtual Machine into VMware Workstation Pro. Before doing that we should have unzipped version of the GNS3 VM.

network-automation-gns3-vm-unzipping

Open VMware Workstation and go to File>Open, locate the extracted GNS3 VM Appliance, and click open to continue.

network-automation-gns3-vm-import

You will be prompted to provide the name and storage location of the GNS3 Virtual Application being imported. You can go with the default values but I changed the storage path here.

Now, click the Import button and the appliance will start importing to the VMware.

network-automation-gns3-vm-importing

After finishing the import, you will see the window as shown below that shows the GNS3 VM virtual device details. We will not change any configuration of VM at this stage and will leave everything to default. However, if needed, we can change the RAM and CPU configuration of the VM from the GNS3 tool later.

network-automation-gns3-vm-import-finished

Click the Play (Power on this virtual machine) button to run the GNS3 VM and you will end up with the screen shown below. The two parameters should have the same value as follows: Virtualization: VMware and KVM Support available: True.

network-automation-gns3-vm-play

Enabling GNS3 VM from GNS3 Tool

Previously, we had only one default server running on GNS3 App and that is our local machine as shown below. But we want to add another Server to run GNS3 appliances i.e GNS3 VM.

To add/enable GNS3 VM as another server, you will need to enable the GNS3 VM by clicking to Edit>Preference>GNS3 VM as shown below:

network-automation-gns3-vm-preference

The virtualization engine, VM name, and other default settings will be loaded automatically in most cases. But if you do not find anything loaded as shown in the picture above, you can try restarting GNS3, VMware workstation, or PC.

You can also change the size of RAM and the number of CPU cores as per your system configuration.

More the RAM and CPU core, the faster will the GNS3 VM be running.

Finally, you should see two servers running on your GNS3: the default local server, and GNS3 VM as a server.

network-automation-gns3-running-servers

Adding Virtual Appliances to GNS3

Until now, we have our GNS3 fully loaded to create a complex network but by default, GNS3 has very few virtual appliances. To accomplish the need of setting up Network Automation Lab, we need some advanced network appliances from routers, switches, and other network automation virtual appliances.

We need the following virtual appliances at a minimum to set up a basic lab environment:

Adding Ubuntu Docker Guest Appliance to GNS3

Go to GNS3 Marketplace and download Ubuntu Docker Guest Appliance. You will get a template file with the extension (.gns3a).

network-automation-ubuntu-docker-guest-download-1

Now open GNS3 and click the “New Template” button to import the newly downloaded ubuntu appliance to it.

network-automation-gns3-new-template
network-automation-gns3-new-template-wizard-1

Now locate the downloaded template file and click the Open button.

network-automation-gns3-new-template-wizard-2

Now, keep clicking the Next button throughout the wizard while leaving everything to default. Finally, you will reach the finish screen as shown below.

network-automation-gns3-new-template-wizard-3

Now you will have Ubuntu Docker Guest showing in the End Devices section but it is simply a template.

network-automation-gns3-ubuntu-docker-installed

Create a new project on GNS3 and drag and drop the Ubuntu Docker Guest on the screen. For the first time, it will take a few minutes for pulling the image from the template file.

Once the pulling image is completed, your Ubuntu Docker Guest is ready to use in any project.

network-automation-gns3-ubuntu-docker-pulling-image

Adding Network Automation Docker Appliances to GNS3

Go to GNS3 Marketplace and download the Network Automation Docker template file.

Now follow all the steps defined in adding Ubuntu Docker Guest in the previous example and you will end up with Network Automation Docker appliance as shown below.

network-automation-gns3-network-automation-appliance

Adding Cisco7200 Router Appliances to GNS3

Virtual appliances files can have different extension like (.bin, .vmdk, .image, and .qcow2) and each have different methods of installation. In this example, we have an appliance image in (.bin) format which needs to be decompressed first and then used.

Open GNS3 and go to Edit>Preferences>Dynamips>IOS Routers and click New Button.

network-automation-gns3-ios-router-templates

Choose the option Run this IOS on the GNS3 VM and click the Next button to continue.

network-automation-gns3-ios-router-templates-wizard-1

Browse the location of the downloaded image file of Cisco7200 on your PC.

network-automation-gns3-ios-router-templates-wizard-2

Select the image file and click the Open button.

network-automation-gns3-ios-router-templates-wizard-3

Since the image is a compressed file with (.bin) extension, we will decompress it to the (.image) file extension.

network-automation-gns3-ios-router-templates-wizard-4

The image file has been decompressed and selected.

network-automation-gns3-ios-router-templates-wizard-5

Now keep clicking the Next button to continue with the default options.

Finally, the Cisco router appliance has been successfully loaded to GNS3 and is ready to be used as a virtual appliance.

network-automation-gns3-ios-router-templates-wizard-10
network-automation-gns3-ios-router-templates-wizard-11

You can drag and drop the Cisco Router c7200 Appliance on the project area and run it.

network-automation-gns3-ios-router-templates-wizard-12

Now open the router’s console on Solar Putty to see the screen below:

network-automation-gns3-ios-router-templates-wizard-13

Adding Cisco csr1000v Router Appliance to GNS3

Now in this example, we have (.qcow2) extension of the image, we will a different method for installation.

First of all, you need to copy the (.qcow2) image to the default image folder of the GNS3 App on your PC. In my case, C:\Users\Gulraiz\GNS3\images\IOS is the default location of GNS3 Images – I have copied the image file to this folder.

Now, we need to download the template file of this (.gns3a) image from the GNS3 marketplace. Go to Cisco csr1000v and download the template file.

Now we need to add a new template from GNS3:

network-automation-gns3-csr1000v-wizard-1

Choose the location of the downloaded template file (.gns3a).

network-automation-gns3-csr1000v-wizard-2

Continue with the default settings.

network-automation-gns3-csr1000v-wizard-3
network-automation-gns3-csr1000v-wizard-4

If you have already copied the (.qcow2) image file to the default images folder of GNS3 App (C:\Users\Gulraiz\GNS3\images\IOS), then this step will automatically pick up the file locally and ready to install.

network-automation-gns3-csr1000v-wizard-5

The image file is getting uploaded to GNS3.

network-automation-gns3-csr1000v-wizard-6
network-automation-gns3-csr1000v-wizard-7

After successful installation of the appliance, you can see the Cisco CSR1000v template in your GNS3, which is ready to use by dragging and dropping it in the project area.

You can open its console for the initial configuration as shown below:

network-automation-gns3-csr1000v-wizard-10

After completion of some initial configurations, your CSR1000v Router is ready to be configured.

network-automation-gns3-csr1000v-wizard-10

Adding Other Remaining Appliances

We have already seen different methods of installing virtual appliances to GNS3, you can install the remaining appliances by using one of the methods defined in previous sections.

Connecting GNS3 to Home Network

Adding Virtual Network Interface to GNS3 VM

First of all, we need to add a Virtual Network Bridge Interface to GNS3 VM. Go to Settings of GNS3 VM.

network-automation-gns3-physical-network-connection-1

Click the Add button to open Add Hardware Wizard.

network-automation-gns3-physical-network-connection-2

Select Network Adapter and click the Finish button.

network-automation-gns3-physical-network-connection-3

When you click the Finish button, you will see three Network Adapters: Network Adapter (default), Network Adapter 2 (default), and Network Adapter 3 (new).

Select Network Adapter 3, and click on the Bridged option in Network Connection Section. As a result, we have three Network Adapters, for NAT, Host-only, and Bridged connection types respectively.

Please note that the sequence of Network Interfaces matters for configuration purposes.

network-automation-gns3-physical-network-connection-4

Setting up Demo Lab on GNS3

Now we need to set up a demo lab on the GNS3 app to test connectivity between the physical network and GNS3 appliances. In this example, we have a virtual appliance (c7200 Router) and Cloud Appliance which acts as a physical network.

network-automation-gns3-physical-network-connection-5

Configuring Cloud

Righ-click the Cloud1 and click configure.

You will find the three interfaces eth0, etho1, and etho2 that represent the three adapters of GNS3 VM Network Adapter (NAT), Network Adapter 2 (Host-only), and Network Adapter 3 (Bridged) respectively.

In this example, we will select the eth2 interface which means bridge connection between physical network and GNS3. Bridged mode replicates another node on the physical network and your VM will receive its own IP address if DHCP is enabled in the network.

If you connect the Physical Network to GNS3 Appliances through Wi-Fi Interface, it may not work properly. It is highly recommended to use Wired Ethernet or Loopback interface only for this purpose.

Configuring Router

Now open the router’s console and configure inter f0/0 to get an IP address through DHCP.

Below are the commands to set interface f0/0 for DHCP.

R1#configure terminal
R1(config)#interface f0/0
R1(config-if)#no shut
R1(config-if)#ip address dhcp
R1(config-if)do show ip interface brief
R1(config-if)#end

You can see DHCP has assigned 192.168.10.43/24 to interface f0/0. The network address is 192.168.10.0/24 which is the same as Home Network Address.

To verify, open Command Prompt and issue a command “ipconfig“, you can see the network address of the IP address assigned to f0/0 is the same as the Home Network which is 192.168.10.0/24.

You can see that PING is also successful from my home network to the Router interface.

Configuring SSH on Router

Now let me show you SSH using Putty from Windows.

Please note that you need to do some additional configuration to the router to enable SSH access. The configuration is as follows

Router>enable
Router#configure terminal
Router(config-line)#line vty 0 4
Router(config-line)#login local
Router(config-line)#transport input ssh
Router(config-line)#exit
Router(config)#username admin privilage 15 password cisco
Router(config)#cyrpto key generate rsa modulus 1024
Router(config)#end

Opening SSH Session to Router

By using PuTTy client software, you can create SSH Session to access Router CLI from your home network.

Open PuTTy, provide IP Address of Router’s Interface i.e 192.168.10.43.

Click the Open button, you will be prompted to save the Router RSA Key to PuTTy cache. You can click Yes if you do not want this prompt to pop up again when you create a session with the router.

Finally, you have access to Router’s CLI using the PuTTy client.

Troubleshooting GNS3 VM

Sometimes working with GNS3 becomes a matter of great patience when GNS3 VM does not work properly. In this section, we will try to find out possible reasons that may cause GNS3 not to work properly and we will discuss the possible solutions. The most common problem is that GNS3 is not booting up and it is greyed-out as shown below.

Same version of GNS3 and GNS3 VM/Server

There must be the same version of GNS3 and GNS3 VM/Server.

VMware Workstation vs Workstation Player

It is observed that GNS3 sometimes does not properly work with VMplayer. It is recommended to use VMware Workstation Pro to avoid any problem of interfacing GNS3 and GNS3 VM.

VMware Virtual Network Editor

We need to make sure that Virtual Network Interface in VMware is bridged to the correct Network Interface. For example, we can see below that we have a Network Controller name Realtek PCIe GbE Family Controller.

To verify that the correct Network Interface is bridged in VMware, you need to open VMware Workstation and click the Edit > Virtual Network Editor > Change Setting button.

Now select the Bridged Interface and you can see that the bridged interface is the same as Correct Network Interface i.e Realtek PCIe GbE Family Controller.

Toggling Status VMware Virtual Adapters

VMnet1 and VMnet8 are virtual adapters that are installed automatically with VMware Workstation Pro. Sometimes disabling/enabling them fixes the problem of GNS3 VM working properly.

Right-click both interface one by one and disable them. Then enabling them again might resolve the issue.

Antivirus/Firewall Blocking

Make sure that any anti-virus and firewall is not blocking the connection between VMware and GNS3.

Windows Update

If you are using Windows 10/11, make sure it is up to date.

Gulraeez Gulshan
Gulraeez Gulshan
I am an engineer, programmer, tech-savvy professional, and very passionate about the latest technologies for the modern web, mobile, cloud-native, machine learning, and network automation. I have a bachelor's degree in Electronics Engineering and a Master's degree in Computer Science and Information Technology from a renowned university in Pakistan. I have not limited myself to a certain set of skills in this era where technology is in a state of flux; I have experience working with an extensive range of technologies and learning daily to update my skills and adapt to the latest technologies

Related Articles

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles