Monday, December 17, 2012

Cisco Configuration Rollback via configure replace

There was always these boring moments when i wanted to reload my lab to a certain point where i configured something, just to try solving a problem in a different approach. at that point i had 3 options,

  1. Negate every command that i need to delete 
  2. Save the configuration ( copy run start ) right to the point that i normally call ( default configuration ) which is the configuration without the testing parameters that i want to test
  3. Save the " default configuration " and issue a write erase, and paste the configuration after the router or switch reload
This was a very time consuming process, specially when you need to test three " BIG " scenarios with complicated parameters, until i found the command from heaven configure replace.

The command works in a very simple manner, it compares the running configuration with the one saved on the flash drive for example, then based on these differences it adds the extra configuration from the configuration saved on the flash to the running configuration and removes the lines that are not present there from the running config. what makes this command very efficient is that you don't need to reload the router/switch to apply a big, like really big configuration.

let's look at this example,

I'm configuring a lab that contains layer 2 and layer 3 configuration ( eventually ! ) and i need to try configuring layer 3 with three different protocols and filters and route-maps etc. 

The easiest way to do this is to configure all the layer 2 parameters then save the configuration to flash 

SW1#copy run flash:layer2-config
Destination filename [layer2-config]?
Verifying checksum...  OK (0x2CC3)
1332 bytes copied in 10.728 secs (124 bytes/sec) 

Check that the file is there

SW1#dir flash:
Directory of flash:/

    1  -rw-        1332                    <no date>  layer2-config

16777212 bytes total (16775816 bytes free)

You can also make sure that this file contains the right configuration 

SW1#more flash:layer2-config
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
hostname SW1
~~~output ommited ~~~

Now, you made come configuration and you want to revert back to the point you saved all your layer 2 config without negating or reloading your box.

SW1#configure replace flash:layer2-config
This will apply all necessary additions and deletions
to replace the current running configuration with the
contents of the specified configuration file, which is
assumed to be a complete configuration, not a partial
configuration. Enter Y if you are sure you want to proceed. ? [no]: y

*Mar  1 00:13:34.119: Rollback:Acquired Configuration lock.
*Mar  1 00:13:44.555: %PARSER-6-EXPOSEDLOCKRELEASED: Exclusive configuration lock released from terminal '0' -Process= "Exec", ipl= 0, pid= 196
Total number of passes: 1
Rollback Done

*Mar  1 00:13:54.951: %PARSER-3-CONFIGNOTLOCKED: Unlock requested by process '196'. Configuration not locked.

That's how easy it is, you've reverted to your desired configuration with one command