Mass config changes

From Internetworkpro

Jump to: navigation, search

This simple command line uses rancid's clogin to connect to every device listed as "up" and type "cisco" in the router.db file and invokes the commands specified inside of the clogin '-c' argument:

clogin -c 'conf t; change #1; change #2; end; wr mem' $(find /var/lib/rancid -maxdepth 2 -name router.db -exec awk -F: '$3 == "up" && $2 == "cisco" && $1 !~ /^#/ {print $1}' {} +)

If the change has lots of lines, write them into a textfile. Instead of the '-c' arg, use

clogin -x <textfile_with_commands>

For changes that require interaction (prompts, for example), you can specify the conent of an expect file and use this with the '-s' arg. Take a look at the sample scripts that come with rancid ($rancid_src/lib).

Of course, the find command above can be modified to fit your needs, like using a for loop to cycle through all devices in a subnet etc.

Personal tools