﻿Using RANCID!

Network management & monitoring Workshop

how to configure it:

1. Start by installing the postfix mail system + mail client

	# apt-get install postfix
	# apt-get install mutt

	(answer "Internet Site" at the question of which type of host you are
	running)

2. Add an alias for the rancid user in /etc/aliases

	rancid-all:			netmanage
	rancid-admin-all:	netmanage

	Save the file, then run:

	# newaliases

3. Install Rancid itself

   apt-get install rancid-core
   apt-get install rancid-util
   apt-get install rancid-cgi
   apt-get install cvsweb
   apt-get install cvs

4. Edit /etc/rancid/rancid.conf

	Find the line with the parameter LIST_OF_GROUPS, and replace it with

	LIST_OF_GROUPS="all"

5. Choose which router you will manage:

	user: netmanage
	password: apr1cot29

	pc1, pc2:   169.223.140.150 (R0)
	pc3, pc4:   169.223.140.151 (R1)
	pc5, pc6:   169.223.140.152 (R2)
	pc7, pc8:   169.223.140.153 (R3)
	pc9, pc10:  169.223.140.154 (R4)
	pc11, pc12: 169.223.140.155 (R5)
	pc13, pc13: 169.223.140.156 (R6)
	pc15        169.223.140.157 (R7)

6. Change to the rancid user

	# su -s /bin/bash rancid
	
	- Check that you ARE the rancid user:

	> id

	- You should see this:

	uid=115(rancid) gid=123(rancid) groups=123(rancid)

7. Create /var/lib/rancid/.cloginrc

	> vi /var/lib/rancid/.cloginrc

	add user 169.223.140.15X netmanage
	add password 169.223.140.15X apr1cot29 apr1cot29

	(Remember to replace X with 1-7)

	> chmod 600 /var/lib/rancid/.cloginrc

7. Initialize the CVS repository for rancid:

	> /usr/lib/rancid/bin/rancid-cvs

	- You should see something similar to this:

No conflicts created by this import

cvs checkout: Updating all
Directory /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
/var/lib/rancid/CVS/all/router.db,v  <--  router.db
initial revision: 1.1


8. Test login to the router

	>  /usr/lib/rancid/bin/clogin 169.223.140.15X

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

RTx#

	- Type 'exit' to logout

9. Add the router.db

	> vi /var/lib/rancid/all/router.db

	Add:

	169.223.140.15X:cisco:up

10. Let's run rancid!

	> /usr/lib/rancid/bin/rancid-run

	(Should take a few seconds)

11. Check out the logs:

	> cd /var/lib/rancid/logs
	> ls -l

	... View the contents of the file:

	> more all.*


12. Look at the configs

	> cd /var/lib/rancid/all/configs
	> more 169.223.140.15X

	- If all went well, you can see the config of the router.


13. Let's change an interface Description on the router

	> /usr/lib/rancid/bin/clogin 169.223.140.15X

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

	config terminal

	- You should see:

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

	- Enter:

	interface FastEthernet 1/0

	- You should get this prompt:

RTx(config-if)#

	- Enter:

	description testing rancid from PCX 		# X = the number of your PC


	- Then type CTRL-Z (press Control + the Z key)

	- You should now have this prompt:

RTx#

	- To save the config to memory:

	write memory

	- The switch should say:

Building configuration...
[OK]

	- Type to exit:

	exit

14. Let's run rancid again:

	> /usr/lib/rancid/bin/rancid-run

	Look at the config and logs

	> ls /var/lib/rancid/logs/

15. Let's see the differences

	> cd /var/lib/rancid/all/configs
	> cvs log 169.223.140.15X

	Notice the revisions.  Let's view the difference between two versions:

	> cvs diff -r 1.2 -r 1.3 169.223.140.15X

	... your change should appear in the output...

16. Check your mail

	As the user "netmanage", run the "mutt" mailer to see the mails that
	Rancid has sent:

	> exit

	# su netmanage

	> mutt

	If everything goes as planned, you should be able to read the mails
	sent by Rancid.

	(use q or x to quit mutt)

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

