Generating Large Numbers of Router Configurations:
You need to generate hundreds of router configuration files for a big network rollout.
When building a large WAN, you will usually configure the remote branch routers similarly, according to a template. This is a good basic design principle, but it also makes it relatively easy to create the router configuration files,The Perl script in Example 1-1 merges a CSV file containing basic router information with a standard template file. It takes the CSV file as input on STDIN.
Example 1-1. create-configs.pl
This Perl script is a simplified version of much larger scripts that we have used to create the configuration files for some very large networks. We then loaded these configuration files into the routers and shipped them to the remote locations, along with a hard copy of the configuration, in case there were problems during shipment. The technician doing the router installation could then simply connect the appropriate cables and power on the router, and never need to even connect to the router’s console unless there were unexpected problems. This methodology can save hundreds of hours in a network installation project.
The script does a relatively simple merge function. It expects the input data in CSV format on STDIN. So if the input file is named RTR-DATA.CSV, you would run the script as follows:
The input file in this case might look something like this:
Using a CSV file like this is convenient because you can keep track of the entire network in a spreadsheet, and then just create a CSV file containing the data you need for the router configurations.
The template configuration needs to include unique variable names that the script will replace with values from the CSV file. For example, the template configuration file might look like this:
The script expects to find this template file located in the current directory with the name rtr-template.txt by default, but you can change it easily by modifying the variable called template_file_name.
Naturally, your router templates will not look like this one, and your CSV file will almost certainly contain other data that is important to your network. So we expect that this script will need significant local modification every time you use it on a new network. But the amount of time required to modify the script is usually far less than the amount of time needed to create all of the configuration files by hand.
The output of this script will be a series of files whose names are the same as the router names, but with .txt added to the end. You can then use a terminal emulator to cut and paste the router configuration files into the routers prior to shipping them to their destinations. Always remember to save the configuration to the router’s NVRAM before powering it off: