After spending a bit of time looking around, I could not find a tool to do this so I went to work using Python and came up with a basic prototype in a couple of hours. The script doesn't actually do the plotting and layout but rather produces a DOT file leaves the heavy lifting to GraphViz. With a little extra work I have now produced a working script which takes the output of "show ip ospf database router" and produces a DOT file which can be used to plot a topology map showing each OSPF router complete with the links between (including metrics) and any transit multi-access networks.
CLI output from Cisco IOS and Cisco ASA is supported (the output seems to be essentially the same) and, obviously, it doesn't matter what vendors' kit is attached into the network, provided you run the "show ip ospf database router" on a supported platform.
The tool, not-so-snappily named "ospfcli2dot" is available from my github: https://github.com/theclam/ospfcli2dot
Example
Here's a simple example of a 4 router setup. R1, R2 and R3 all sit on a shared LAN, while R4 is attached point to point to R3 and R5:
The "show ip ospf database router" command can be run from any device in the network since all devices within an area share the same topology database. The output of this is quite verbose so will not be shown here. For the purposes of this example, I have just copied and pasted the output into a file called cli-output.txt.
Simply run the script against that file:
foeh@feeble ~/Projects/ospfcli2dot $ ./ospfcli2dot
ospfcli2dot - takes the output of "show ip ospf database router" and outputs a GraphViz DOT file corresponding to the network topology
v0.2 alpha, By Foeh Mannay, April 2016
Enter input filename: cli-output.txt
Enter output filename: example.dot
foeh@feeble ~/Projects/ospfcli2dot $ dot -Tgif -oexample.gif example.dot
This creates "example.gif", shown below:
As you can see, the metric is shown against each link and the script has automatically highlighted in red that one of the point to point links has different metrics in each direction.
Please give it a try and let me know how you get on!
Links
Download: https://github.com/theclam/ospfcli2dot
I spotted a misconfiguration on a large Area thanks to this :)
ReplyDeleteGreat!
ReplyDeleteHi i got respond like this using python3
ReplyDeleteroot@Anak17thn:/home/anak17thn/ospfcli2dot-master# python3 ospfcli2dot.py tess.dot
ospfcli2dot - takes the output of "show ip ospf database router" and optionally a hostfile
outputs a GraphViz DOT file corresponding to the network topology
v0.3 alpha, By Foeh Mannay, December 2017
Enter input filename: JKTTBSRC12_router.txt
Enter hostnames file or press enter to continue without one: JKTTBSRC12_router.txt
If you want to group by hostname, enter the separator now
(or press enter to continue):
Enter output filename: tessss.dot
Traceback (most recent call last):
File "ospfcli2dot.py", line 233, in
if(areas):
NameError: name 'areas' is not defined
root@Anak17thn:/home/anak17thn/ospfcli2dot-master#
.
DeleteHi,
DeleteYour host name file should be different to your topology file. Try just leaving it blank.
Foeh
It's working... Genius ...
ReplyDeleteGlad you got some use out of it - thanks for the feedback!
DeleteHey Foeh I love your code and it's amazing. Thanks a bunch.
ReplyDelete