- Cisco router /switch running IOS with support for "kron" and "archive" commands
- Ubuntu PC
- IP Connectivity between the Cisco and the Ubuntu PC
First install atftpd on your Ubuntu PC:
sudo apt-get install atftpd
Edit the atftpd config file:
sudo nano /etc/default/atftpd
Change:
USE_INETD=true
to
USE_INETD=false
Note the location that atftpd stores files written to the server is defined as the last entry in the OPTIONS line in this file. Default is /srv/tftp. You don't need to change this unless you really want to do so.
Start the service:
sudo service atftpd start
The service is now running, you can verify this with the command:
sudo ps -A | grep atftpd
1519 ? 00:00:00 atftpd
The bit in red shows that the atftpd process is running and the number 1519 refers to PID.
Logon to your Cisco device - first we will verify that we can write our config to our new TFTP server. Issue the command:
What just happened here? You issue the command "copy run tftp" which means copy the running config to a tftp server. The cli asked you for the address of the remote server (192.168.0.1). The cli then asks you for the filename you wish to write to on the server - by default it will use your router hostname and append "confg" hence MyRouter-confg in this case. The two !s show that the file is being copied over and the cli tells you how long it took.
MyRouter#cop run tftp:
Address or name of remote host []? 192.168.0.1
Destination filename [MyRouter-confg]?
!!
4165 bytes copied in 5.228 secs (797 bytes/sec)
If you now go back to your server and do a directory listing of our tftp folder you should see your file there:
bob@fossil.org:~$ ls -la /srv/tftp/ | grep MyRouter
-rw-r--r-- 1 nobody nogroup 4165 2012-05-11 16:06 MyRouter-confg
So we know tftp server and client bits work. Now to automate it.
We use the archive command:
MyRouter#conf t
Enter configuration commands, one per line. End with CNTL/Z.
MyRouter(config)#archive
MyRouter(config-archive)#path tftp://192.168.0.1/MyRouter.cfg
The archive command will now write the config to the tftp server when you issue the archive config command. Try it:
MyRouter#archive config
!!
You can then use the command show archive to see the history of archived configs.
The second part of this is to schedule the archiving to take place using the kron command:
MyRouter(config)#kron policy-list MyKronPolicy
MyRouter(config-kron-policy)#cli archive config
MyRouter(config-kron-policy)#exit
MyRouter(config)#kron occurrence MyKron at 20:00 recurring
So what does this mean? Here we have created a kron policy list which issues the command archive config, We have then created a kron entry to run this policy at 20:00 every day. There are other options for when you can run the command - either as a one off or in a given amount of time from now. You can check your kron table with the command:
MyRouter#show kron schedule
Kron Occurrence Schedule
MyKron inactive, will run again in 0 days 04:23:43 at 20:00 on
This shows the next time that the kron entry will be run. If your Cisco device is not using NTP and your clock is set incorrectly you may get a warning about the clock being wrong.
And that is it. You should now have your config backed up automatically every day at 20:00. The archive command is clever enough to increment the filename so you don't overwrite your previous entry each time.
No comments:
Post a Comment