Cisco’s IOS offers an easy to use feature for configuration versioning to an external server such as TFTP or SCP. Furthermore, you can use IOS commands to compare any two snapshots and to roll back to one of them.
Archive
Using the archive command within the configuration mode you are entering the archive configuration mode. You must select a path, which SHOULD be a secure protocol such as SCP. You need to specify the username and password, separated by a colon, in plaintext though. (While this is not really good, it is still much better than transferring the whole configuration via plain TFTP through your complete network!) The variables $h and $t are for the hostname respectively the date/time. The last step is to set the condition when the configuration is copied to the destination: Either time-based via time-period <minutes> or during the “wr mem” process via write-memory. I prefer the latter. My default setup is:
1 2 3 |
archive path scp://iosarchive:iospassword@scp.weberlab.de/$h-$t write-memory |
It uses a username of “iosarchive” and the password “iospassword”. The SCP server is set via an FQDN “scp.weberlab.de” after the @-sign. I am copying directly into the root folder “/” while the filenames are displayed as hostname-dash-datetime.
Now for every “write memory” or “copy run start” you’ll see the copy process. In my case it’s resolving the FQDN first. Note the exclamation mark in the middle of the last line which shows the copy process:
1 2 3 4 5 6 7 8 9 10 11 |
R4#wr Building configuration... [OK] Translating "scp.weberlab.de"...domain server (2003:DE:2016:120::A08:53) Translating "scp.weberlab.de"...domain server (2003:DE:2016:120::A08:53) [OK] Writing R4-Feb-20-2018-21-57-46.530-UTC-5 ! Sink: C0644 7370 R4-Feb-20-2018-21-57-46.530-UTC-5 R4# |
You can also trigger a copy of the running configuration via archive config manually.
Show Archive
Using the show archive command you can see the last 10 archives:
1 2 3 4 5 6 7 8 9 10 11 |
R4#show archive The maximum archive configurations allowed is 10. The next archive file will be named scp://iosarchive:iospassword@scp.weberlab.de/R4-Feb-21-2018-08-16-44.467-UTC-6 Archive # Name 1 scp://iosarchive:iospassword@scp.weberlab.de/R4-Feb-16-2018-10-57-51.796-UTC-0 2 scp://iosarchive:iospassword@scp.weberlab.de/R4-Feb-16-2018-11-05-17.353-UTC-1 3 scp://iosarchive:iospassword@scp.weberlab.de/R4-Feb-16-2018-12-58-02.633-UTC-2 4 scp://iosarchive:iospassword@scp.weberlab.de/R4-Feb-16-2018-16-31-27.030-UTC-3 5 scp://iosarchive:iospassword@scp.weberlab.de/R4-Feb-20-2018-19-46-01.579-UTC-4 6 scp://iosarchive:iospassword@scp.weberlab.de/R4-Feb-20-2018-21-57-46.530-UTC-5 <- Most Recent [...] |
Note the “<- Most Recent” keyword at the end of one line.
Looking at the SCP server itself (in my case a Ubuntu Linux) you can see exactly those configuration snapshots:
1 2 3 4 5 6 7 |
weberjoh@jw-nb10-syslog-mirror:/home/iosarchive$ ls -ahl | grep R4 -rw-r--r-- 1 iosarchive iosarchive 7.3K Feb 16 11:57 R4-Feb-16-2018-10-57-51.796-UTC-0 -rw-r--r-- 1 iosarchive iosarchive 7.1K Feb 16 12:05 R4-Feb-16-2018-11-05-17.353-UTC-1 -rw-r--r-- 1 iosarchive iosarchive 7.1K Feb 16 13:58 R4-Feb-16-2018-12-58-02.633-UTC-2 -rw-r--r-- 1 iosarchive iosarchive 7.1K Feb 16 17:31 R4-Feb-16-2018-16-31-27.030-UTC-3 -rw-r--r-- 1 iosarchive iosarchive 7.2K Feb 20 20:46 R4-Feb-20-2018-19-46-01.579-UTC-4 -rw-r--r-- 1 iosarchive iosarchive 7.2K Feb 20 22:57 R4-Feb-20-2018-21-57-46.530-UTC-5 |
Differences & Rollback
Let’s make a concrete example how to use the compare and rollback features. Before I started I archived the current configuration. This was called “R4-Feb-20-2018-21-57-46.530-UTC-5”. Now I made some configuration changes manually, namely an interface tracking for HSRP and an access-list:
1 2 3 4 5 6 7 8 9 |
conf t int gi0/0 standby 25 priority 110 standby 25 preempt standby 25 track gi0/1 20 exit access-list 100 permit ip host 192.168.124.11 host 192.168.120.10 access-list 100 permit ip host 192.168.120.10 host 192.168.124.11 end |
After that I copied the configuration via “archive config” to the SCP server. This snapshot is called “R4-Feb-21-2018-08-40-39.857-UTC-6”.
Now I used the show archive config differences <path1> <path2> command to compare the differences. This fantastically reveals all configuration changes at a glance, line 10-16:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
R4#show archive config differences scp://iosarchive:iospassword@scp.weberlab.de/R4-Feb-20-2018-21-57-46.530-UTC-5 scp://iosarchive:iospassword@scp.weberlab.de/R4-Feb-21-2018-08-40-39.857-UTC-6 Translating "scp.weberlab.de"...domain server (2003:DE:2016:120::A08:53) Sending file modes: C0644 7370 R4-Feb-20-2018-21-57-46.530-UTC-5 Sending file modes: C0644 7633 R4-Feb-21-2018-08-40-39.857-UTC-6 Translating "scp.weberlab.de"...domain server (2003:DE:2016:120::A08:53) Sending file modes: C0644 7370 R4-Feb-20-2018-21-57-46.530-UTC-5 ! Sending file modes: C0644 7633 R4-Feb-21-2018-08-40-39.857-UTC-6 !!Contextual Config Diffs: +track 1 interface GigabitEthernet0/1 line-protocol interface GigabitEthernet0/0 +standby 25 priority 110 +standby 25 preempt +standby 25 track 1 decrement 20 +access-list 100 permit ip host 192.168.124.11 host 192.168.120.10 +access-list 100 permit ip host 192.168.120.10 host 192.168.124.11 R4# |
Some time later I wanted to rollback to the configuration before I made any of those changes. Therefore I could use the configure replace command. The “list” keyword at the end additionally shows all CLI changes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
R4#configure replace scp://iosarchive:iospassword@scp.weberlab.de/R4-Feb-20-2018-21-57-46.530-UTC-5 list 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 Translating "scp.weberlab.de"...domain server (2003:DE:2016:120::A08:53) Sending file modes: C0644 7370 R4-Feb-20-2018-21-57-46.530-UTC-5 ! Sending file modes: C0644 7370 R4-Feb-20-2018-21-57-46.530-UTC-5 ! !Pass 1 !List of Rollback Commands: no access-list 100 interface GigabitEthernet0/0 no standby 25 track 1 decrement 20 no standby 25 preempt no standby 25 priority 110 no track 1 interface GigabitEthernet0/1 line-protocol end Total number of passes: 1 Rollback Done R4# Feb 21 2018 13:28:25.825 UTC: Rollback:Acquired Configuration lock. R4# |
Nice. ;)
Just for fun I used the show archive config differences again, but this time with only a single path to the old config, which then compares it to the running config:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
R4#show archive config differences scp://iosarchive:iospassword@scp.weberlab.de/R4-Feb-21-2018-08-40-39.857-UTC-6 Translating "scp.weberlab.de"...domain server (2003:DE:2016:120::A08:53) Sending file modes: C0644 7633 R4-Feb-21-2018-08-40-39.857-UTC-6 Sending file modes: C0644 7633 R4-Feb-21-2018-08-40-39.857-UTC-6 !!Contextual Config Diffs: +track 1 interface GigabitEthernet0/1 line-protocol interface GigabitEthernet0/0 +standby 25 priority 110 +standby 25 preempt +standby 25 track 1 decrement 20 +access-list 100 permit ip host 192.168.124.11 host 192.168.120.10 +access-list 100 permit ip host 192.168.120.10 host 192.168.124.11 R4# |
Also note that you can use this command without any paths to compare the running config with the startup config. The “+” indicates that those commands are present in the startup config but not in the running config, while a “-” would indicate commands in the running but not in the startup config:
1 2 3 4 5 6 7 8 9 |
R4#show archive config differences !Contextual Config Diffs: +track 1 interface GigabitEthernet0/1 line-protocol interface GigabitEthernet0/0 +standby 25 priority 110 +standby 25 preempt +standby 25 track 1 decrement 20 +access-list 100 permit ip host 192.168.124.11 host 192.168.120.10 +access-list 100 permit ip host 192.168.120.10 host 192.168.124.11 |
And one more note: There is the option of “incremental-diffs” within the “show archive config” commands that shows actual configuration commands that are not present in the running configuration, that is, without those “+” and “-“. Comparing my current running-config with the one saved after my manual changes shows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
R4#$e config incremental-diffs scp://iosarchive:iospassword@scp.weberlab.de/R4-Feb-21-2018-08-40-39.857-UTC-6 Translating "scp.weberlab.de"...domain server (2003:DE:2016:120::A08:53) Translating "scp.weberlab.de"...domain server (2003:DE:2016:120::A08:53) [OK] Sending file modes: C0644 7633 R4-Feb-21-2018-08-40-39.857-UTC-6 Sending file modes: C0644 7633 R4-Feb-21-2018-08-40-39.857-UTC-6 ! !List of Commands: track 1 interface GigabitEthernet0/1 line-protocol interface GigabitEthernet0/0 standby 25 priority 110 standby 25 preempt standby 25 track 1 decrement 20 access-list 100 permit ip host 192.168.124.11 host 192.168.120.10 access-list 100 permit ip host 192.168.120.10 host 192.168.124.11 end |
Time-Based Reload & Rollback
Very similar to the time-based reload you can schedule a time-based config replace. These are the commands to do a time-based reload, just for the sake of completeness:
1 2 3 4 |
reload at hh:mm reload in hhh:mm show reload reload cancel |
Combined with the rollback functionalities you can set a time at which a rollback shall take place (e.g., just a few minutes after some big changes). In case you’ve cut your connection this can save your life. ;) If all your changes work properly you can “confirm” the replace, i.e., stop the pending revert action.
1 2 3 |
configure replace <path> time <minutes> configure replace confirm ! stop the pending revert action configure revert now ! speed up the revert |
Good to know.
Featured image “Archives” by Marino González is licensed under CC BY-NC-ND 2.0.
Nice writeup!.
I also tend to do a show archive config diff without further parameters just after logging in a device. Just to see if anyone left some unsaved stuff in before I do my changes. So I would not save them to start along with my changes I’m about to make. Or at the very least I would then be aware that I’m saving other changes along with mine.