<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Bob Drank the Water</title>
	<atom:link href="http://uberbruco.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://uberbruco.wordpress.com</link>
	<description>Bring me my monocle.  I want to look rich.</description>
	<lastBuildDate>Sun, 17 Apr 2011 22:48:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='uberbruco.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Bob Drank the Water</title>
		<link>http://uberbruco.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://uberbruco.wordpress.com/osd.xml" title="Bob Drank the Water" />
	<atom:link rel='hub' href='http://uberbruco.wordpress.com/?pushpress=hub'/>
		<item>
		<title>RANCID on FreeBSD</title>
		<link>http://uberbruco.wordpress.com/2009/07/09/rancid-on-freebsd/</link>
		<comments>http://uberbruco.wordpress.com/2009/07/09/rancid-on-freebsd/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 18:39:35 +0000</pubDate>
		<dc:creator>bruco</dc:creator>
				<category><![CDATA[nerd]]></category>

		<guid isPermaLink="false">http://uberbruco.wordpress.com/?p=7</guid>
		<description><![CDATA[RANCID is an application that allows you to track changes to network devices using a CVS tree.  It will email you any changes made at scheduled intervals.  You can read more about it here. I’m going to implement RANCID on a FreeBSD box at work to track changes to my Cisco network devices.  I’ve tested [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uberbruco.wordpress.com&amp;blog=8285556&amp;post=7&amp;subd=uberbruco&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><font size="2">RANCID is an application that allows you to track changes to network devices using a CVS tree.  It will email you any changes made at scheduled intervals.  You can read more about it <a href="http://www.shrubbery.net/rancid/">here</a>.</p>
<p>I’m going to implement RANCID on a FreeBSD box at work to track changes to my Cisco network devices.  I’ve tested these directions on FreeBSD 6.3 and 7.2 and they should work on FreeBSD in general.</p>
<p>Oh, and credit where credit is due, I used <a href="http://joe-ma-how-to.blogspot.com/2008/05/setting-up-and-installing-rancid-on.html">Joe-Ma’s directions</a> extensively as I learned about RANCID.</p>
<p><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">1.    First, let’s create a user for RANCID.  I’ll call the user… I dunno… RANCID.</p>
<pre style="padding-left:60px;"># adduser</pre>
<address></address>
<p style="padding-left:30px;">I added the RANCID user to the wheel group, so I can easily su to root later when I’m logged in as RANCID.</p>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">2.    Now let’s make sure we have the latest version of RANCID to install:</p>
<pre style="padding-left:60px;"># portsnap fetch update</pre>
<p style="padding-left:30px;">I like portsnap, other people user other methods.  To each his own.</p>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">3.    Install RANCID next:</p>
<pre style="padding-left:60px;"># cd /usr/ports/net-mgmt/rancid/ &amp;&amp; make install clean</pre>
<p style="padding-left:30px;">I accepted all the defaults during the install.</p>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">4.    Now copy /usr/local/etc/rancid/rancid.conf.sample to /usr/local/etc/rancid/rancid.conf.</p>
<pre style="padding-left:60px;"># cp /usr/local/etc/rancid/rancid.conf.sample /usr/local/etc/rancid/rancid.conf</pre>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">5.    Edit rancid.conf.  I changed and uncommented the following line:</p>
<pre style="padding-left:60px;">LIST_OF_GROUPS=”CiscoDevices”</pre>
<p style="padding-left:30px;"><em>(</em><em>this is where you list one or more groups that your network devices will fall under.  I’m only using one group for all of them.)</em></p>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">6.    None of my Cisco devices are in DNS, so I’m going to just add some names to my /etc/hosts file:</p>
<pre style="padding-left:60px;">192.168.1.5.1     Switch1
192.168.2.10.1    Switch2
192.168.2.15.1    Router1
256.43.26.35      Firewall1</pre>
<p style="padding-left:30px;">Etc.</p>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">7.    We’ve been working as root, but now you’ll want to login as your RANCID user and create a .cloginrc file in the home directory:</p>
<pre style="padding-left:60px;">$ touch /home/RANCID/.cloginrc</pre>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">8.    The .cloginrc file contains usernames, passwords, and methods of logging into your network equipment.  You’ll need to edit the file to include this information. Here are some eamples from mine:</p>
<pre style="padding-left:60px;">add password switch* {password} {enapassword}</pre>
<p style="padding-left:30px;"><em>(In this case, any device defined in my hosts file that starts with “switch” will use the first password to login to the device, and the second as the enable password.)</em></p>
<address> </address>
<pre style="padding-left:60px;">add method switch* telnet</pre>
<p style="padding-left:30px;"><em>(Any device that starts with “switch” will be logged into through telnet.)</em></p>
<pre style="padding-left:60px;">add user firewall* admin</pre>
<p style="padding-left:30px;"><em>(Any device that starts with “firewall” will be logged into using “admin” as the username.)</em></p>
<pre style="padding-left:60px;">add method firewall* ssh</pre>
<p style="padding-left:30px;"><em>(Any device that starts with “firewall” will be logged into through ssh.)</em></p>
<p style="padding-left:30px;">Note: I’ve found that when clogin uses the .cloginrc file to identify devices, it changes the name given to lowercase.  Therefore, all your device names in the .cloginrc file must be in lowercase.  For instance, in my hosts file I list Switch1 and Switch2, but when referring to them in .cloginrc I use switch* &#8211; WITHOUT a capital “s”.  Otherwise it won’t work.  I don’t know if there is a setting to change this, but in my case the easiest thing to do is just avoid capital letters in device names in .cloginrc.</p>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">9.    Keep in mind that the .cloginrc file has clear-text passwords in it, so it needs to be locked down.  In fact, the program won’t use it if it’s writeable by anybody other than the RANCID user.  So let’s set the permissions on it:</p>
<pre style="padding-left:60px;">$ chmod 600 /home/RANCID/.cloginrc</pre>
<p style="padding-left:30px;">The installation might have created a /usr/local/var/rancid directory.  But we don’t want it, we’re going to create it again ourselves.  So, if it exists, su to root and get rid of it.</p>
<pre style="padding-left:60px;">$ su
Password:
# rm –r /usr/local/var/rancid</pre>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">10.    We need to recreate the /rancid directory as the RANCID user, but I didn’t have permission to do so.  But remember, we made RANCID a member of the wheel group.  So, still as root, let’s modify the directory permissions:</p>
<pre style="padding-left:60px;"># chmod 775 /usr/local/var</pre>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">11.    Now we’ll exit back to our RANCID user shell and recreate that folder:</p>
<pre style="padding-left:60px;"># exit
$ mkdir /usr/local/var/rancid</pre>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">12.    Next we’ll create our initial directory structure with this command:</p>
<pre style="padding-left:60px;">$ /usr/local/bin/rancid-run</pre>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">13.    And now our data directories with this command:</p>
<pre style="padding-left:60px;">$ /usr/local/bin/rancid-cvs</pre>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">14.    Now the full structure should be in place in the /usr/local/var/rancid directory.  You should be able to cd to a directory named after the group (or groups) you named in Step 5.</p>
<pre style="padding-left:60px;">$ cd /usr/local/var/rancid/CiscoDevices</pre>
<address></address>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">15.    In here there’s a file called router.db that we need to edit.  This is where we’ll add the list of devices that we want RANCID to look at.  Based on earlier examples, here’s mine:</p>
<pre style="padding-left:60px;">Switch1:cisco:up
Switch2:cisco:up
Router1:cisco:up
Firewall1:cisco:up</pre>
<p style="padding-left:30px;">The first section refers to the device based on the names I put in my /etc/hosts file.  The second section specifies the type of device – in my case, they are all Cisco.  The third section simply says the device is up and should be scanned.  Any device I add here I want to be scanned, so they will all say “up”.</p>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">16.    Before we run anything at this point, you’ll probably want the emails generated to actually go somewhere.  Let’s su back to root and add some aliases.  This all depends on your mail setup, but in my case I want the emails from RANCID to go to an external email address.  So I added the following lines to /etc/aliases:</p>
<pre style="padding-left:60px;">rancid-CiscoDevices: bruco@myemail.com
rancid-admin-CiscoDevices: bruco@myemail.com</pre>
<p style="padding-left:30px;">Replace “CiscoDevices” in both those lines with whatever group name you defined in Step 5.  If you did multiple groups, you’ll need two lines for each group.</p>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">17.    This step depends on what mail server you are running.  By default FreeBSD runs sendmail.  I haven’t changed that, so I run sendmail, and now I need to regenerate my aliases for it.  Still as root:</p>
<pre style="padding-left:60px;"># newaliases</pre>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">18.    Now let’s exit back to our RANCID shell and run it again.  Don’t run it as root!  It might cause permission issues and will just be a headache.  Only run it as the RANCID user you created.</p>
<pre style="padding-left:60px;"># exit
$ /usr/local/bin/rancid-run</pre>
<p style="padding-left:30px;">If everything works, you should receive emails detailing the devices you’ve specified in router.db.</p>
<p style="padding-left:30px;"><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;">19.    Lastly, we probably want to run this automatically every so often.  So let’s schedule it with cron.  Once again, we’ll do it as the RANCID user, not root!</p>
<pre style="padding-left:60px;">$ crontab -e
 45    17    *    *    *    /usr/local/bin/rancid-run</pre>
<p style="padding-left:30px;">I’m running the job at 5:45 each day, because I have a fairly controlled environment (I’m the only person making changes to the Cisco devices).  However, it could be run more frequently if necessary.  Many people probably run it hourly.</p>
<p><span style="color:#ffffff;">.</span></p>
<p>Now we’re done!  At whatever interval we’ve set, RANCID will log into all the devices you’ve defined and check for differences since the last check.  If it finds them, it will email you the differences.</p>
<p>Here’s an example of an email from RANCID:</p>
<p><span style="color:#ffffff;">.</span></p>
<p style="padding-left:30px;"><em>Index: configs/switch1<br />
===================================================================<br />
retrieving revision 1.3<br />
diff -u -4 -r1.3 switch1<br />
@@ -135,9 +135,8 @@<br />
!<br />
interface FastEthernet0/17<br />
!<br />
interface FastEthernet0/18<br />
-  power inline never<br />
spanning-tree portfast trunk<br />
!<br />
interface FastEthernet0/19<br />
!</em></p>
<p><span style="color:#ffffff;">.</span></p>
<p>In this case I changed port 0/18 to allow Power over Ethernet on it.  See the &#8211; character next to “power inline never”?  That means that that particular line was removed from the configuration since the last time it was checked.  If I had added a line it would appear with a + character next to it.</p>
<p><span style="color:#ffffff;">.</span></p>
<h3>Things to keep in mind:</h3>
<p>Make sure all the device names in .cloginrc are in lowercase.</p>
<p>Don’t run /usr/local/bin/rancid-run as root – only run it as the RANCID user.</p>
<p>I ran into one issue where RANCID was hanging on one device – a router, specifically.  It turns out the router security was set up incorrectly and didn’t require an ena password.  RANCID didn’t know what to do, so it just hung on that device.  I changed the router configuration (since I do want an ena password to be required!) and now RANCID can login and pull the configuration properly.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uberbruco.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uberbruco.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uberbruco.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uberbruco.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uberbruco.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uberbruco.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uberbruco.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uberbruco.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uberbruco.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uberbruco.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uberbruco.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uberbruco.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uberbruco.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uberbruco.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uberbruco.wordpress.com&amp;blog=8285556&amp;post=7&amp;subd=uberbruco&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uberbruco.wordpress.com/2009/07/09/rancid-on-freebsd/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/80302d6c5b0eacae5ddd55268ad38bf1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bruco</media:title>
		</media:content>
	</item>
	</channel>
</rss>
