Browse DevX
Sign up for e-mail newsletters from DevX


Build a Custom Cisco Configuration Repository : Page 6

You don't have to spend a fortune on CiscoWorks to store and compare your Cisco router configurations. With a little work and some help from Subversion, you can roll your own.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Configuring the Initial Repository
You need to upload some files into the repository for it to actually work. To do that, go to /tmp and check out the configurations.

conrad@gonzo:~> cd /tmp conrad@gonzo:/tmp> svn co http://localhost/depot/routers Checked out revision 6.

Now, run the snmp-conf.pl script on each of your routers:

/usr/local/bin/snmp-conf --t <router ip> -o /tmp/routers

This will populate the repository with basic files. You'll also need to run the following command on each of your routers:

conrad@gonzo:/tmp/routers> svn add A

After adding them all, you'll need to run an update and then a commit:

conrad@gonzo:/tmp/routers> svn update At revision 6. conrad@gonzo:/tmp/routers> svn commit Adding Transmitting file data . Committed revision 7.

You need to check out the configurations again for things to work properly:

conrad@gonzo:/tmp> svn co http://localhost/depot/routers Checked out revision 7.

Testing Everything Out
If you configured your repository to be updated via cron-based updates, run the /usr/local/bin/router-cron.sh script now. It should automatically update your repository. Then, skip the next paragraph to view your results.

If you configured your repository to be updated from SNMP trap triggers, there are a few more steps. You need to restart snmptrapd to use snmptt. Kill snmptrapd if it's running, and re-start it using the command snmptrapd—On. Go to one of the routers you've configured, and make a basic configuration change. For example, you can simply change the hostname.

SomeRouter(config)# hostname AnotherRouter AnotherRouter(config)# exit AnotherRouter# wr

Now, you should be able to go to http:///viewcvs, and view the configuration that was just changed, and see what changed about it. If your updates were configured via cron jobs, you are finished! Otherwise, there are just a few more steps that need to happen.

Finishing Up
Subversion needs to have the configurations checked out for updates to happen properly, so you need to set them up so they're always in the checked-out state.

Create the following script as /usr/local/bin/router-maint.sh, and run chmod 755 /usr/local/bin/router-maint.sh to make it executable.

#!/bin/sh # set these for your environment SVN=/usr/local/bin/svn NOW=`date` cd /tmp/routers; $SVN update # commit any current changes # this will throw an error the first time it is run # You can safely ignore the error. cd /tmp/routers; $SVN commit --message "Auto update on $NOW" # check out the configs cd /tmp; $SVN co http://gonzo.timconrad.org/depot/routers

Create a nightly cron job to do any missed updates and check out a new revision of the repository:

0 0 * * * /usr/local/bin/router-maint.sh

When I initially set up a configuration repository, I did it primarily for disaster recovery purposes. Over time, I've found that it's also very useful when I quickly need to look at a configuration for a given network device, or I'm curious as to what's changed on the router over a certain amount of time. One extension to this that would be helpful in environments with multiple network administrators, would be the capability to keep track of which user makes which change to the devices, however, that would take some additional development. Hopefully, you'll find the configuration repository as useful as I have!

Tim Conrad lives and works in New York City, where he supports the network infrastructure at an educational services company. In his spare time he likes to go to concerts, drink beer, play guitar, and spend quality time with his computers.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date