Learn how to automate the configuration of network devices with NAPALM, a Python library used to automate and interact with network devices and OSs using a unified API.
- [Tutor] So NAPALM is used for network automation but provides an abstraction layer making it easy to configure multiple vendor devices. This software is available on GitHub. And I'm gonna show you in a moment how to install it in a GNS3 topology. Many network devices are supported and you can see a list on this link. As an example, Arista EOS, Juniper, CiscoIOS XR, Cisco Nexus, CiscoIOS as well as other vendors.
This software makes it really easy within python to configure devices either by merging configurations, replacing configurations, comparing configurations and if necessary rolling back configurations. The software makes it easy for you as the network engineer to write a simple python scripts that are very powerful. So as an example you can use the get_bgp_neigbors function in your python code and the same results will be returned whether you are connecting to a CiscoIOS device, IOS XR device, JunOS device, Nexus device, Arista device and other devices that are supported.
A list of supported vendors are shown in this table for the relevant commands. Am gonna demonstrate this in a moment but once again you could get the ARP table. From multiple vendors or get the device configurations or get environmental information. Or get facts about the device or interfaces or interface counters or layer three IP addresses LLTP neighbors, MAC address table information NTP information, VRFs, in NPRs environments.
You can even sent Pings from devices or Trace Routes from those devices and collect the responses. So NAPALM is really powerful. Because it abstracts you from a low level programming. The idea with abstraction is high to complexity. As an example when you drive you motor vehicle you might turn the key or press a button to start the car. (engine roars) But there is a lot of hidden things happening to make the car start.
(engine roars) You press the accelerator to go quicker. (engine roars) But a lot of complexity is hidden from you. The car present a simple interface, where you can see your speed as an example, you can see your acceleration, you can turn the steering wheel to turn left or to turn right. A very simple interface is provided for a complex piece of machinery.
The same idea happens here. You are hidden from low level programming interfaces and APIs across multiple vendors and you can use simple commands to retrieve information, from network devices and program the network devices using NAPALM. Now some of network devices have proper APIs. The CiscoIOS doesn't. So the CiscoIOS has no native API that you can use. But that's not gonna stop us.
NAPALM uses Netmiko to interact with network devices. So Netmiko is a prerequisite for using NAPALM with CiscoIOS devices. In this GN3 topology I have got a CiscoIOS layer two switch, and CiscoIOSv router. And am gonna demonstrate how to install and use NAPALM on this Ubuntu server to extract information and configure these IOS devices. A link to the documentation is shown on the GitHub page.
Documentation is available at readthedocs and you will find caveats and prerequisites like this on the documentation pages. So have a look at the NAPALM documentation if you need more information or ask a question and I will do my best to answer it. But now am gonna show you how to install NAPALM and use it to retrieve information from these network devices running in GNS3.
- Connecting to a switch using NAPALM
- Using JSON with NAPALM
- Using NAPALM to retrieve BGP neighbors
- Connecting to multiple BGP routers
- Automating large BGP networks
- Configuring ACLs using NAPALM
- Auditing your device configurations