Using RANCID! intERLab AIT March 2008 1. Install Rancid # apt-get install rancid-core # apt-get install rancid-cgi # apt-get install rancid-util - Answer "Yes" when asked 2. Edit /etc/rancid/rancid.conf Fine the line with the parameter LIST_OF_GROUPS, and set it to: LIST_OF_GROUPS="all" 3. Choose which switch you will manage (10.10.2.253 or 10.10.1.253) depending on which side of the room you are in. Create /var/lib/rancid/.cloginrc # vi /var/lib/rancid/.cloginrc add user 10.10.?.253 inst add password 10.10.?.253 1nterl4b 1nterl4b (Remember to replace ? with 1 or 2) - Save the file and change its owner to "rancid" # chmod 600 .cloginrc # chown rancid .cloginrc 4. Change to the rancid user # su - rancid - Check that you ARE the rancid user: > id - You should see this: uid=1001(rancid) gid=1001(rancid) groups=1001(rancid) 5. Initialize the CVS repository for rancid: > /usr/lib/rancid/bin/rancid-cvs - You should see something similar to this: cvs checkout: Updating all Directory /usr//../var/lib/rancid/CVS/all/configs added to the repository cvs commit: Examining configs cvs add: scheduling file `router.db' for addition cvs add: use `cvs commit' to add this file permanently /usr//../var/lib/rancid/CVS/all/router.db,v <-- router.db initial revision: 1.1 6. Let's add our switch to the config: > cd /var/lib/rancid > vi all/router.db ... add this info: 10.10.?.253:cisco:up Also, there is a small bug in the file /usr/lib/rancid/bin/control_rancid, so edit it and add: PATH=$PATH:/usr/sbin ... just UNDER the first line (#!/bin/sh at the top) 7. Test login to the switch! > /usr/lib/rancid/bin/clogin 10.10.?.253 - You should now be logged in to the switch, and see something like: lan?-sw# - Type 'exit' to logout 8. Let's run rancid! > /usr/lib/rancid/bin/rancid-run (Should take a few seconds) 9. Check out the logs: > cd /var/lib/rancid/logs > ls -l ... View the contents of the file: > more all.* 10. Look at the configs > cd /var/lib/rancid/all/configs > more 10.10.?.253 - If all went well, you can see the config of the router. 11. Let's modify something on the router... > /usr/lib/rancid/bin/clogin 10.10.?.253 - At the "lan?-sw#" prompt, enter the command: config terminal - You should see: Enter configuration commands, one per line. End with CNTL/Z. lan?-sw(config)# - Enter: interface FastEthernet 0/X # X = 1 - 24 - You should get this prompt: lan?-sw(config-if)# - Enter: description port for PC Y # Y = the number of your PC - Then type CTRL-Z (press Control + the Z key) - You should now have this prompt: lan?-sw# - Type to save the config to memory: write memory - The switch should say: Building configuration... [OK] - Type to exit: exit 12. Let's run rancid again: > /usr/lib/rancid/bin/rancid-run Repeats Steps 9. - 10. -- look at the config and logs 13. Let's see the differences > cd /var/lib/rancid/all/configs > cvs log 10.10.?.253 cvs diff -r 1.2 -r 1.3 10.10.?.253 ... your change should appear in the output... 14. Finally, let's make rancid run automatically every 30 minutes from cron > crontab -e - Add this line: */30 * * * * /usr/lib/rancid/bin/rancid-run ... then save and quit 15. Repeat step 3, adding more hosts (other routers and switches)