Udemy: Get the course for $10 here: https://goo.gl/QYC988
GNS3 Academy: Get the course for $10 here: https://goo.gl/vnZJhg
More free Python videos here: https://www.youtube.com/playlist?list=PLhfrWIlLOoKPn7T9FtvbOWX8GxgsFFNwn
Learn Python programming with GNS3. In this series of videos I will show you how you can quickly and easily program Cisco networks using Python.
================================
Script on GitHub:
================================
https://github.com/davidbombal/pythonvideos/commit/90f349178c9dba5d65a1304c97814505d59be5bb
================================
Install Netmiko:
================================
apt-get update
apt-get install python -y
apt-get install build-essential libssl-dev libffi-dev -y
apt-get install python-pip -y
pip install cryptography
pip install netmiko
================================
Al's GNS3 community entry:
================================
Transcription:
In the previous video I showed you how to use Paramiko to configure a switch using SSH. Paramiko is a Python implementation of the SSH of version 2 protocol and provides both client and server functionality.
Now Netmiko is a multi-vendor library that was developed to simplify Paramiko SSH connections to network devices. This is one of multiple videos teaching you network programmability using Python and GNS3. You can find out more details about the software on github.
But in brief, it's once again a multi vendor library that allows you to connect to network devices using SSH. It supports Python 2.7, 3.4 and 3.5.
It supports a wide range of devices, devices that are tested on a regular basis include Aresta vEOS, Cisco ASA, Cisco IOS, IOS XE. IOS XR, Nexus OS, the Cisco SG300, HP Comware and Aruba or ProCurve software Juniper and Linux. There's been limited testing on devices from Avaya, Brocade, Dell and other vendors.
There's also experimental testing with yet more devices. The idea once again is to simplify SSH connections in multi vendor environments.
Now multiple devices are supported and you can find the list by clicking on this link. As you can see, there's a wide range of devices that are supported using SSH. Now the way you get started is you use from Netmiko import connect handler then you specify a name for your device and you specify the device type. In this example I'm going to be using Cisco IOS.
Here's a list of device types, we have Cisco IOS, Cisco XE, Cisco ASA, Nexus and a long list of devices are listed here but we're going to start off with Cisco IOS.
You then specify the IP address, username and password to connect to the device. You can specify a port number, default is port 22. You can specify a secret default it is not used, verbose is turned off.
You then connect to the device and you can execute commands such as show commands using the net connect send command option. For long-running commands you can use the send command expect which waits for the trailing prompt or for an optional pattern.
So as an example, you could use this for write memory you can enter and exit enable mode. You can change options such as the config of devices. Netmiko will automatically enter configuration mode to make those changes when you specify send config.
I'm going to demonstrate this it's always using GNS3 and here's an example of the code that I'm going to run on an IOSv switch in the GNS3 network.
So here's my Ubuntu client and my IOSvL 2 switch. This is the same topology as I used for the previous video.
In the previous video, I showed you the steps to install Paramiko. The steps are very much the same. I've put them below this video. The one difference is we're going to use pip install Netmiko to install Netmiko. I've already done that. In this example, if you're installing this on a new device here are the steps and I've linked them below so either install Paramiko or Netmiko or both.
So in my example I've got Netmiko installed on the Ubuntu client and I've got SSH pre-configured on the switch.
If you want to see how I set that up, please have a look at the previous video where I discuss Paramiko.
Ok so here are the steps from Netmiko import connect handler we’re specifying a device called IOSv Layer 2 to the device. Type is Cisco IOS. This is the IP address of the switch. Here's the username and the password to login to the switch.
You can support multiple devices by creating codes such as the following. I'll show you that later. We are then going to connect to the IOSv Layer 2 switch and I'm going to send a command sh ip interface brief and print that output.
This shows you an example of a privilege or enable command on a Cisco device, I'm then going to send configuration commands. In this example we'll create a loopback. Loopback 0 and configure this IP address on the loopback 0 interface...
Discounted link to course here: https://goo.gl/ntqu3G
GNS3 Academy: Get the course for $10 here: https://goo.gl/vnZJhg
More free Python videos here: https://www.youtube.com/playlist?list=PLhfrWIlLOoKPn7T9FtvbOWX8GxgsFFNwn
Learn Python programming with GNS3. In this series of videos I will show you how you can quickly and easily program Cisco networks using Python.
================================
Script on GitHub:
================================
https://github.com/davidbombal/pythonvideos/commit/90f349178c9dba5d65a1304c97814505d59be5bb
================================
Install Netmiko:
================================
apt-get update
apt-get install python -y
apt-get install build-essential libssl-dev libffi-dev -y
apt-get install python-pip -y
pip install cryptography
pip install netmiko
================================
Al's GNS3 community entry:
================================
Transcription:
In the previous video I showed you how to use Paramiko to configure a switch using SSH. Paramiko is a Python implementation of the SSH of version 2 protocol and provides both client and server functionality.
Now Netmiko is a multi-vendor library that was developed to simplify Paramiko SSH connections to network devices. This is one of multiple videos teaching you network programmability using Python and GNS3. You can find out more details about the software on github.
But in brief, it's once again a multi vendor library that allows you to connect to network devices using SSH. It supports Python 2.7, 3.4 and 3.5.
It supports a wide range of devices, devices that are tested on a regular basis include Aresta vEOS, Cisco ASA, Cisco IOS, IOS XE. IOS XR, Nexus OS, the Cisco SG300, HP Comware and Aruba or ProCurve software Juniper and Linux. There's been limited testing on devices from Avaya, Brocade, Dell and other vendors.
There's also experimental testing with yet more devices. The idea once again is to simplify SSH connections in multi vendor environments.
Now multiple devices are supported and you can find the list by clicking on this link. As you can see, there's a wide range of devices that are supported using SSH. Now the way you get started is you use from Netmiko import connect handler then you specify a name for your device and you specify the device type. In this example I'm going to be using Cisco IOS.
Here's a list of device types, we have Cisco IOS, Cisco XE, Cisco ASA, Nexus and a long list of devices are listed here but we're going to start off with Cisco IOS.
You then specify the IP address, username and password to connect to the device. You can specify a port number, default is port 22. You can specify a secret default it is not used, verbose is turned off.
You then connect to the device and you can execute commands such as show commands using the net connect send command option. For long-running commands you can use the send command expect which waits for the trailing prompt or for an optional pattern.
So as an example, you could use this for write memory you can enter and exit enable mode. You can change options such as the config of devices. Netmiko will automatically enter configuration mode to make those changes when you specify send config.
I'm going to demonstrate this it's always using GNS3 and here's an example of the code that I'm going to run on an IOSv switch in the GNS3 network.
So here's my Ubuntu client and my IOSvL 2 switch. This is the same topology as I used for the previous video.
In the previous video, I showed you the steps to install Paramiko. The steps are very much the same. I've put them below this video. The one difference is we're going to use pip install Netmiko to install Netmiko. I've already done that. In this example, if you're installing this on a new device here are the steps and I've linked them below so either install Paramiko or Netmiko or both.
So in my example I've got Netmiko installed on the Ubuntu client and I've got SSH pre-configured on the switch.
If you want to see how I set that up, please have a look at the previous video where I discuss Paramiko.
Ok so here are the steps from Netmiko import connect handler we’re specifying a device called IOSv Layer 2 to the device. Type is Cisco IOS. This is the IP address of the switch. Here's the username and the password to login to the switch.
You can support multiple devices by creating codes such as the following. I'll show you that later. We are then going to connect to the IOSv Layer 2 switch and I'm going to send a command sh ip interface brief and print that output.
This shows you an example of a privilege or enable command on a Cisco device, I'm then going to send configuration commands. In this example we'll create a loopback. Loopback 0 and configure this IP address on the loopback 0 interface...
Discounted link to course here: https://goo.gl/ntqu3G
- Category
- Routers and Switches
Be the first to comment