top of page
  • Writer's pictureAlexander Deca

Network Audit using Python on Cisco devices

Updated: Sep 21, 2023


Sooner or later, you will encounter a network that isn't well-documented (i.e., no diagrams, no existing inventory nor configuration, etc.). The company is looking at you for auditing all network devices to verify recurring issues such as spanning-tree loops in the network, flapping MAC addresses, configuration drift, no stacking where stacking should be performed, daisy-chained switches with multiple interfaces towards the core switch, multiple single interfaces between devices instead of port channels, and whatnot. For those working in the same field, the whole shebang :-)


I thought about ensuring that I did not spend to much time manually logging into each device to map the network and looked at Python to achieve this. Initially, I was looking into just visualizing the network by plotting out the topology based on the "show cdp neighbors output", but I ended up with multiple scripts with their own functions to fetch different network information.


Although the plotted network uses the libraries Networkx and Matplotlib, there are probably several libraries out there that might achieve the same thing. The result was pretty decent (all in all, it contained all the information I needed to create a network topology)


Would I be using the visualization in official documentation? Probably yes however, only for highlighting that the Network topology drawing was created based on the visualization through the Python script.



Image of daisy-chained switches visualized by a python script

I published all scripts on GitHub, and although they are focusing on Cisco IOS-XR, NX-OS, and IOS-XE with minor adjustments, I am pretty sure you could use this for other Network vendors as well.



220 views1 comment
bottom of page