Archive for the 'Cisco IOS' Category
In our day to day work as network administrators it is often necessary to compare configuration files of Cisco routers or switches. As we know, a characteristic of Cisco IOS is that the configuration files are stored in text format, but still a line by line comparison of different config files is tedious and in many cases almost impossible. For this reason it would be useful to present some methods that allow us to perform this comparison task with full automation.
Configuration files comparison using specialized software
One option to help us compare Cisco configuration files is to export the config files in text format and then use a program to perform line by line comparison. The easier way to export a configuration file in text format is to execute the command “show run” or “show startup“, press the “space bar” key several times until the end of the configuration and then copy and paste the lines from the Terminal screen to a text editor.
A free program available on the Internet to compare text files is Compare It 4. It can be downloaded from the official site: http://www.grigsoft.com/wincmp3.htm
Using Cisco IOS Commands
From IOS version 12.3 (4)T, the comparison can be made directly on the IOS command line.
The commands to compare the running configuration from the startup configuration are the following:
Router> enable
Router # show archive config differences system: running-config nvram: startup-config
Contextual Config Diffs:
+ ip dhcp excluded-address 172.16.1.106 172.16.1.254
- ip dhcp excluded-address 172.16.1.160 172.16.1.254
To understand the output above, you need to know the following:
- The plus symbol (+) means that the configuration line exists in the “startup-config” but not in the “running-config”
- The minus symbol (-) means that the configuration line exists in “running-config” but not in “startup-config”.
In our example above, there is a command in backup configuration file (startup-config) that excludes address range 172.16.1.106 up to 172.16.1.254 from the DHCP address pool.
The comparison shows that someone has entered and changed the range of excluded addresses, and replaced it by range 172.16.1.160 to 172.16.1.254 and did not save the changes. That’s why the changes are only present in the active configuration (running-config). The command which is present in the running-config is preceded by the minus (-) symbol.
In our example above, the only difference between the two files are the two excluded-address commands. If there were more differences they would be listed as well. The command only displays the lines of the files in which there are differences.
I hope the post was helpful. If you have any more information or you want to provide additional references on the file comparison feature feel free to comment below.



