Réseaux

Python learning for Network Engineers | Part 17 |Netmiko introduction for Cisco SSH configuration



𝗙𝗼𝗿 𝗖𝗼𝗺𝗽𝗹𝗲𝘁𝗲 𝗣𝘆𝘁𝗵𝗼𝗻 𝗙𝗼𝗿 𝗡𝗲𝘁𝘄𝗼𝗿𝗸 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝘀 𝗖𝗼𝘂𝗿𝘀𝗲:
𝗘𝗻𝗿𝗼𝗹𝗹 𝗳𝗼𝗿 𝗯𝗲𝗹𝗼𝘄 𝗨𝗱𝗲𝗺𝘆 𝗖𝗹𝗮𝘀𝘀: 𝟐𝟎𝟐𝟐 𝐕𝐞𝐫𝐬𝐢𝐨𝐧
𝑫𝒊𝒔𝒄𝒐𝒖𝒏𝒕𝒆𝒅 𝑹𝒆𝒇𝒆𝒓𝒓𝒂𝒍 𝑳𝒊𝒏𝒌:
https://www.udemy.com/course/python-for-network-engineers/?referralCode=35A75AAE1ACA94A15829 Python Series Complete video Playlist URL :https://www.youtube.com/watch?v=sG_RiytUA38&list=PLOocymQm7YWakdZkBfCRIC06fv7xQE85N
To stay updated with my latest videos Please subscribe to my channel by clicking below
https://www.youtube.com/channel/UCcA2nhdC0wzqyv9x1lk5NnA?sub_confirmation=1

Introduction to Netmiko.
Simplifies SSH to the networking device
Simplifies execution of show command as well as configuration in to the device

textfsm:can extract the date from output and give it in a structured way.
Installation Command:
pip install netmiko

Netmiko commonly-used methods:
net_connect.send_command() – Send command down the channel, return output back (pattern based)
net_connect.send_command_timing() – Send command down the channel, return output back (timing based)
net_connect.send_config_set() – Send configuration commands to remote device
net_connect.send_config_from_file() – Send configuration commands loaded from a file
net_connect.save_config() – Save the running-config to the startup-config
net_connect.enable() – Enter enable mode

need to import the ConnectHandler function from Netmiko.
then define a network device dictionary which contains device_type, ip, username, and password.
verbose in for detailed logging.
Dictionaries:
will have mapping between key and value
Order is not mandatory here
Script sample:

from netmiko import ConnectHandler
from getpass import getpass
password = getpass()
RTR_10 = {
‘ip’: ‘10.10.10.10’,
‘username’: ‘admin’,
‘password’: ‘admin’,
‘device_type’: ‘cisco_ios’,
}

net_connect = ConnectHandler(**RTR_10)

config_commands = [ ‘int lo0’,
‘ip add 1.1.1.1 255.255.255.0’,
‘no shut’ ]
output = net_connect.send_config_set(config_commands)
print(output)

output = net_connect.send_command(‘show ip int brief’)
print(output)
#NetmikoCiscoSSH
#CiscoPythonConfiguration
#NetmikoCiscoConfiguration

Views : 5232
network engineer

Source by NetworkEvolution

Mourad ELGORMA

Fondateur de summarynetworks, passionné des nouvelles technologies et des métiers de Réseautique , Master en réseaux et système de télécommunications. ,j’ai affaire à Pascal, Delphi, Java, MATLAB, php …Connaissance du protocole TCP / IP, des applications Ethernet, des WLAN …Planification, installation et dépannage de problèmes de réseau informatique……Installez, configurez et dépannez les périphériques Cisco IOS. Surveillez les performances du réseau et isolez les défaillances du réseau. VLANs, protocoles de routage (RIPv2, EIGRP, OSPF.)…..Manipuler des systèmes embarqués (matériel et logiciel ex: Beaglebone Black)…Linux (Ubuntu, kali, serveur Mandriva Fedora, …). Microsoft (Windows, Windows Server 2003). ……Paquet tracer, GNS3, VMware Workstation, Virtual Box, Filezilla (client / serveur), EasyPhp, serveur Wamp,Le système de gestion WORDPRESS………Installation des caméras de surveillance ( technologie hikvision DVR………..). ,

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *