It is for sure a tedious task but using TCL, it will pretty much make your life easier. I have researched for a way to automate the config preparation provided you have all the necessary data required. I am not a programmer but somehow I managed to find some TCL software and commands to make this possible. Before we begin we would need to have TCLKIT which can be downloaded here.
Now for this example, let us only try to create configs for 10 routers. Our standard config is as shown below. (not so long so make things easier)
hostname (hostname)
!
interface Serial1/1
ip address (ip address)(mask)
!
router ospf 1
network(network) (wildcard) area (ospf area)
The first step is to create our variables, quite much work required for this especially for long standard configs. We will create variables for those with () in the standard config above. These are the parts in the configuration wherein the data will be placed. Standard configuration with variables shown below.
hostname $hostname
!
interface Serial1/1
ip address $ipaddress $ipmask
!
router ospf 1
network $network $wildcard area $ospfarea
Now we have created our variables. Let us use the multivariable "foreach" TCL command to create a looping script. We put in our variables next to the "foreach" statement. The "$" is not required. If you are not familiar with this, please visit this post.
foreach {hostname ipaddress ipmask network wildcard ospfarea}
The next line of this script will now contain the data. Prepare the data in excel spreadsheet and the sequence of the columns should be the same as the one listed in the "foreach" statement. Then add that to the second line of the script. Put an open { before the data and } after the data.
Add also the important commands below that will make auto text file generation for each config file. The final script will look like something below. Then save this as a text file.
foreach {hostname ipaddress ipmask network wildcard ospfarea} {
Router1 1.1.1.1 255.255.255.0 1.1.1.1 0.0.0.0 1
Router2 1.1.1.2 255.255.255.0 1.1.1.2 0.0.0.0 2
Router3 1.1.1.3 255.255.255.0 1.1.1.3 0.0.0.0 3
Router4 1.1.1.4 255.255.255.0 1.1.1.4 0.0.0.0 4
Router5 1.1.1.5 255.255.255.0 1.1.1.5 0.0.0.0 5
Router6 1.1.1.6 255.255.255.0 1.1.1.6 0.0.0.0 6
Router7 1.1.1.7 255.255.255.0 1.1.1.7 0.0.0.0 7
Router8 1.1.1.8 255.255.255.0 1.1.1.8 0.0.0.0 8
Router9 1.1.1.9 255.255.255.0 1.1.1.9 0.0.0.0 9
Router10 1.1.1.10 255.255.255.0 1.1.1.10 0.0.0.0 10
} {set data "
hostname $hostname
!
interface Serial1/1
ip address $ipaddress $ipmask
!
router ospf 1
network $network $wildcard area $ospfarea
"
set filename "${hostname}.txt"
set fileId [open $filename "w"]
puts -nonewline $fileId $data
close $fileId
}
Now its time to auto generate the configs. What this looping script does is take the first line on the data, do the variable substitution and then at the end it will save the text file with the hostname as the filename. It does this until the last line of the data. The files will be auto generated where the TCLKIT software is saved.
Open TCLKIT, two windows will appear big and small. Click on File -> Source ->Go to the directory where you saved the script as text file -> Change "Files of Type to "All Files" -> Select the Script. Then viola, your configurations appear and all variables substituted. It makes life easier for a network engineer.
very informative! Can you mention some other similar tools which you might have stumbled upon.
very well written article,Thx.Pls share more scripts of this kind.Is there any graphical way to do the similar task ? what is your opinion abt perl ?
Hello, What is your contact?
Livin4jc@gmail.com why?
This is cool my fried
I have read your blog since 2010. Actually you are my teacher. I learned a lot from your blog. Really really thanks and I really respect and appreciate your work. I respected you since 2010.You are my fan since 2010.:)
tcl is usefull for made easy dor this
Thanks for sharing this informative information. I really liked this blog post.Network configuration is really very hard for a big organization only a ccna, ccnp, ccie certified person can handle this. because they have vast experience of working on Network devices and know how they have to configure them.
____________
CCIE Service Provider
That really is the solution to the problem. Thanks for your thoughts. Cisco Training