Learn how to build your GNS3 network.
- [Instructor] GNS3 makes this process very easy. One of the best devices to use in GNS3 is the Network Automation Container. If you don't have this device as an installed device, look under Available Devices in GNS3 and drag the Network Automation Container to your workspace to install it in GNS3. In my example, I already have the Network Automation Container installed, so I'm gonna drag it to the GNS3 workspace.
What I'll do is drag an ethernet switch to the GNS3 workspace and run that on the GNS3 VM. In my example, I'm running all the devices on the GNS3 VM. The Network Automation Container boots up very quickly, so I wanna have the ethernet switch in the topology which will allow the Docker container to get an IP address from the NAT Cloud and also have internet connectivity.
The devices I'm going to automate, however, are Cisco Viral, IOSv-Layer2 switches and Cisco IOSv routers. Cisco Viral Images are recommended for use in GNS3. You could use other devices but please note that you may encounter issues when using Dynamite's Images.
So, in this example, I'm going to use Viral Images and a Network Automation Container. Now, in this video, I'm going to build the topology from scratch. You don't have to do that if you don't wanna. You can download the pre-configured topology that I've shared, so rather than building the topology, you can simply download it and import it into GNS3. I'm gonna connect the Ethernetswitch to the NAT Cloud.
Connect the GNS3 ether switch to the IOSv-Layer2 switch and connect the switch to the router. So, we'll start off with a simple topology. I'll change the switch name to switch one, router name to router one. Very basic topology to start with. But we'll expand this topology and make it more complex as we go through the course.
But initially I wanna get you started automating as quickly as possible. You can make the topology look pretty. I'm not worried too much about that. I simply wanna get started. So, I'll start up the network devices and open up consoles to them. As you can see here, the IOSv-Layer2 switch is booting and so is the IOSv router, the Network Automation Container has already booted up.
Ifconfig shows us that the Network Automation Container only has an IP version six address. It doesn't have an IP version four address. We not going to manage the Ethernetswitch through the console. What I'm gonna do initially, however, is configure the Network Automation Container to use DHCP. So, cat /etc/network/interfaces shows us that these lines have been commented out, so I'm gonna use nano /etc/network/interfaces and I'm going to uncomment these two lines and press control X and Y to save the file and I'm gonna overwrite the file.
So again, I've used Nano, a simple text editor to uncomment these two lines and I've saved the file. Now, in the pre-built topology that I've given you, that's already been done for you, so you can simply import the topology and that configuration would have already been completed for you. I'm gonna stop the Network Automation Container and start it up again and open up a console to the Network Automation Container.
As you can see here, it's obtained an IP address, so ifconfig shows us the IP address of the Network Automation Container. The NAT Cloud runs a DHCP server and has allocated an IP address to the Network Automation Container. You don't have to use the NAT Cloud if you don't want to, you could configure your Cisco router as a DHCP server but to keep things simple and to get started I've used the Nat Cloud as the DHCP server.
The NAT Cloud also gives us internet access, so I can use commands such as apt-get update to update references on the Network Automation Container. And I can also ping sites on the internet. So, I would recommend the use of the NAT Cloud and the Network Automation Container in GNS3. One of the reasons for using the Network Automation Container is that it comes pre-installed with both Python version 2.7 as well as Python 3, in this case Python 3.5.
You could install a later release of Python if you want to but for our examples, Python 3.5 suffices, in other words, it's good enough but if you wanna install a later release of Python, such as 3.6 or later, you can do that but for our examples, Python 3.5 is good enough. So again, I could run Python version 3 and print something such as Network Automation or Hello World within the Network Automation Container.
I could do something such as X equals one, Y equals two, X plus Y equals three but that's not really the focus of this course. The focus on this course is network automation. So, in Google I'm gonna do a search for Python 3 Telnet. My first hit in Google is the Telnet Library on the python.org website and this gives us details of the Telnet Library available in Python.
I'm gonna scroll to the end of the page. At the end of the page, we find this example Python script. I'm gonna copy that and I'm gonna open up a text editor. In this case, I'm using Sublime Text and I'm gonna paste that script into Sublime Text. Now, when it comes to Python IDEs, there are many integrated development environments available for Python.
One of the most popular is PyCharm. You can download a free version of PyCharm and use that to edit your scripts. In these examples, I'm going to be creating scripts such as my first Python 3 script directly on the Network Automation Container. However, using Nano for editing scripts isn't very easy, so you may prefer to use an IDE such as PyCharm, or Sublime Text for doing your editing.
So, what I'm gonna be doing in a lot of examples is editing the script and creating the script in Sublime Text and then I'm gonna copy it into GNS3. Again, it's up to you. PyCharm is very popular, Sublime Text is very popular, Microsoft Studio Code is another integrated development environment that you may prefer if you used to using Microsoft products, so it's really up to you.
You could use PyCharm, Sublime Text, Virtual Studio, or you could simply search in Google for Python IDE and use one of the other IDEs that are freely available on the internet. In a lot of cases, you get free and paid versions of IDEs. I suggest that initially you get the free version of an IDE such as PyCharm and use that and once you get better at Python, you can invest in a paid version of an IDE but start out by using something that's free.