Join David Bombal for an in-depth discussion in this video GNS3 lab setup and IDEs, part of Network Automation Quick Start.
- [Instructor] GNS3 makes this process very easy. One of the best devices to use in GNS3 is the NetworkAutomation container. If you don't have this device as an installed device, look under Available Devices in GNS3 and drag the NetworkAutomation container to your workspace to install it in GNS3. In my example, I already have the NetworkAutomation container installed, so I'm gonna drag it to the GNS3 workspace.
What I'll also 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 NetworkAutomation 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 Layer Two Switches and CiscoIOSv 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 Dynamips images.
So, in this example, I'm going to a Viral Images and a NetworkAutomation 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 want to, 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 Layer Two switch and connect the switch to the router.
So, we'll start off with a simply 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 layer two switch is booting and so is the IOSv router, the NetworkAutomation container has already booted up. Ifconfig shows us that the NetworkAutomation 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 NetworkAutomation 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 NetworkAutomation container and start it up again and open up a console to the NetworkAutomation container.
As you can see here, it's obtained an IP address, so ifconfig shows us the IP address of the NetworkAutomation container. The NAT Cloud runs a DHCP server and has allocated an IP address to the NetworkAutomation 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 NetworkAutomation container. And I can also ping sites on the internet. So, I would recommend the use of the NAT Cloud and the NetworkAutomation container in GNS3. One of the reasons for using the NetworkAutomation 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 NetworkAutomation container.
I could so 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 of 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 NetworkAutomation 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, Visual Code 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 version 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.