Using SNMP to Perform Mass Configuration Changes

Problem

You want to automate the distribution of a set of configuration commands to a large number of routers.

Solution

The following Perl script will distribute configuration commands to a large number of routers. It works by using SNMP to trigger TFTP file transfers into the routers. In effect, this script lets you automatically distribute a series configuration commands to a list of routers. Automating routine changes like this saves time and effort, but more importantly, it virtually eliminates typographical mistakes.

Here’s some example output:

Freebsd% ./snmpcfg.pl
=================================== 
toronto - Update Successful
toronto - Wr Mem Successful
=================================== 
boston  - Update Successful
boston  - Wr Mem Successful
=================================== 
denver  - Update Successful
denver  - Wr Mem Successful
=================================== 
newyork - Update Successful
newyork - Wr Mem Successful
=================================== 
detroit - Update Failed
=================================== 
chicago - Update Successful
chicago - Wr Mem Successful
=================================== 
sanfran - Update Successful
sanfran - Wr Mem Successful
=================================== 
seattle - Update Successful
seattle - Wr Mem Successful
===================================
Freebsd%

The Perl code follows in Example 17-3.

Example 17-3. snmpcfg.pl

#!/usr/bin/perl -w # # snmpcfg.pl -- a script to perform mass configuration ...

Get Cisco IOS Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.