Adding a Linux Instance in GNS3 and connect it to the internet through a Cisco Router instance

Sometimes we want to test scripts for Network Automation in GNS3. We usually run our scripts in Linux based machines. This Linux machine can be either our GNS3 host, a remote machine, or a Linux instance within the GNS3 topology. In this post we show the steps to create a Linux instance in GNS3 that can interact with our virtual routers, switches and other appliances in our virtual topology. To use a Linux machine with to run scripts we usually need to install some packages that are downloaded to the machine from he internet. In this post we discuss the steps to add a Linux instance into the GNS3 topology and connect it to the internet.

1.- On GNS3 Create your Cisco routers, switches and others.

2.- Install Ubuntu Docker Guest image in GNS3:

2.1- Go to https://gns3.com/marketplace/appliances and look for Ubuntu Docker Guest and download it.



2.2- On GNS3, go to File>Import Appliance and import the appliance you just downloaded by going through the wizard.

3.- Drop the Ubuntu Docker Guest instance into a GNS3 project together with a Router (switch is optional), and connect a Cloud object to the router as in the figure:

4.- Provide internet connectivity to the Docker instance by doing the following:

4.1 -On the router configure interface G0/3 for DHCP and G0/0 with a static ip address:

config t
interface g0/3
 ip address dhcp 
 no shut
interface g0/0
ip address 10.0.0.1 255.255.255.0
no shut



4.2- On the same router, configure NAT

config t
interface g0/3
ip nat outside
interface g0/0
ip nat inside
access-list 1 permit 10.0.0.0 0.255.255.255
ip nat inside source list 1 interface g0/3 overload

5.- Configure the linux instance with an ip address, default gateway and DNS server:

ifconfig eth0 10.0.0.2 netmask 255.255.255.0 up
route add default gw 10.0.0.1
echo "nameserver 1.1.1.1" > /etc/resolv.con



You can also do this by right-clicking the instance icon, then “Configure”, and on the General Settings tab > Network Configuration click the Edit button, and edit the text as follows:

6.- Test reachability:

root@UbuntuDockerGuest-1:~# ping google.com

Now your Linux virtual machine has internet access.