Posts Tagged ‘config replace’


In a recent post I talked about Using Config Replace For Managing Router & Switch Initial Configs.  This is a great feature that can be useful to quickly switch between initial configs and a default config while labbing on your routers without having to write erase and reload – which can be very time consuming.  However, I previously assumed that this required a staged “blank” config in the router’s flash, because regular IOS and IOS-XE don’t have a built in text editor such as vi/nano/pico that would let you create a blank file on the router’s flash.

Thanks to my buddy xous in #cisco on, I found that you can use TCL to write a file to flash through the IOS CLI, the same as if it was a native text editor.  The end result is that you can use the following code to write a blank config file at any time to rollback to.

puts [ open "flash:blank.cfg" w+] {
version 15.4

An example implementation of this is as follows:

R1#show ip int brief | exclude unassign
Interface              IP-Address      OK? Method Status                Protocol
GigabitEthernet1.13      YES TFTP   up                    up
GigabitEthernet1.100   YES TFTP   up                    up
GigabitEthernet1.146     YES TFTP   up                    up
Loopback0           YES TFTP   up                    up
Tunnel0             YES TFTP   up                    up      

R1(tcl)#puts [ open "flash:blank.cfg" w+] {
+>(tcl)#version 1.1
R1#config replace flash:blank.cfg
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]: yes
Overwriting with a file sized 50% or less than running config's. Proceed? [no]: yes
% Be sure to ask the CA administrator to revoke your certificates.


Router#show ip int brief | ex unassign
Interface              IP-Address      OK? Method Status                Protocol


The end result is that you can at any time default the router’s config without having to erase and reload. Note that there are certain caveats such as deleted subinterfaces on Ethernet or Serial links which will still exist as “deleted” in the running config, but in most cases for our applications this will not be an issue.

Also as a shameless plug for IRC feel free to join the discussion in the channel #cisco on and chat with us. You can find me there with nick bmcgahan.

Happy labbing!

Tags: ,


In this short video I outline how to use the Configuration Rollback and Replace feature, which can save you a great deal of time when you’re switching between blank configs or initial configurations for INE’s CCIE Routing & Switching Version 5 Workbook.

Tags: , , ,


CCIE Bloggers