﻿Using RANCID!
Apricot 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. Create /var/lib/rancid/.cloginrc

	# vi /var/lib/rancid/.cloginrc

	add     user 169.223.2.3 rancid
	add password 169.223.2.3 r4nc1d s3cr3t

	- 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:

169.223.2.3:cisco:up


7. Test login to the switch!

	> /usr/lib/rancid/bin/clogin 169.223.2.3

	- You should now be logged in to the switch, and see something like:

Switch#

	- 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 169.223.2.3

	- 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 169.223.2.3

	- At the "Switch#" prompt, enter the command:

	config terminal

	- You should see:

Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#

	- Enter:

	interface FastEthernet 0/X					# X = 1 - 24

	- You should get this prompt:

Switch(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:

Switch#

	- 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 169.223.2.3

	cvs diff -r 1.1 -r 1.2 169.223.2.3

	... 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