https://dashiels.net

Creating Scripts on Python for Network Automation

WHEN IT COMES TO CONFIGURING DEVICES ON A NETWORK, IT IS MORE EFFICIENT TO CREATE A SCRIPT TO CONFIGURE ALL THE DEVICES THAN TO CONFIGURE EACH DEVICE ONE BY ONE.

I was introduced to network automation by David Bombal, a well-known networking instructor. I have been experimenting with a tool called Netmiko and have also practiced a little with Ansible. Both of these tools allow for routers and switches to be configured or to pull configuration information at the same time. Sometimes I run into errors in my code but with persistance I will find the answer. In this lab, I also decided to use the community version of EVE-NG, another network emulation software, to get more experience with its usage.In this lab, I created a fairly simple topology. Two access layer switches, two distribution/core layer switches, and two edge routers are what make the topology. And my goal here was to create a script using netmiko to SSH into each device and configure each device according to its function in the topology (i.e. access layer switches configured with access switchports). The lab is still in the works since I have been running into a timeout issue in the code. But at the time of this writing and after much research, I believe I have found the solution and can resume working on this lab.

Feels Good to Solve Problems

After much time trying to find a timeout problem, I finally found a solution thanks to a guy called IPvZero I found on YouTube. He has GitHub with the code that I needed. I integrated his code into mine and was finally able to SSH into the devices. This time I decided to redo the lab in GNS3 since I have more experience with it and can configure things faster. Many thanks to IPvZero.

PyCharm

I find PyCharm very useful from other IDE's. This is the new and improved code that I came up with. I just need to clean it up and keep working with bugs.

Using Nornir to Configure Interfaces

In this lab, I used a powerful tool called Nornir on Python to configure the IP addresses of the router interfaces by reading them from CSV (comma-seperated values) file. I am still working to configure the rest of the devices with MPLS.