← blog · 2026-08-05
First Useful Netmiko Script: VLAN Audit
A 40-line Python script that saved me an hour of show vlan brief copy-paste.
tags: automation, python, netmiko
Contents
I got tired of SSHing into two switches to compare show vlan brief. You can pull both at once with a small Netmiko loop:
from netmiko import ConnectHandler
devices = [
{"host": "192.168.99.11", "device_type": "cisco_ios", "username": "admin"},
{"host": "192.168.99.12", "device_type": "cisco_ios", "username": "admin"},
]
for d in devices:
conn = ConnectHandler(**d)
print(f"== {d['host']} ==")
print(conn.send_command("show vlan brief"))
Notes
send_commandblocks. You wait for each device in turn. That works for two switches and it drags for fifty.- Do not hardcode passwords. Use
getpassor env vars. - Pipe the outputs through
diffliband you get an audit you can save and share.
Repo: I will publish the cleaned script to /projects.