I find that sometimes when I want to lab up a specific scenario I have to do the same “router ospf 1234” and “network 198.51.blah.blah area blah” commands over and over just to get basic routing configured. Awhile ago I wrote an EIGRP auto configuration script but at that time I didn’t know about the ipaddress module or how to do any looping in programs. This resulted in about 600 lines of code just to throw commands at a router CLI and a script that can’t handle more than 5 interfaces per device. Not ideal.
With that said, I recently decided to revisit the idea but focus on OSPF. This time I invoked the ipaddress module and primitive looping for much cleaner and scalable code. You can find the code at: github.com/routingloopnet/ospf-autoconfiguation-/blob/main/ospf_autoconf.py. A specific “network” statement is entered for every interface with an ipv4 address. This version supports a practically unlimited number of interfaces per device, OSPF Router ID configuration and multiarea OSPF. Eventually I want to write a second version with passive interface, stub, OSPF priority, network type and a few other options.
If you have any thoughts on this or other features that I should add drop a comment or send me an email.