Cấu hình backup tự động switch, router cisco với kron
Cấu hình backup tự động switch, router cisco với kron
1/ Cấu hình trên switch, router:
Điều chỉnh lại giờ sao cho chuẩn với GMT +7 để cả switch và server backup đồng bộ giờ chuẩn.
clock timezone vietnam +7
Create a kron policy list—This is the script that lists what commands the router should run at the scheduled time.
Router(config)#kron policy-list SaveConfig
Router(config-kron-policy)#cli write
Router(config-kron-policy)#exit
cli—Specifies EXEC CLI commands within a Command Scheduler policy list.
Policy-list—Specifies the policy list associated with a Command Scheduler occurrence.
Note: The reason why write was used rather than copy running-config startup-config is because kron does not support interactive prompts and the copy running-config startup-config command requires interaction. It is important to remember this when you create commands. Also, note that kron does not support configuration commands.
Create a kron occurrence—This informs the router when and how often the policy should run.
Router(config)#kron occurrence SaveConfigSchedule
at 23:00 Sun recurring
Router(config-kron-occurrence)#policy-list SaveConfig
SaveConfigSchedule—This is the name of occurrence. Length of occurrence-name is from 1 to 31 characters. If the occurrence-name is new, an occurrence structure will be created. If the occurrence-name is not new, the existing occurrence will be edited.
at—Identifies that the occurrence is to run at a specified calendar date and time.
recurring—Identifies that the occurrence is to run on a recurring basis.
Verify the kron configuration by using the show command.
Router#sh kron schedule
Kron Occurrence Schedule
SaveConfigSchedule inactive, will run again in 1 days 12:37:47 at 23:00 on Sun
inactive—Means that kron is not running the command(s) at present.
Active—Means that kron is running the current command(s).
Router#show running-configuration
kron occurrence SaveConfigSchedule at 23:00 Sun recurring
policy-list SaveConfig
kron policy-list SaveConfig
cli write
Backup Configuration to a TFTP Server
This example is to save the running config to a TFTP server (10.1.1.1) every Sunday at 23:00:
Router(config)#kron policy-list Backup
Router(config-kron-policy)#cli show run | redirect tftp://10.1.1.1/switch01.conf
Router(config-kron-policy)#exit
!
Router(config)#kron occurrence Backup at 9:30 wed recurring
Router(config-kron-occurrence)#policy-list Backup
2/ Cấu hình server TFTP
Có thể dùng phần mềm tftp 64 để dùng trên window hoặc cài tftp server trên linux
Sau khi cài xong cần mở cổng 69 trên firewall và cài đặt chi tiết như sau:
Go ahead and double click on tftpd64.exe file. It will open TFTPD64 program (Check screenshot). Once the program is open, click on Settings button.
The TFTPD64 settings window will open as shown below.
Put a check mark only to TFTP Server option. Remove checkmark from all other options.
Note: Be very careful with the DHCP option because if you keep this option checked, then your laptop can act like a DHCP Server in your network. So be careful with the options that you select.
Click on TFTP tab, the window will look as shown below.
Click on Browse button to specify Base Directory. You need to specify the Base Directory of the TFTP Server. You can select any folder in your laptop as the Base Directory. Remember that all the files transferred using TFTP Server will be placed in this folder.
I selected the same TFTP folder (C:\TFTP) as my Base directory. Once you select the folder of your choice, click on OK button.
Under TFTP Security, select the option None (you can also use Standard).
Under Advanced TFTP Options, select Option negotiation, Show Progress bar, Translate Unix file names and Allow “\” as virtual root (check screenshot to understand better)
Here comes a very important step. Now we are going to bind an IP address to the TFTP Server. To set the IP address for TFTP server, please select the option Bind TFTP to this address then select the IP address available for you. I select 10.250.89.1 here as it was the only option available to me. You may get a different IP address, please use the IP address available in the drop down window. Do not break your head, we just an IP address here
Once you have performed all the above said steps, Click on OK. Now you will receive a window asking to restart TFTPD64 to apply the new settings. Click on OK and close all TFTP windows which were open in your laptop.
Re-open TFTPD64 now. Once the program open, just ensure that you selected same IP address for Server Interface. Please remember that the TFTP64 application should be running when any TFTP related job is done. If you close this application, TFTP server will be terminated.
Voila, I just setup a TFTP Server here. Now when I use the address tftp://10.250.89.1, I am referring to C:\TFTP folder in my laptop. Moreover, if you copy a file in C:\TFTP folder, it is accessible by typing the above address. For example, If I keep a Word document file with name SiRu.docx in C:\TFTP folder, the path will be tftp://10.250.89.1/SiRu.docx (never type the folder name C:\TFTP in TFTP path).
You can also find whether anyone is accessing the TFTP Server. When someone copy any file from TFTP server, a tiny file copy window will show statistics and progress bar.
If you wish to find You can also click on Log Viewer and see the logs there.