Configure multiple Cisco IOS devices with Netmiko

Related Posts:
- https://rfc-1925.com/setting-up-ssh-on-a-cisco-switch/
- https://rfc-1925.com/how-to-install-netmiko-paramiko-in-windows-10-using-pip/
- https://rfc-1925.com/netmiko-ssh-script-to-cisco-3750-switch/
Copy pasta script and save as config.py:
from netmiko import ConnectHandler
c3750_s1 = {
'device_type': 'cisco_ios',
'ip': '10.0.10.24',
'username': 'lab',
'password': 'lab'
}
c3750_s2 = {
'device_type': 'cisco_ios',
'ip': '10.0.10.25',
'username': 'lab',
'password': 'lab'
}
c3750_s3 = {
'device_type': 'cisco_ios',
'ip': '10.0.10.26',
'username': 'lab',
'password': 'lab'
}
all_devices = [c3750_s1, c3750_s2, c3750_s3]
for devices in all_devices:
net_connect = ConnectHandler(**devices)
for n in range (2,21):
print ("Creating VLAN " + str(n))
config_commands = ['vlan ' + str(n), 'name Python_VLAN' + str(n)]
output = net_connect.send_config_set(config_commands)
print (output)
Execute the script and then check the devices for configuration changes.
Leave a Reply