It took me times to research and find out how to get configuration backup automatically from H3C, Huawei and HP network devices. Finally I can get it works using Rancid with the following steps. But wait, if you don’t understand what Rancid is, check out our Rancid article.
Before we move ahead to the heart of the article, I would like to mention that this document is specifically for Rancid version 2 and below platform/models have been tested successfully.
- Huawei MA5600 (Comware 5)
- HP A5900 (Comware 7)
- H3C S3100 (Comware 3)
- H3C S5600 (Comware 3)
- H3C S7506 (Comware 5)
- H3C S7906E (Comware 5)
- H3C S5820X / HP A5800-48G (Comware 5)
- H3C S5800 (Comware 5)
- H3C S3610 (Comware 5)
- H3C MSR30-60 (Comware 5)
- H3C/HP S5120 (Comware 5)
- 3Com 7750 (Comware 3)
- 3Com 5500-EI/SI / HP E5500-EI/SI (Comware 3)
- 3Com 5500G (Comware 3)
- 3Com 4200G (Comware 3)
- 3Com 4210 (Comware 3)
- 3Com 4800G / H3C S5500 / HP A5500 (Comware 5)
- 3Com 4210G (Comware 5)
1. Upload scripts to Rancid server (h3clogin & h3crancid script has been attached)
In my case, I have customized Rancid path to /rancid/bin/ so if you are using different path, you have to upload both files attached there.
2. Change files permission and ownership
After the files are uploaded, you have to change permission and ownership with following command.
chown rancid:netadm /rancid/bin/h3clogin chown rancid:netadm /rancid/bin/h3crancid chmod 755 /rancid/h3clogin chmod 755 /rancid/h3crancid
3. Modify rancid-fe file in the same directory
As I mentioned above, I have Rancid in /rancid/ so now I have to modify rancid-fe file in order to get it support with H3C. The command would be:
Then add the following line. There are similar setting for different vendor in that file.
'h3c' => 'h3crancid',
4. Create Rancid Group
It is very useful to separate different network devices’ configuration by using different directory. It can be based on customer name, geographical location or vendor platform.
In order to do that, you have to modify /rancid/etc/rancid.conf by adding the name of the group. Below is the example of creating Test group where all the device configurations will be stored.
LIST_OF_GROUP="Australia USA England"
The group names must be separated with a space. Once a new group is added you need to generate config and svn folder with below command:
5. Email aliases need to be created
Now it is time to put in an email address to receive notification whenever configuration on the network devices change.
rancid-admin-Test: rancid-Test rancid-Test: noc noc: [email protected]
6. Add H3C switch into router.db
Now you have to add your H3C switch into router.db file so that Rancid can keep trace on it.
vim /rancid/var/Test/router.db MyDevice:h3c:up
7. Update the hosts file
Note that MyDevice that has been added in router.db above, we have to map it with an IP address in hosts file.
!!Below is an example of MyDevice IP address
8. Add login credential of device to .cloginrc file
Rancid uses Telnet or SSH to log into network devices and pull the configuration then compare for differ. So we have to add login credential other it wont work.
!!!Recommendation: I would suggest to create a separate username and password with read-only permission.
Then modify the .cloginrc file with something similar as the following.
add user MyDevice username-to-login add password MyDevice password-to-login add method MyDevice ssh
9. Login Verification
Now let test if you can login to your H3C switch with Rancid. You will need to troubleshoot it if you cannot login successfully before you move to the next step.
[[email protected] ~]$ h3clogin MyDevice
10. Let get the configuration from the switch
!!!Before you issue below command, make sure you are rancid user otherwise the permission of configuration file will be changed and cause some issue when it automatically run.
[[email protected] ~]$ rancid-ran Test
Note that you can issue above command for specific group or just rancid-ran for every groups in the system. The configuration file will be stored at /rancid/var/Test/config/
That’s it!!! Now you can get configuration for H3C, HP, H3Com and Huawei switch using Rancid or leave a comment below if have an issue.
Download the files, simply click the link below.