Global Router Configuration Tool  (config_devices)

Top  Previous  Next

This program will send any number of configuration commands to a list of Cisco routers.  The commands that are sent are defined in a text file (any name), that you create.  This file MUST NOT include the commands needed to enter and exit configuration mode on the router.  The script will automatically handle that.  The commands are sent in sequential order from top to bottom of the file. 

 

 

Program Name: config_devices

 

Script Argument

Description

-rf <filename>

List of routers or IP Address to run script against (REQUIRED)

-cf <filename>

File which contains a list of configuration commands to send to router.  These MUST BE configuration commands only!!!  One configuration command per line.  Lines that begin with a “#” are considered comments and will not be sent to the router.  (REQUIRED)

-wm

Saves configuration file to NVRAM after making the configuration changes.  This option performs a “write mememory” on the router.  (OPTIONAL)

-safe

Safe Mode.  If an error occurs while sending a configuration command to a router in the list, all subsequent commands to that router will not be sent.  The script will continue on to the next router on the list and continue sending commands.  (OPTIONAL)

-ssafe

SuperSafe Mode.  Abort Script if there is an error while sending any of the configuration commands to any of the routers. (OPTIONAL)

-ssh

Use Secure Shell when accessing routers.  Do NOT use with –pw option. (OPTIONAL)

-pw <filename>

Login/Password File.  (OPTIONAL)

-log <filename>

Save detailed trace file to a name other than the default file name.  (OPTIONAL)

-ulog

Unique Log file.  Save detailed trace log file to a Unique filename automatically created by script. Filename will be in format of scriptname_timestamp.log. (OPTIONAL)

 

The configuration command file (-cf <filename>) should contain a list of configuration commands that will be sent to each router.  This is not a TCL file, it is a plain text file that must contain one command per line.  Lines that begin with a “#” are considered comments and will not be sent to the router as a command.  There is one special command that can be entered into this file that will NOT be sent to the router.  This is the SLEEP <seconds> command (all capitals).  If desired, this is a method to introduce a delay between configuration commands.  Seconds can be a whole integer (e.g. 2) or a real number (e.g. 1.5).  The SLEEP command MUST be entered in all CAPITAL letters otherwise it will be interpreted as a command to send to the router.  Note, this is not typically needed but may be useful if you would like to watch the script as it is running to visually inspect the output of a particular command.

 

By default, the configuration commands will not be saved to NVRAM.  Use the –wm option to save the configuration changes.

 

This program also has the option to be run in Safe and SuperSafe mode which should be considered when running scripts in production environments.  If entering a configuration command results in an error on the router and the script is running in Safe or SuperSafe mode, the config will not be saved to NVRAM even if the –wm option is applied.  If the script is NOT running in Safe or SuperSafe mode, and the –wm option is applied, the config WILL be saved to NVRAM even if there are one or more commands that caused configuration errors.

 

Sample Command: The following command will send the configuration commands listed in file snmp_cmds.cmds to the routers listed in the file rtrs.rt. After the configuration commands are entered, the config will be saved to NVRAM because of the –wm option.  If there are any errors while sending a particular configuration command, the script will abort all remaining commands to that router and continue on to the next router because of the –safe option (SAFE Mode).  The detailed trace-log will be saved to the file snmp_log instead of the default file name of config_devices.log (notice this argument was listed first on the command line).  The script will not prompt the user for passwords because the passwords are being read in from the logins.txt file (-pw option).

 

config_devices –log snmp_log –pw logins.txt –rf rtrs.rt –cf snmp_cmds.cmds –wm –safe