<?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:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Teklimbu's Weblog</title>
	<atom:link href="http://teklimbu.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://teklimbu.wordpress.com</link>
	<description>WordPress.com weblog for Linux/Unix sysadmins</description>
	<lastBuildDate>Sat, 02 Feb 2008 14:29:45 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
		<url>http://www.gravatar.com/blavatar/d2ff18460ea0bcb9846ea77f65c72338?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Teklimbu's Weblog</title>
		<link>http://teklimbu.wordpress.com</link>
	</image>
			<item>
		<title>Server and Network Monitoring using MRTG &#8211; Part 1</title>
		<link>http://teklimbu.wordpress.com/2008/01/28/server-and-network-monitoring-using-mrtg-part-1/</link>
		<comments>http://teklimbu.wordpress.com/2008/01/28/server-and-network-monitoring-using-mrtg-part-1/#comments</comments>
		<pubDate>Mon, 28 Jan 2008 15:41:20 +0000</pubDate>
		<dc:creator>teklimbu</dc:creator>
				<category><![CDATA[freebsd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mrtg]]></category>
		<category><![CDATA[snmp]]></category>
		<category><![CDATA[solaris]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[monitoring]]></category>

		<guid isPermaLink="false">http://teklimbu.wordpress.com/?p=22</guid>
		<description><![CDATA[
This is the 1st series of articles highlighting the usage of MRTG for server and network monitoring.
In my previous article, I touched upon the basics of installing MRTG, Net-SNMP and used the cfgmaker tool to generate simple MRTG graphs. In this article, we further move on to the topic of creating MRTG graphs for a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=22&subd=teklimbu&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Flinux_unix%2FServer_and_Network_Monitoring_using_MRTG_Part_1' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
<p>This is the 1st series of articles highlighting the usage of <b>MRTG </b>for server and network monitoring.</p>
<p>In my previous <a href="http://teklimbu.wordpress.com/2007/12/05/monitoring-your-linuxunix-servers-and-network-devices-using-mrtg-and-snmp/" title="Server monitoring using MRTG basics" target="_blank">article</a>, I touched upon the basics of installing <b>MRTG</b>, <b>Net-SNMP</b> and used the <b>cfgmaker </b>tool to generate simple <b>MRTG </b>graphs. In this article, we further move on to the topic of creating <b>MRTG </b>graphs for a single Linux/Unix machine using only shell scripts.</p>
<p>The final goal or mission of these series of articles is to provide users concrete and professional examples of monitoring their servers and network devices using <b>MRTG</b>. In the end of these series of articles, we will round up and unite all these <b>MRTG </b>graphs to our <b>web based network monitoring system </b>called <b>Nagios</b>.</p>
<p><span id="more-22"></span></p>
<p>I had provided the basics steps of installation and configuration of <b>Nagios </b>in my previous article which can be found at:</p>
<p><a href="http://teklimbu.wordpress.com/2008/01/01/network-management-using-nagios/" title="Nagios installation and basics" target="_blank">http://teklimbu.wordpress.com/2008/01/01/network-management-using-nagios/ </a></p>
<p>For this article, I will be just be using a shell script called <b>system</b> which I had found on the web some time ago. This script provides various data such as memory usage, processes running, tcp connections, etc..</p>
<p>The shell script called <b>system</b> and it&#8217;s corresponding <b>mrtg.cfg </b>configuration file can be used to monitor your workstations and servers and it looks quite cool! You won&#8217;t even be needing <b>SNMP </b>for this script to work but the downside is that this script can monitor only a single network interface. Of course, we can modify this script to report every network interface on your server! And we will be using other scripts in future articles reporting the traffic analysis from multiple network interfaces.</p>
<p>Which tools and programs will we be using in this article? We will only be using the <b>Apache</b> web server, the <b>MRTG </b>tool and of course the shell script called &#8220;<b>system</b>&#8220;.</p>
<p>As always, if you want anything to be displayed graphically on a web page, you will need a web server. <b>Apache </b>is the default Web server used with Linux and Unix hosts. Even Windows based operating systems uses them!</p>
<p>A large fraction of the websites running on the Internet today are powered by the Apache web server. Hence our first step is installing a very basic form of Apache suiting our needs. As of today (28-Jan-2008), the latest version of <b>Apache is 2.2.8</b></p>
<p align="center"><b>Installing the Apache Web server</b></p>
<p><b>(1.)  Download Apache</b></p>
<p>cd   /usr/local/src</p>
<p>wget http://ftp.cuhk.edu.hk/pub/packages/apache.org/httpd/httpd-2.2.8.tar.gz</p>
<p><b>(2.)  unzip the sources</b></p>
<p>tar   zxvf   httpd-2.2.8.tar.gz</p>
<p><b>(3.)  Configure Apache</b></p>
<p>cd    httpd-2.2.8</p>
<p>./configure</p>
<p>–prefix=/usr/local/httpd \</p>
<p>–enable-so</p>
<p><b>(4.) Compile and install Apache </b></p>
<p>make  &amp;&amp;   make  install</p>
<p><i><b>(5.)  Start the Apache web server </b></i></p>
<p>/usr/local/httpd/bin/apachectl start</p>
<p>That’s it. <b>Apache 2.2.8</b> should now be running!</p>
<p>Moving on, we will next compile and install the <b>MRTG </b>package.</p>
<p align="center">&nbsp;</p>
<p align="center"><b>MRTG Installation</b></p>
<p><b><i>(1.)  Create local directory and change to that directory.</i></b></p>
<p>mkdir  -p  /usr/local/src/mrtg</p>
<p>cd   /usr/local/src/mrtg</p>
<p><i><b>(2.) Download MRTG. The latest version of MRTG as on 28-Jan-2008 is 2.15.2.<br />
</b></i></p>
<p>wget http://oss.oetiker.ch/mrtg/pub/mrtg-2.15.2.tar.gz</p>
<p><b><i>(3.)   Unzip the package.</i></b></p>
<p>tar   zxvf mrtg-2.15.2.tar.gz</p>
<p>cd   mrtg-2.15.2</p>
<p><b><i>(4.)   Configure MRTG</i></b></p>
<p>./configure   –prefix=/usr/local/mrtg-2</p>
<p>Note: you may need to install the GD library. For Debian users, it’s just a matter of typing:<b> apt-get install libgd-dev</b></p>
<p>However, you can download the GD package and compile it manually.</p>
<p><code>wget http://www.libgd.org/releases/oldreleases/gd-2.0.33.tar.gz</code></p>
<p><code>tar zxvf  gd-2.0.33.tar.gz</code></p>
<p><code>cd  gd-2.0.33</code></p>
<p><code>./configure</code></p>
<p><code>make &amp;&amp; make install</code><code></code></p>
<p align="left">&nbsp;</p>
<p> <b><i> (5.)    Compile and install the MRTG software.</i></b></p>
<p>make &amp;&amp; make  install</p>
<p>That’s it. MRTG is now installed in the prefixed directory:  /usr/local/mrtg-2</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><b>The main shell script: system</b></p>
<p>We will use the following shell script called <b>system</b>.</p>
<p><i><b>(1.)  mkdir  -p  /usr/local/mrtg-2/scripts/</b></i></p>
<p><i><b>(2)  vi  /usr/local/mrtg-2/scripts/system</b></i></p>
<p>#Copy and paste the following</p>
<p>###Start of script called system####</p>
<p>#!/bin/sh</p>
<p>TYPE=$1<br />
PARAM=$2</p>
<p>if [ "$TYPE" = "load" ]; then<br />
INDATA=`cat /proc/loadavg | cut -d &#8216; &#8216; -f2 | sed &#8217;s/\.//g&#8217; | sed &#8217;s/^0//g&#8217;`<br />
OUTDATA=`cat /proc/loadavg | cut -d &#8216; &#8216; -f3 | sed &#8217;s/\.//g&#8217; | sed &#8217;s/^0//g&#8217;`<br />
fi</p>
<p>if [ "$TYPE" = "processes" ]; then<br />
INDATA=`cat /proc/loadavg | cut -d &#8216; &#8216; -f4 | cut -d &#8216;/&#8217; -f 2`<br />
OUTDATA=`cat /proc/loadavg | cut -d &#8216; &#8216; -f4 | cut -d &#8216;/&#8217; -f 1`<br />
fi</p>
<p>if [ "$TYPE" = "network" ]; then<br />
LINE=`cat /proc/net/dev | grep $PARAM | sed s/$PARAM://`<br />
INDATA=`echo $LINE | awk &#8216;{print $1}&#8217; `<br />
OUTDATA=`echo $LINE | awk &#8216;{print $9}&#8217; `<br />
fi</p>
<p>if [ "$TYPE" = "swap" ]; then<br />
SWAPFREE=`cat /proc/meminfo | grep &#8220;SwapFree&#8221; | sed &#8217;s/ //g&#8217; | cut -d &#8216;:&#8217; -f2 | cut -d &#8216;k&#8217; -f1`<br />
SWAPTOTAL=`cat /proc/meminfo | grep &#8220;SwapTotal&#8221; | sed &#8217;s/ //g&#8217; | cut -d &#8216;:&#8217; -f2 | cut -d &#8216;k&#8217; -f1`<br />
SWAPUSED=`expr $SWAPTOTAL &#8211; $SWAPFREE`<br />
INDATA=$SWAPFREE<br />
OUTDATA=$SWAPUSED<br />
fi</p>
<p>if [ "$TYPE" = "uptime" ]; then<br />
INDATA=`cat /proc/uptime |  cut -d &#8216; &#8216; -f1`<br />
OUTDATA=`cat /proc/uptime | cut -d &#8216; &#8216; -f2`<br />
fi</p>
<p>if [ "$TYPE" = "tcp" ]; then<br />
INDATA=`netstat -an | grep -c ESTABLISHED`<br />
OUTDATA=$INDATA<br />
fi</p>
<p>if [ "$TYPE" = "memory" ]; then<br />
INDATA=`free -bt | grep buffers\/cache | awk &#8216;{print $3}&#8217;`<br />
OUTDATA=`free -bt | grep buffers\/cache | awk &#8216;{print $4}&#8217;`<br />
fi</p>
<p>echo $INDATA<br />
echo $OUTDATA<br />
echo `uptime | cut -d&#8221;,&#8221; -f1,2`<br />
echo $TYPE</p>
<p>###End of system script####</p>
<p><i><b>(3.) Save the script and exit from your editor.</b></i></p>
<p align="center">&nbsp;</p>
<p align="center"><b>The mrtg.cfg file</b></p>
<p>Next we will create the configuration file called <b>mrtg.cfg</b></p>
<p><i><b>(1.) Create the necessary Apache and MRTG directories  </b></i></p>
<p><i><b>mkdir  -p /usr/local/mrtg-2/system/</b></i></p>
<p><i><b>mkdir -p /usr/local/httpd/htdocs/mrtg/status </b></i></p>
<p><i><b>(2.) vi /usr/local/mrtg-2/system/mrtg.cfg</b></i></p>
<p>#Copy and paste the following:</p>
<p>WorkDir: /usr/local/httpd/htdocs/mrtg/status</p>
<p>#RunAsDaemon:Yes</p>
<p>Interval:5</p>
<p>Options[_]: nopercent,growright,noinfo,gauge</p>
<p>MaxBytes[_]: 125000000</p>
<p>Xsize[_]: 600<br />
Ysize[_]: 200<br />
Ytics[_]: 10</p>
<p>###############################################################################<br />
#<br />
# HTML formatting stuff<br />
#<br />
###############################################################################</p>
<p>PageTop[^]: &lt;table cellspacing=&#8221;0&#8243; cellpadding=&#8221;10&#8243; border=&#8221;0&#8243; width=&#8221;100%&#8221; align=&#8221;center&#8221;&gt;&lt;tr&gt;&lt;td width=&#8221;185&#8243; valign=&#8221;top&#8221; c lass=&#8221;small&#8221;&gt;&lt;table cellspacing=&#8221;0&#8243; cellpadding=&#8221;5&#8243; border=&#8221;0&#8243; width=&#8221;100%&#8221;&gt;&lt;tr&gt;&lt;td class=&#8221;tableh&#8221;&gt;Network&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td c lass=&#8221;tablesh&#8221;&gt;&lt;a href=&#8221;index.html&#8221;&gt;- Traffic&lt;/a&gt;&lt;br&gt;&lt;a href=&#8221;tcp.html&#8221;&gt;- Open Connections&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&#8221;tableh&#8221;&gt;System Stats&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&#8221;tablesh&#8221;&gt;&lt;a href=&#8221;load.html&#8221;&gt;- Load Averages&lt;/a&gt;&lt;br&gt;&lt;a href=&#8221;swap.html&#8221;&gt;- Swap Memory&lt;/a&gt;&lt;br&gt;&lt;a href=&#8221;processes.html&#8221;&gt;- Processes&lt;/a&gt;&lt;br&gt;&lt;a href=&#8221;uptime.html&#8221;&gt;- Uptime and Idle Time&lt;/a&gt;&lt;br&gt;&lt;a href=&#8221;cpu.html&#8221;&gt;- CPU&lt;/a&gt;&lt;br&gt;&lt;a href=&#8221;memory.html&#8221;&gt;- Memory Usage&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;td&gt;</p>
<p>PageFoot[^]: &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</p>
<p>AddHead[^]: &lt;meta http-equiv=&#8217;Expires&#8217; content=&#8217;-1&#8242;&gt;&lt;style&gt;&lt;!&#8211; body { text-align: center; background-color: #CCCCCC; font-size: 10pt; font-family: arial, verdana; } th, td { font-size: 10pt; font-family: arial, verdana; } h3 { font-size: 12pt; font-family: arial, verdana; font-weight: bold; } .small { font-size: 8pt; font-family: arial, verdana; } .tableh { font-size: 10pt; font-family: arial, verdana; color: white; background-color: black; font-weight: bold; } .tablesh { font-size: 10pt; font-family: arial, verdana; color: black; background-color: #999999; font-weight: normal; } a:visited, a:active, a:link { text-decoration: none; font-weight: normal; font-family: arial, verdana; color: black; } a:hover { font-weight: normal; font-family: arial, verdana; background-color: #999999; color: white; } &#8211;&gt;&lt;/style&gt;</p>
<p>###############################################################################<br />
#<br />
# Stats<br />
#<br />
###############################################################################<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
# Network<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Target[index]: `/usr/local/mrtg-2/scripts/system network eth0`<br />
Options[index]: nopercent, noinfo<br />
Title[index]: Traffic Analysis for eth0<br />
PageTop[index]: &lt;h3&gt;Traffic Analysis for eth0&lt;/h3&gt;</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
# TCP Connections<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Target[tcp]: `/usr/local/mrtg-2/scripts/system tcp`<br />
Title[tcp]: Established TCP Connections<br />
PageTop[tcp]: &lt;h3&gt;Established TCP Connections&lt;/h3&gt;<br />
YLegend[tcp]: Connections<br />
ShortLegend[tcp]:<br />
LegendI[tcp]:<br />
LegendO[tcp]: Established</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
# Load<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Target[load]: `/usr/local/mrtg-2/scripts/system load`<br />
Options[load]: gauge, nopercent, noinfo<br />
MaxBytes[load]: 3000</p>
<p>Title[load]: Load Averages<br />
PageTop[load]: &lt;h3&gt;Load Averages&lt;/h3&gt;</p>
<p>YLegend[load]: Load (10E-2)<br />
ShortLegend[load]: (10E-2)<br />
LegendI[load]: 5-minute stagger<br />
LegendO[load]: 15-mintute stagger<br />
Legend1[load]: Load Average over last 5 minutes<br />
Legend2[load]: Load Average over last 15 minutes<br />
Legend3[load]: Average over last 5 minutes<br />
Legend4[load]: Average over last 15 minutes</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
# Swap<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Target[swap]: `/usr/local/mrtg-2/scripts/system swap`</p>
<p>Title[swap]: Swap Memory Usage</p>
<p>PageTop[swap]: &lt;h3&gt;Swap Memory Usage&lt;/h3&gt;</p>
<p>YLegend[swap]: Swap Usage</p>
<p>ShortLegend[swap]:</p>
<p>LegendI[swap]:</p>
<p>LegendO[swap]: Used</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
# Processes<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Target[processes]: `/usr/local/mrtg-2/scripts/system processes`<br />
Title[processes]: Processes<br />
PageTop[processes]: &lt;h3&gt;Processes&lt;/h3&gt;<br />
YLegend[processes]: Processes<br />
ShortLegend[processes]:<br />
LegendI[processes]: Total<br />
LegendO[processes]: Running</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
# Uptime<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Target[uptime]: `/usr/local/mrtg-2/scripts/system uptime`</p>
<p>Title[uptime]: Uptime and Idle Time</p>
<p>PageTop[uptime]: &lt;h3&gt;Uptime and Idle Time&lt;/h3&gt;</p>
<p>YLegend[uptime]: Uptime (sec)</p>
<p>ShortLegend[uptime]:</p>
<p>LegendI[uptime]: Total Uptime</p>
<p>LegendO[uptime]: Idle Time</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
# CPU<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Target[cpu]: `/usr/bin/awk &#8216;/cpu /{print $2+$3; print $2+$3+$4; print &#8220;quite some time&#8221;; print &#8220;domain.com&#8221;}&#8217;&lt;/proc/stat`</p>
<p>Title[cpu]: CPU Usage</p>
<p>PageTop[cpu]: &lt;H3&gt;CPU Usage&lt;/h3&gt;</p>
<p>MaxBytes[cpu]: 100</p>
<p>Options[cpu]: nopercent,growright,noinfo,bits</p>
<p>LegendI[cpu]:  user:</p>
<p>LegendO[cpu]:  total:</p>
<p>Ylegend[cpu]: %CPU</p>
<p>ShortLegend[cpu]: %CPU</p>
<p>Legend1[cpu]: Time spent in user mode</p>
<p>Legend2[cpu]: Time spent in user mode + time spent in system mode</p>
<p>Legend3[cpu]: Maximum occurance of time spent in user mode</p>
<p>Legend4[cpu]: Maximum occurance of (time spent in user mode + time spent in system mode)</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
# Memory<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Target[memory]: `/usr/local/mrtg-2/scripts/system memory`<br />
Options[memory]: gauge, noinfo<br />
MaxBytes[memory]: 665536000</p>
<p>Title[memory]: Memory Utilization<br />
PageTop[memory]: &lt;H3&gt;Memory Utilization&lt;/H3&gt;</p>
<p>YLegend[memory]: Bytes<br />
ShortLegend[memory]: B<br />
LegendI[memory]: Used:<br />
LegendO[memory]: Buffers + Cache:<br />
Legend1[memory]: Free real memory<br />
Legend2[memory]: Free swap memory<br />
Legend3[memory]: Maximal 5 Minute Memory In Use<br />
Legend4[memory]: Maximal 5 Minute Active Memory</p>
<p><i><b>(3.) Save the file and exit.</b></i></p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><b>Run the  MRTG tool to generate your graphs</b></p>
<p>Next we need to run mrtg using the above configuration file to generate our graphs.</p>
<p><i><b>(1.) Run the command below three (3) times.</b>  </i></p>
<p><i>env LANG=C </i><i>/usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/system/mrtg.cfg </i></p>
<p><i><b>(2.) We will need to generate the MRTG graphs automatically every 5 minutes, so we have to add an entry in the cron table.</b></i></p>
<p><i><b>vi  /etc/crontab</b></i></p>
<p>#Copy and paste the following</p>
<p>*/5 * * * * root <i>env LANG=C </i><i>/usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/system/mrtg.cfg   2&gt;&amp;1 /dev/null<br />
</i></p>
<p>Well that&#8217;s it! Fire your web browser and enter something like the following in your URL:</p>
<p><i><b>localhost/mrtg/status </b></i></p>
<p>or</p>
<p><b><i>192.168.0.1/</i><i>mrtg/status  </i></b></p>
<p>Your graphs will be generate every 5 minutes and will look something like the following after sometime.</p>
<p><img src="http://farm3.static.flickr.com/2258/2225049747_4030b229b3.jpg?v=0" alt="mrtg server eth0 traffic" height="375" width="500" /></p>
<p><img src="http://farm3.static.flickr.com/2285/2225049961_586cf5e71c.jpg?v=0" alt="mrtg server load" height="375" width="500" /></p>
<p><img src="http://farm3.static.flickr.com/2144/2225840986_a19b1807f1.jpg?v=0" alt="mrtg server memory" height="375" width="500" /></p>
<p>Well we will move on to more advanced topics like monitoring <b>Cisco routers </b>and <b>switches</b>, <b>Squid</b>, <b>Apache</b>, <b>Bind, Qmail, IPTABLES </b>using <b>SNMP </b>and <b>shell/perl</b> scripts in our next series of articles covering <b>MRTG</b>. Till then, enjoy your server monitoring with <b>MRTG</b>!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/teklimbu.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/teklimbu.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/teklimbu.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/teklimbu.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/teklimbu.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/teklimbu.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/teklimbu.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/teklimbu.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/teklimbu.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/teklimbu.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/teklimbu.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/teklimbu.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=22&subd=teklimbu&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://teklimbu.wordpress.com/2008/01/28/server-and-network-monitoring-using-mrtg-part-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dac1f65f8303afbf89a5d1d2c98c8e8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">teklimbu</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2258/2225049747_4030b229b3.jpg?v=0" medium="image">
			<media:title type="html">mrtg server eth0 traffic</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2285/2225049961_586cf5e71c.jpg?v=0" medium="image">
			<media:title type="html">mrtg server load</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2144/2225840986_a19b1807f1.jpg?v=0" medium="image">
			<media:title type="html">mrtg server memory</media:title>
		</media:content>
	</item>
		<item>
		<title>Effective User management under Linux/Unix</title>
		<link>http://teklimbu.wordpress.com/2008/01/20/effective-user-management-under-linuxunix/</link>
		<comments>http://teklimbu.wordpress.com/2008/01/20/effective-user-management-under-linuxunix/#comments</comments>
		<pubDate>Sun, 20 Jan 2008 17:52:56 +0000</pubDate>
		<dc:creator>teklimbu</dc:creator>
				<category><![CDATA[freebsd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[blowfish]]></category>
		<category><![CDATA[des]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[passwd]]></category>
		<category><![CDATA[user management]]></category>

		<guid isPermaLink="false">http://teklimbu.wordpress.com/2008/01/20/effective-user-management-under-linuxunix/</guid>
		<description><![CDATA[
In this article, we look into the topic of managing our users on our local Linux/Unix box. As we know it, Linux/Unix is a multiuser environment, therefore, one of the main tasks of a system administrator is to create user accounts and provide a secure environment for users to do their work in.
Adding and removing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=21&subd=teklimbu&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Flinux_unix%2FEffective_User_management_under_Linux_Unix' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
<p>In this article, we look into the topic of managing our users on our local Linux/Unix box. As we know it, Linux/Unix <span>is a multiuser environment, therefore, one of the main tasks of a system administrator is to create user accounts and provide a secure environment for users to do their work in.</span></p>
<p>Adding and removing users is still one of the most important task of a system administrator. Therefore, we as system administrators need a good understanding of how the Linux/Unix accounting system works in order to provide good network services to our users and clients.</p>
<p>Good account management is also the key determinant to system security. Infrequently used accounts are prime targets for crackers. So are accounts with weak passwords.</p>
<p><span id="more-21"></span></p>
<p>Adding new users to your system involves a lot of processes running in the background. Several databases are updated, a local mail directory is created. So is the user&#8217;s home directory.  You supply some deal of information including a <i>username </i>and <i>password. </i></p>
<p align="center">&nbsp;</p>
<p align="center"><b>The </b><b>/ETC/PASSWD FILE</b></p>
<p align="left">Below is a listing of some contents inside the <b>/etc/passwd</b> file.</p>
<p align="left"><i><b>11:42:43 tek@gw-tek-sp:~$ cat /etc/passwd</b></i></p>
<p><b>root:x:0:0:root:/root:/bin/bash<br />
nobody:x:99:99:Nobody:/:/sbin/nologin<br />
tek:x:506:506: Tek Limbu:/home/tek:/bin/bash<br />
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin<br />
rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin<br />
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin<br />
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin</b></p>
<p>The <b>/etc/passwd </b>file contains a list of users recognized by the system. The system consults this file at login time to determine a user&#8217;s <b>UID</b> and to verify the user&#8217;s <b>password</b>. Each line in the file represents one user and contains <b>seven (7) </b>fields separated by colons:</p>
<ol>
<li>Login name</li>
<li>Encrypted password (unless a shadow password file is used)</li>
<li>UID number</li>
<li>Default GID number</li>
<li>&#8220;Various&#8221; information, full name, phone number, etc</li>
<li>Home directory</li>
<li>Login shell</li>
</ol>
<p>As computing processing power has become faster, it has become very dangerous to leave encrypted password in a world readable plain text file. For this reason, most Linux/Unix distributions allows us to hide the encrypted passwords by placing them in a separate file which is not world-readable. The file is called the <b>shadow </b>file and can be found in <b>/etc/shadow.</b></p>
<p><i><b>19:03:55 root@gw-tek-sp:~$ ls -l /etc/shadow</b></i></p>
<p><i><b><br />
-r&#8212;&#8212;&#8211;  1 root root 1981 Jan  8 22:55 /etc/shadow</b></i></p>
<p>If we look at the <b>/etc/shadow </b>file with the <b><i>ls -l </i></b>command, we see that it&#8217;s has a very restricted set of permissions. Only the <b>SUPERUSER </b>or <b>root </b>has permissions to access it and even for the <b>root </b>user, those are read-only permissions. Other users can&#8217;t even touch or see the file!</p>
<p><i><b>(1.) Login name</b></i></p>
<p>The 1st field on the <b>/etc/passwd</b> file<b> </b>consists of the <b>login name.</b> As shown below, the 1st field represents the user called &#8220;<b>tek</b>&#8220;.</p>
<p><b> tek:x:506:506: Tek Limbu:/home/tek:/bin/bash</b></p>
<p>Also known as <b><i>usernames</i></b>, login names must be unique and no more than 32 characters in length. But who needs a login name more than 32 characters long!<br />
With the exception of the &#8220;colons&#8221; and &#8220;newlines&#8221;, they may contain any other characters. Very old versions of UNIX limit the permissible characters in a username to be only of 8 characters in length.  But these are getting very rare these days.</p>
<p><i><b>(2.) Encrypted password </b></i></p>
<p>The 2nd field in the <b>/etc/passwd </b>file consists of our username&#8217;s password in an encrypted form. But these days, on newer systems, the encrypted password is not kept on this world-readable file any longer due to security reasons. Therefore, they are kept in the <i><b>/etc/shadow </b></i>file who has a very restrictive permission set and is not world-readable.</p>
<p>Let&#8217;s look at the example shown below:</p>
<p><b> tek:x:506:506: Tek Limbu:/home/tek:/bin/bash</b></p>
<p>As you can see, there is an <b>&#8220;x&#8221;</b> representing the encrypted password. Why? That&#8217;s because this system is using the more secure <b>/etc/shadow </b>file to store encrypted passwords.</p>
<p>Password encryption  are based either on the <b>DES </b>or <b>MD5 </b>secure hashing algorithm. <b>DES</b>, the Data Encryption Standard is a <b>cipher</b> which is an algorithm for performing encryption and decryption.</p>
<p>The operation of a cipher usually depends on a piece of auxiliary information, called a <b>key</b>. This <b>key</b> is a piece of information that controls the operation of a cryptographic algorithm.</p>
<p><b>DES</b> was created in 1976, and is consisted of 56-bit keys which has since been subsequently enjoyed widespread use internationally.</p>
<p><b>DES </b>is now considered to be insecure for many applications which is mainly due to it&#8217;s 56-bit key size being too small. Today&#8217;s processing power can easily decrypt a <b>DES </b>encrypted password. One major disadvantage of using <b>DES </b>encryption is that it limits the password length to be just <b>8 </b>characters in length! Even though your password may consist of <b>15 </b>characters, only the first <b>8 </b>characters are significant with the remaining characters being ignored silently.</p>
<p>Luckily, almost all major Linux/Unix distributions these days deploy the <b>MD5 </b>secure hashing algorithm  with a 128-bit hash value. Hence<b> MD5</b> are much secure in comparison to  <b>DES</b>. This is primarily due to <b>MD5&#8217;s </b>larger 128-bit hash length. However, even <b>MD5 </b>have their own disadvantages!</p>
<p>If you are really paranoid about password security and encryption, I recommend you to read about the <b>Blowfish </b>hash algorithm or <b>Advanced Encryption Standard</b> (<b>AES</b>).</p>
<p><b>(3.) UID number</b></p>
<p>The user ID (or UID) is a unique number that differentiates a user from any other user on a given system. This is the 3rd field represented in <b>/etc/passwd </b>file<b>.</b> Users need to have a way to identify themselves for the purposes of accounting, security, logging and resource management on a system. Therefore, every user on the system must have a User ID (<b>UID</b>).</p>
<p>Let&#8217;s look again at the example for the <i>username &#8220;tek&#8221; as </i>shown below:</p>
<p><b> tek:x:506:506: Tek Limbu:/home/tek:/bin/bash</b></p>
<p>As can be seen above,  the  <b>Username </b><i><b>&#8220;tek&#8221;</b></i> has a <b>UID </b>of <b>506</b> and a Group ID (<b>GID</b>) of <b>506. </b>We will discuss the <b>GID </b>in more detail in the next section.</p>
<p>The UID and GID are often automatically assigned in sequence by the account creation program. So, the user added after <b>“tek” </b>would have a <b>UID </b>of <b>507</b>. Some Linux distributions assign all users to a specific group called <b>“user”</b>. Others, like <i><b>Red Hat</b></i> or <i><b>Centos</b></i>, typically assign users to their own unique group, which means the <b>UID </b>and <b>GID </b>are usually identical.</p>
<p>The range of values for a <b>UID </b>varies amongst different systems; at the very least, a <b>UID </b>can be between <b>0</b> and <b>65535</b>, with some restrictions:</p>
<ul>
<li>The Superuser must always have a UID of zero (0).</li>
<li>The user &#8220;nobody&#8221; was traditionally assigned the largest possible UID (as the opposite of the Superuser). More recently, the user is assigned a UID in the system range (1–100, see below) or between 65530–65535.</li>
<li>UIDs from 1 to 100 are otherwise reserved for system use by convention; some manuals recommend that UIDs from 101 to 499 (RedHat) , 501 to 600 (Centos) or even 999 (Debian) be reserved as well.</li>
</ul>
<p>The <b>UID </b>value references users in the <b><i>/etc/passwd</i> </b>file. <b>Shadow </b>password files and <b>Network Information Service</b> <b>(NIS)</b> also refer to numeric <b>UIDs</b>. The user identifier is a necessary component of Unix file systems and processes. Some operating systems might have support for <b>16-bit UIDs</b>, making <b>65536 </b>unique IDs possible, though a modern system with <b>32-bit UIDs</b> will potentially make <b>4,294,967,296 </b>distinct values available.</p>
<p><i><b>(4.)  Default GID number</b></i></p>
<p>The <b>4th </b>field called the <b>group identifier</b>, often abbreviated to <b>GID</b>, is a numeric value used to represent a specific group. The range of values for a <b>GID </b>varies amongst different systems; at the very least, a <b>GID </b>can be between <b>0 </b>and <b>65535</b>, with one restriction: the login group for the <b>Superuser </b>must have <b>GID 0</b>.</p>
<p>This numeric value is used to refer to groups in the <b><code>/etc/passwd</code></b> and <b><code><span class="new">/etc/group</span></code></b> files or their equivalents. <b>Shadow </b>password files and <b><code>Network Information Service (NIS)</code></b> also refer to numeric <b>GIDs</b>. The group identifier is a necessary component of Linux/Unix file systems and processes.</p>
<p>The limits on the range of possible group identifiers come from the memory space used to store them. Originally, a signed <b>16-bit</b> integer was used. Realizing that sign was not necessary—negative numbers don&#8217;t make valid group IDs—an unsigned integer was used instead, allowing group IDs between <b>0</b> and <b>65535</b>. Modern operating systems usually use unsigned <b>32-bit</b> integers, which allow for group IDs between <b>0</b> and <b>4294967295</b>.</p>
<p>The switch from <b>16</b> to <b>32 </b>bits was originally not necessary—one machine or even one network did not serve more than <b>65536 </b>users at the time—but was made to eliminate the need to do so in the future, when it would be more difficult to implement. Remember the history of <b>IPv4 </b>where we thought that <b>4 billion</b> IP addresses would have been enough? Well that was not the case, so the Internet world is heavily developing on <b>IPv6</b>.</p>
<p>As mentioned on this article, Linux/Unix is a multiple user operating system. Every time a new user is created, a <b>UID </b>for this user is created. In addition, a Group ID (<b>GID</b>), for this user is also created.</p>
<p>Therefore, in a system having multiple users, these users can be categorized into <b><i>groups</i>.</b> In case you may not know, conventional Linux/Unix file system permissions are organized into three classes, <b><i>user</i>, <i>group</i>, </b>and <b><i>others</i>.</b></p>
<p><i><b>(5.) &#8220;GECOS&#8221; information, full name, phone number, etc</b></i></p>
<p>The 5th field is commonly used to store personal information about each user in the system. It does not have a well defined syntax. Interestingly, this field is also known as <b>GECOS</b>. According to the authors of <b>www.admin.com</b>, the <b>GECOS </b>field originally held the login information needed to transfer batch jobs from <b>UNIX systems at Bell Labs</b> to a mainframe running <b>GECOS (the General Electric Comprehensive Operating System)!</b></p>
<p>We can use any methods for storing user&#8217;s data on this field but the program called <b>finger </b>interprets comma-separated GECOS entries in the following order:</p>
<ul>
<li>Full Name (Often the only field used)</li>
<li>Office number and building</li>
<li>Office telephone extension</li>
<li>Home phone number</li>
</ul>
<p>If I run the <b>finger </b>program for <i>username &#8220;tek&#8221;, </i>I get the following information:</p>
<p><i><b>23:40:39 tek@gw-tek-sp:~$  finger tek</b></i></p>
<p><i><b><br />
Login: tek                              Name: Tek Limbu<br />
Directory: /home/tek                    Shell: /bin/bash<br />
On since Thu Jan 17 23:38 (NPT) on pts/0 from 192.168.6.10<br />
No mail.</b><b><br />
No Plan.</b></i></p>
<p>If users of the system wants to change their GECOS information, they can use the command called <b>chfn</b>.  Let&#8217;s take an example as shown below:</p>
<p><i><b>23:40:49 tek@gw-tek-sp:~$  chfn tek</b></i></p>
<p><i><b><br />
Changing finger information for tek.<br />
Password:<br />
Name [Tek Limbu]: Tek Bahadur Limbu<br />
Office []: Wlink HQ<br />
Office Phone []: 977-1-5555555<br />
Home Phone []: 977-1-4444444</b></i></p>
<p><i><b>Finger information changed.</b></i></p>
<p>As can be seen above, we have changed and added new entries. Now if I run the <b>finger </b>program for <b>username </b><i>tek</i>, I get the following:</p>
<p><i><b>23:45:25 tek@gw-tek-sp:~$ finger tek</b></i></p>
<p><i><b><br />
Login: tek                              Name: Tek Bahadur Limbu<br />
Directory: /home/tek                    Shell: /bin/bash<br />
Office: Wlink HQ, 977-1-5555555         Home Phone: 977-1-4444444<br />
On since Thu Jan 17 23:38 (NPT) on pts/0 from 192.168.6.10<br />
No mail.<br />
No Plan.</b></i></p>
<p><i><b></b></i><br />
But it can sometimes be a nuisance for system administrators if users keep on changing their <b>GECOS </b>information containing some weird words on a daily basis! So in the best interest of everybody,  it is often useful to disable this <b>chfn </b>command completely from the system.</p>
<p><b>23:49:48 root@gw-tek-sp:~$ chmod a-x /usr/bin/chfn  </b></p>
<p>This way, users on your system won&#8217;t be able to update their information any longer! Well it is up to the system administrator to decide if they want to disable the <b>chfn </b>command.</p>
<p><b><i>(6.) Home directory</i></b></p>
<p>Normal users usually get a <b><i>home directory</i></b> when their accounts get created.  User&#8217;s shells are <b>cd</b>&#8216;d to their home directories when they log in to the system. If a user&#8217;s home directory is missing at login time for some reasons, the system will print a message something like the one below:</p>
<p><i><code><b> warning: cannot change directory to : No such file or directory</b></code></i></p>
<p>Linux/Unix systems generally allow the login to proceed and put the user in the root directory <b>(/root)</b>.</p>
<p><i><b>(7.)  Login shell</b></i></p>
<p>The login shell is usually a command interpreter such as the Bourne Shell <b>(Bash)</b> or the <b>C </b>shell <b>(/bin/csh or /bin/sh)</b>. The <b>Bash </b>shell is the default shell used in <b>Linux </b>if <b>/etc/passwd</b> does not specify any specific login shell. But on <b>FreeBSD </b>or <b>Solaris </b>systems, the default shell is usually the <b>C shell </b>(<b>/bin/csh</b>).</p>
<p>On <b>Linux </b>systems, the <b>C </b>shell <b>(/bin/sh)</b> is a actually just a symbolic link to the <b>Bash </b>shell <b>(/bin/bash).</b></p>
<p>For a complete list of shells available on your system, check out the file <b>/etc/shells.</b></p>
<p>For example, it might look something like the following:</p>
<p><i><b>00:27:37 root@gw-tek-sp:~$ cat /etc/shells<br />
</b></i></p>
<p><i><b>/bin/sh<br />
/bin/bash<br />
/sbin/nologin<br />
/bin/ash<br />
/bin/bsh<br />
/bin/ksh<br />
/usr/bin/ksh<br />
/usr/bin/pdksh<br />
/bin/tcsh<br />
/bin/csh<br />
/bin/zsh</b></i></p>
<p align="center">&nbsp;</p>
<p align="center"><b>The /ETC/SHADOW FILE</b></p>
<p align="center">&nbsp;</p>
<p align="left">As said on the preceding paragraphs, the primarily use of the <b>/etc/shadow </b>file is for security reasons. This fact is due to the <b>shadow </b>file being readable only by the <b>SUPERUSER </b>and simply can&#8217;t be accessed in any way by normal users.</p>
<p align="left">When <b>shadow </b>passwords are in use, the password field in the <b>/etc/passwd </b>file is represented by or contains the character &#8220;<b>x</b>&#8220;. We should maintain both the <b>shadow </b>and <b>passwd </b>files simultaneously. However, thanks to tools like <b>&#8220;useradd&#8221;</b>, it is possible to maintain both of them using a single tool.</p>
<p align="left">A sample entry from an <b>/etc/shadow </b>file may look something like the following:</p>
<p align="left"><i><b> tek:$1$xXiCmk/P$3oTnfjo1ZtCOtxy1jcSTD/:13156:0:99999:7:::</b></i></p>
<p align="left">One thing to note is that the <b>shadow </b>file is not a superset of the <b>passwd</b> file. One should use a tool such as <b>useradd </b>which will maintain both files for you automatically. Similar to the <b>/etc/passwd </b>file where each line contains <b>seven (7)</b> fields, each line in the <b>/etc/shadow</b> file contains <b>nine (9) </b>fields.</p>
<p align="left">Each line in the <b>shadow </b>file are separated by colons in the following way:</p>
<ul>
<li>Login name</li>
<li>Encrypted password</li>
<li>Date of last password change</li>
<li>Minimum days between password changes</li>
<li>Maximum days between password changes</li>
<li>Number of days to warn users before password expiration</li>
<li>Number of days after password expiration that the account is disabled</li>
<li>Account expiration date</li>
<li>A reserved unused field</li>
</ul>
<p align="left">&nbsp;</p>
<p align="center"><b>The </b><b>/etc/group File</b></p>
<p align="left">In a similar way as there is an <b>/etc/passwd </b>file, there is an <b>/etc/group</b> file. This is the file which lists all the available groups on your system.</p>
<p align="left">Looking at the line for <i>user <b>&#8220;tek&#8221; </b></i>in <b>/etc/passwd</b> will reveal:</p>
<p align="left"><b> tek:x:506:506: Tek Limbu:/home/tek:/bin/bash</b></p>
<p align="left">Here, we see the <i>username </i><b>&#8220;tek&#8221;</b> has a Group ID (<b>GID</b>) of <b>506</b>. If we look at the contents of the file <b>/etc/group</b>, we might see something like the following:</p>
<p align="left"><i><b>wheel:x:10:root,tek<br />
staff:x:23:tek,emi,john,anuj,sony<br />
squid:x:24:tek,john,anuj<br />
tek:x:506:</b></i>
</p>
<p align="left">Each line represents one group and contains four fields:</p>
<ul>
<li>Group name</li>
<li>Encrypted password (rarely used!)</li>
<li>GID number</li>
<li>List of members</li>
</ul>
<p align="left">We see from the above information that the user <b><i>&#8220;tek&#8221; </i></b>has an individual <b>GID </b>of <b>506</b>. Additionally, the user also belongs to the groups called <b>&#8220;wheel&#8221;</b>, <b>&#8220;staff&#8221;</b> and <b>&#8220;squid&#8221;</b>.</p>
<p> One use for groups is with project or departmental teams who may require access to the same set of materials, such as project guidelines, data, and documents. Creating either a separate partition or a section in the main file system for all of these team files to reside on reduces the need for excessive use of symbolic links between user directories. Set the permissions appropriately such that group members can enter and work.</p>
<p>Another nice use for groups is to even use them to restrict access. If you have a set of people who just simply should not have access to a specific file or directory, then you can put them into a group and then deny access to that group for the file or directory while giving access to the owner and to the rest of the ‘world’.</p>
<p>Let&#8217;s look at an example. Suppose we have a <b>Squid proxy </b>server. Suppose it&#8217;s main configuration and bin files reside in the directory called <b>/etc/squid.</b></p>
<p>Now let&#8217;s change the permission of the of the directory <b>/etc/squid </b>to <i>user <b>squid </b></i>and <i>group <b>squid.</b></i></p>
<p><i><b>16:05:20 root@gw-tek-sp:~$ chown -R squid:squid /etc/squid/</b></i></p>
<p><i><b>16:05:22 root@gw-tek-sp:~$ cd /etc/squid</b></i></p>
<p><i><b>16:13:28 root@gw-tek-sp:/etc/squid$ chmod u=rwx,g=rwx,o= *</b></i></p>
<p align="left">&nbsp;</p>
<p>What the above commands do is that it will allow the <i>user <b>squid </b></i>and any other users belonging to <i>group</i> <i><b>squid </b></i>to read,write, and execute the contents of the directory <b>/etc/squid/.</b> However, every other users and groups will be denied permission to the directory <b>/etc/squid/.</b></p>
<p><b><br />
</b>How do we exactly add users in our Linux/Unix machine?</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><b>ADDING USERS</b></p>
<p align="left">Technically speaking, the process of adding users on your system consists of the following steps:</p>
<ol>
<li>Edit the <b>/etc/passwd</b> and <b>/etc/shadow</b> files to define the user&#8217;s account</li>
<li>Set an initial password for the new user</li>
<li>Create, <b>chown</b>, and <b>chmod</b> the user&#8217;s home directory</li>
</ol>
<p align="left">&nbsp;</p>
<p><b></b></p>
<p>The command called <b>useradd</b> can automate this process for you to some extent. However, for the purposes of practice and demonstration, we will add a user called &#8220;<i>john&#8221; </i>manually executing one step at a time.</p>
<p><i><b>Editing the </b><b>passwd and </b><b>shadow files</b></i></p>
<p>To safely edit the <b>/etc/passwd </b>file, we use the universal command called <b>vipw</b> to invoke our choice of text editor (probably <b>vi</b>) on a copy of the file. The existence of the temporary edit file serves as a lock; <b>vipw </b>allows only one person to edit the <b>/etc/passwd </b>file at a time, and thus prevents users from changing their passwords while the <b>/etc/passwd </b>file is being edited.</p>
<p>When the text editor terminates the editing work on the <b>/etc/passwd</b> file, <b>vipw </b>replaces the original <b>passwd</b> file with your edited copy.</p>
<p>Now moving on to the example of adding a <i>user </i>called <i>&#8220;john&#8221;, </i>we invoke the <b>vipw </b>command as user <b>root.</b></p>
<p><b><i>18:26:24 root@gw-tek-sp:#  vipw</i></b></p>
<p>Then we will add the following entry to the <b>/etc/passwd </b>file:</p>
<p><i><b>john:x:525:10:John Shrestha, Sys Dep, 555:/home/john:/bin/bash</b></i></p>
<p>We then adding a matching entry to <b>/etc/shadow</b> by running the following command:</p>
<p><i><b>18:35:03 root@gw-tek-sp:~$ vipw -s</b></i></p>
<p>john:*::::::::</p>
<p>This will cause the <i>user </i><b>john  </b>not to have current entry for an encrypted password and sets the account to never expire.</p>
<p align="left"><b>Setting an initial password for <i>user </i></b><b>john</b></p>
<p>The above commands and entries will not generate a password for the <i>user </i><b>john. </b>However the user <b>root </b>can change and reset any user&#8217;s password with the <b>passwd</b> command as shown below:</p>
<p><i><b>19:36:02 root@gw-tek-sp:~$ passwd john</b></i></p>
<p><i><b><br />
Changing password for user john.<br />
New UNIX password:<br />
Retype new UNIX password:<br />
passwd: all authentication tokens updated successfully.</b></i></p>
<p>By the way, never leave a new account or any account that has access to a shell &#8211;without a password.</p>
<p><b>Creating the user&#8217;s home directory</b></p>
<p>After setting an initial password and adding the relevant entries for <i>user </i><b>john </b>in <b>/etc/passwd </b>and <b>/etc/shadow</b>, we move on to create <i><b>john&#8217;s </b></i>home directory.</p>
<p><i><b>19:53:23 root@gw-tek-sp:~$ mkdir /home/john<br />
19:53:29 root@gw-tek-sp:~$ cp /etc/skel/.[a-zA-Z]* /home/john/<br />
19:53:31 root@gw-tek-sp:~$ chown john /home/john/<br />
19:53:37 root@gw-tek-sp:~$ chgrp wheel /home/john/<br />
19:53:43 root@gw-tek-sp:~$ chmod 700 /home/john/<br />
</b></i></p>
<p>We then copy the default start-up files and scripts from the <b>/etc/skel/</b> directory<b> </b>to the directory <b>/home/john/</b></p>
<p>The reason why we are using the <b>chown </b>and <b>chgrp </b>commands is to set <b>john&#8217;s </b>home directory to <i>user <b>john </b></i>and <i>group <b>wheel</b></i> is because any directories created by <i>user <b>root </b></i>will initially be own by <b>root.</b></p>
<p><b>chmod 700 </b>will cause <b><i>john&#8217;s </i></b>home directory be to accessible, readable and executable only by <i>user <b>john.</b> </i>Even the group members won&#8217;t have be able to access <b><i>john&#8217;s </i></b>home directory and the files residing beneath <i>john&#8217;s </i>home directory.</p>
<p align="center">&nbsp;</p>
<p align="center"><b>Copying in the default startup files and scripts</b></p>
<p>We can customize some commands and utilities by placing configuration files in a newly created user&#8217;s home directory. Most of these files begins with a initial dot <b>(.) </b>to elide these files.</p>
<p>The table below summarizes the widely used startup files for both Linux and Unix.</p>
<div style="text-align:center;"><img src="http://farm3.static.flickr.com/2068/2214088202_cbde84d263.jpg?v=0" alt="common-startup-files" height="375" width="500" /></div>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="left">The <b>useradd </b>command is normally the one you will use to create new users on your system. It will automatically create the relevant entries in <b>/etc/passwd </b>and <b>/etc/shadow</b> files.</p>
<p align="left">The syntax for the <b>useradd</b> command is illustrated below:</p>
<p align="left"><i>useradd -d home_directory  -e expire_date -g initial_group -p password login_name </i></p>
<p align="left">Therefore, to create a new <i>user </i>called <b>&#8220;john&#8221; </b>, put him in <i>groups <b>wheel</b></i> and <i><b>staff </b></i>and set his account to expire on <b>25-Dec-2008</b>, we would use the following command:</p>
<p align="left"><i><b>useradd  -d /home/john -e 2008-12-25</b></i><i><b> -g wheel -G staff -m -s /bin/bash john </b></i></p>
<p align="left"> The <b>-m</b> option specifies that if the home directory does not exist, it will be created and so will the files and directories contained in<b> /etc/skel</b> be copied to the <b>/home/john </b>directory. The <b>-s </b>parameter will assign the type of shell to the user. In this case, <i>user </i><b>john </b>will be given the <b>bash </b>shell.</p>
<p align="left">Since the <b>useradd </b>program will also take files from the directory called <b>/etc/skel</b> and copy these to the newly user&#8217;s home directory, therefore, any files that should be given to a new user – such as login files to set up environment variables – should be set up in that directory.</p>
<p align="left">You might want to customize your common startup scripts for new users under the directory <b>/etc/skel/</b></p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="center"><i><b>   REMOVING USERS</b></i></p>
<p align="left">Disabling a user&#8217;s account is simply a matter of editing the file <b>/etc/passwd</b> and removing the relevant user&#8217;s entry!</p>
<p align="left">The user will no longer be able to log in at all and will not be recognized as an existing user account. To fully remove the user from the system, we also have to remove the user from the <b>/etc/shadow </b>and <b>/etc/group </b>files. We then proceed to remove the user&#8217;s home, mail, and spool directories.</p>
<p align="left">However, for clarity and simplicity, we use the universal command called <b>userdel </b>to remove existing users from the system.</p>
<p align="left"><i><b>13:26:46 root@gw-tek-sp:$ userdel -r john</b></i></p>
<p align="left">The above example removes the <i>user </i>called <b>john</b> from the system. It removes <b>john&#8217;s</b> entry from the <b>/etc/passwd</b> and <b>/etc/shadow</b> files.</p>
<p align="left">The <b>&#8220;-r&#8221; </b>parameters removes the user&#8217;s home directory and any sub-directories and files beneath <b>john&#8217;s </b>home directory.</p>
<p align="left"> However, even after this, there may <i>still</i> be other files in the system that belong to the phantom <b>UID </b>once known as user <b>john</b>, such as e-mail in /var/mail or temporary files in /tmp. The userdel command won’t remove these or look for them.  We have to manually locate these files and inspect them and decide if we want to keep or delete them.</p>
<p align="left">&nbsp;</p>
<p align="center"><b>DISABLING LOGINS</b></p>
<p align="left">On some occasions, a user&#8217;s login must be temporarily disabled for various reasons. If your system is the only system on the network where users are allowed to login, then it is simply a matter of putting a <b>star (*)</b> in the encrypted password fields of the <b>/etc/passwd</b> and <b>/etc/shadow </b>files<b>.</b></p>
<p align="left">However if your server is centralized across the network, then users may still be able to login even if you have disabled the user from your system&#8217;s <b>/etc/passwd </b>and <b>/etc/shadow </b>files!</p>
<p align="left">So the best possible way to temporarily disable a user from your system is to replace the <i>user&#8217;s shell </i>with a <b>/sbin/nologin </b>shell or with a shell script which prints a message stating why the login has been disabled.</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><i><b>MODIFYING USER ACCOUNTS</b></i></p>
<p align="left">We can modify existing users information either by manually editing the <b>/etc/passwd </b>and <b>/etc/shadow </b>files or we can use the in-built tool called <b>usermod.</b></p>
<p align="left"><b> </b>Suppose we want to modify <i>user <b>john&#8217;s </b></i>home directory from <b>/home/john </b>to <b>/home/newjohn, </b>add <b>john </b>to the <i>groups <b>student </b></i>and <b><i>sysadm, </i></b>we would issue the following command:</p>
<p align="left"><b># usermod -d /home/newjohn -g student -G sysadm john</b></p>
<p align="left">&nbsp;</p>
<p align="left">The example above modifies <b>john&#8217;s </b>home to a new directory called <b>/home/newjohn</b> and adds <b>john </b>to both the <b>student </b>and <b>sysadm </b>groups.</p>
<p align="left">Well that&#8217;s it! I hope this article has given you enough hindsights to manage your local users of your system in an effective way. We will dive and discuss into advanced user management using the <code><b>Network Information Service </b></code><code><b> (NIS)</b></code> or <code><b>Open LDAP</b></code> for a centralized login and access control system in the future.</p>
<p align="left">Till then, happy user management on your Linux/Unix system!</p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/teklimbu.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/teklimbu.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/teklimbu.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/teklimbu.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/teklimbu.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/teklimbu.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/teklimbu.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/teklimbu.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/teklimbu.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/teklimbu.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/teklimbu.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/teklimbu.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=21&subd=teklimbu&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://teklimbu.wordpress.com/2008/01/20/effective-user-management-under-linuxunix/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dac1f65f8303afbf89a5d1d2c98c8e8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">teklimbu</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2068/2214088202_cbde84d263.jpg?v=0" medium="image">
			<media:title type="html">common-startup-files</media:title>
		</media:content>
	</item>
		<item>
		<title>System integrity using Files, Permissions, Processes, Root and Sudo</title>
		<link>http://teklimbu.wordpress.com/2008/01/06/files-permissions-processes-root-and-sudo/</link>
		<comments>http://teklimbu.wordpress.com/2008/01/06/files-permissions-processes-root-and-sudo/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 11:07:48 +0000</pubDate>
		<dc:creator>teklimbu</dc:creator>
				<category><![CDATA[freebsd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[sudo]]></category>
		<category><![CDATA[superuser]]></category>

		<guid isPermaLink="false">http://teklimbu.wordpress.com/2008/01/06/files-permissions-processes-root-and-sudo/</guid>
		<description><![CDATA[
To be a good in system administration, we have to understand the basics of files, processes and permissions of our Linux/Unix hosts. Therefore, in this article, we will cover the basic stuffs regarding files, processes, permissions, the SUPERUSER &#8220;root&#8221; account and the sudo program.
Every file and process on a Linux/Unix system is owned by a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=20&subd=teklimbu&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Flinux_unix%2FLinux_Unix_system_integrity_via_permissions_2' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
<p>To be a good in system administration, we have to understand the basics of files, processes and permissions of our Linux/Unix hosts. Therefore, in this article, we will cover the basic stuffs regarding files, processes, permissions, the SUPERUSER &#8220;<b>root</b>&#8221; account and the <b>sudo </b>program.</p>
<p>Every file and process on a Linux/Unix system is owned by a particular user account. Every file has both an <i>owner </i>and a <i>group owner</i>. What this means is that the owner of the file enjoys one <i>special </i><i>property</i> that is not shared with everyone on the system. This property is the ability to <i>modify </i>the permissions of the file.</p>
<p>Other users on the system can&#8217;t access files belonging to others without the owner&#8217;s permission, so this restriction helps protect a user&#8217;s files against &#8220;malicious&#8221; users!</p>
<p><span id="more-20"></span></p>
<p>Please note that all credits for this article goes to the authors of the book called &#8220;LINUX ADMINISTRATION HANDBOOK&#8221;. I recommend this book for all levels of system administrators. It can be accessed from the site <a href="http://www.admin.com" title="Linux Administration Handbook" target="_blank">http://www.admin.com</a></p>
<p>Having said that, although the owner of a file can always be a single person, many people can be group owners of the file if they are all part of a single Linux/Unix group. Groups are defined in the <b>/etc/group </b>file.</p>
<p>Ownerships of a file can be shown with the <b>ls  -l </b><i>filename </i>command as shown below:</p>
<p><i><b>-bash-3.00$  </b><b>ls -l /export/home/tek/records<br />
-rw-r&#8211;r&#8211;   1 tek      wheel        869 Jan  4 14:43 /export/home/tek/records</b></i></p>
<p>As seen above, the file named <i>records is owned </i>by the user &#8220;tek&#8221; and the group &#8220;wheel&#8221;.</p>
<p>Linux/Unix  in reality keeps track of owners and groups represented by numbers rather than as text names. User identification numbers (<b>UIDs</b>) are mapped to user names in the <b>/etc/passwd</b> file and Group identification numbers (<b>GIDs</b>) are mapped to group names in the <b>/etc/group</b> file.</p>
<p>The text names that corresponds to UIDs and GIDs are designed only for the convenience of the system&#8217;s human users! Next time a command such as <b>ls </b>are issued which displays ownership information, then the files <b>/etc/passwd </b>and <b>/etc/group </b>are queried.</p>
<p align="center"><b>Processes </b></p>
<p>A <b>process </b>is the term used by Linux/Unix to represent a running program through which the running program&#8217;s use of memory, processor time, and I/O resources can be managed.</p>
<p>Unlike files, processes have not two but four identities associated with them. They are a <i>real </i>and <i>effective </i><b>UID </b>and a <i>real </i>and <i>effective </i><b>GID</b>. The &#8220;<i>real</i>&#8221; numbers are used for <i>accounting </i>purposes, and the &#8220;<i>effective</i>&#8221; numbers are used for the determination of <i>access permissions</i>.</p>
<p>Superuser or root privilege UID (SUID)  is always equal to 0 (zero).</p>
<p>For example, the Real UID (RUID) is the UID of the process that created the process itself. It can be changed only if the running process has Effective UserID (EUID)=0.</p>
<p>The effective UID (EUID) is used to evaluate privileges of the process to perform a particular action. EUID can be changed either to Real UserID (RUID), or SUID if EUID is not equal to 0. If EUID=0, it can be changed to anything.</p>
<p>Most of the time, the real and effective numbers are the same.</p>
<p>The owner of a process can send the process signals such as <i>kill </i>and can also reduce the process scheduling priority.</p>
<p>Under normal circumstances, it is not possible for a process to change it&#8217;s 4 ownership credentials. There is a special situation in which the effective user (EUID) and group ID (EGID) can and needs to be changed.</p>
<p>When a command which has the &#8220;setuid&#8221; or &#8220;setgid&#8221; permissions is executed, the effective UID (EUID) or GID (EGID) of the resulting process can be set to the UID or GID of the file containing the program image rather than the UID or GID of the user executing the command.</p>
<p>For example, let us look at the program called &#8220;<b>passwd</b>&#8220;.</p>
<p><b><i>-bash-3.00$ ls -l /usr/bin/passwd<br />
-r-sr-sr-x   1 root     sys        22620 Jan 23  2005 /usr/bin/passwd</i><br />
</b><br />
As you know it, <b>passwd </b>is the command used for changing the passwords for a given user in a Linux/Unix environment.</p>
<p>As can be seen above, the <b>UID </b>and <b>GID </b>permissions are set to <b><i>root </i></b>and <b><i>sys </i></b>respectively. How is it possible for a normal user to run this program then? Well that&#8217;s what we called the &#8220;<i><b>setuid</b></i>&#8221; or &#8220;<i><b>setgid</b></i>&#8221; permissions!</p>
<p>The normal user&#8217;s privileges are thus &#8220;promoted&#8221; for the execution of that specific command only. Hence Linux/Unix&#8217;s <i><b>setuid </b></i>facility allows programs run by normal users to make use of the <i>root </i>account in a very limited way.</p>
<p>As in the passwd command example below, we can see the &#8220;<b><i>setuid</i></b>&#8221; permissions in action:</p>
<p><i><b>-bash-3.00$ /usr/bin/passwd tek</b><b><br />
Enter existing login password:<br />
New Password:<br />
Re-enter new Password:<br />
passwd: password successfully changed for tek</b></i></p>
<p>Here we see the <b>passwd </b>command that users run to change their login password is a <b>setuid </b>program. The program<b> passwd </b>modifies the <b>/etc/passwd</b> file in a very well-defined way and then terminates. To prevent abuse, the <b>passwd </b>program requires the users to prove that they know the current password before it agrees to make the requested password change. Nice security!</p>
<p align="center">&nbsp;</p>
<p align="center"><b>ROOT: The SUPERUSER </b></p>
<p>What exactly is the root account? Why does it has a very special place in Linux/Unix systems? Well the main defining characteristic property of the <b>root </b>account is that it&#8217;s <b>UID </b>is set to <b>0 (zero)</b>.</p>
<p>Linux/Unix systems permit the superuser (that is root) to perform any valid operation on any file or process. In addition, some process issuing system calls or requests directly to the kernel can only be executed by the superuser.</p>
<p>Below are some restricted operations which can only be performed by the superuser (root):</p>
<ul>
<li>Creating device files</li>
<li>Setting the system&#8217;s hostname</li>
<li>Configuring network interfaces</li>
<li>Setting the system clock</li>
<li>Raising resource usage limits and process priorities</li>
<li> Shutting down the system</li>
</ul>
<p>An example of superuser powers is the ability of a process owned by root to change it&#8217;s <b>UID</b> and <b>GID</b>. The <b>login </b>program and it&#8217;s window system equivalents like GDM and KDM are a case in point.</p>
<p>The <b>login </b>program that prompts you for your username and password when you log in to the system initially runs as <b>root</b>. If the username and password  matches, the<b> login </b>program changes it&#8217;s <b>UID</b> and <b>GID</b> to your <b>UID </b>and <b>GID</b> and starts up your user environment. Once a root process has changed it&#8217;s ownerships to become a normal user process, it can never recover it&#8217;s former privileged state!</p>
<p>Therefore, it is extremely important for any system administrator to choose a very complex and secure password for the <b>root </b>user! I recommend a minimum of <b>8</b> characters with a mixture of Capital letters and numerical numbers! A warning has to be issued here, which is not to make the root&#8217;s password so complicated that you can&#8217;t remember it!</p>
<p>For remote administration, we obviously use the program called the <b>Secure Shell </b><b>(SSH) </b>to manage our servers. For that matter, it is advisable to disable direct <i>root </i>access via <b>SSH</b>. To disable SSH to root user and set other security restrictions, at least enable/disable it&#8217;s parameters as shown below:</p>
<p><b><i> vi /etc/ssh/sshd_config</i></b></p>
<p>###Recommended values###</p>
<p># Listen port (Default is 22, but change is to a higher port above 1025!)<br />
<b> Port 2012</b></p>
<p># Only v2 (recommended)<br />
<b>Protocol 2</b></p>
<p># Port forwarding<br />
<b>AllowTcpForwarding no</b></p>
<p># X11 tunneling options<br />
<b>X11Forwarding no</b></p>
<p># Ensure secure permissions on users .ssh directory.<br />
<b>StrictModes yes</b></p>
<p># Default is 600 seconds. 0 means no time limit.<br />
<b>LoginGraceTime 120</b></p>
<p># Maximum number of retries for authentication<br />
# Default is 6. Default (if unset) for MaxAuthTriesLog is MaxAuthTries / 2<br />
<b>MaxAuthTries    4<br />
MaxAuthTriesLog 3<br />
</b></p>
<p><b>PermitEmptyPasswords no</b></p>
<p><b>PermitRootLogin no</b><br />
<b>###End of </b><b><i>sshd_config</i></b><b>###</b></p>
<p align="center">&nbsp;</p>
<p align="center"><b>BECOMING ROOT </b></p>
<p>A better way to access the root account is to use the <b>su </b>command. If invoked without any arguments, <b>su</b>  will prompt for the root password and then start up a root shell. The privileges of this shell remain in effect until the shell terminates (<b>Ctrl+D</b> or the <b>exit </b>command).</p>
<p><b>su </b>does not record the commands executed as <b>root</b>, but it does create a log entry that states who became root and when.</p>
<p>So we have to extra careful as to whom to give root&#8217;s password! It is also a good idea to get in the habit of typing the full pathname to the <b>su </b>command rather than relying on the shell to find the command for you!</p>
<p><i><b>-bash-3.00$ whereis su<br />
su: /sbin/su /sbin/su.static /usr/bin/su /usr/man/man1m/su.1m</b></i></p>
<p><i><b></b></i><br />
Note: The exact location of the su command may differ from one system to another.</p>
<p>Next time you want to become root, simply type:</p>
<p><b>/usr/bin/su -</b></p>
<p>This will give you some protection against programs called <b>su </b>that may have been slipped into your search path with the intention of retrieving passwords.</p>
<p align="center">&nbsp;</p>
<p align="center"><b>sudo: a limited su</b></p>
<p>Since the privileges of the superuser account cannot be subdivided, it is hard to give someone the ability to do one task (backups) without giving that person the root privileges of the root account. Also if the SUPERUSER account is used by several administrators, you will have only a vague idea of who&#8217;s using it and doing what?</p>
<p>These types of problems can be resolved to some extent by a program called &#8220;<b>sudo</b>&#8220;. It is available in Debian, RedHat, SuSE, FreeBSD packages among other distributions.</p>
<p>For installation in Debian, it&#8217;s as simple as:  <b><i>apt-get install sudo</i></b></p>
<p>For Fedora and Centos, it&#8217;s:  <i><b>yum install sudo</b></i></p>
<p>For FreeBSD, you just <b>make install</b> in <b>/usr/ports/security/sudo</b></p>
<p><b>sudo </b>takes as it&#8217;s argument a command line to be executed as <b>root</b> (or as another restricted user). <b>sudo </b>consults the file <b>/etc/sudoers</b>, which lists the people who are authorized to use <b>sudo</b> and the commands they are allowed to run on the system.</p>
<p>If the proposed command is permitted for the user, <b>sudo </b>prompts the user&#8217;s own password and executes the command.</p>
<p>For example, suppose we have a normal user called &#8220;<i>john</i>&#8221; belonging to the &#8220;<i>wheel</i>&#8221; group. Under normal circumstances, user &#8220;<i>john</i>&#8221; can&#8217;t run the <b>tcpdump </b>command.</p>
<p>To give our normal user &#8220;<i>john</i>&#8221; the limited <b>sudo </b>access to the <b>tcpdump </b>command, we add the following entry in <b>/etc/sudoers</b> file.</p>
<p><i><b>(1.)  vi /etc/sudoers</b></i></p>
<p>#Add the following</p>
<p>john, %wheel ALL= /sbin/, /usr/sbin, /usr/sbin/tcpdump</p>
<p>(2.) Save and exit.</p>
<p>If user &#8220;<i>john</i>&#8221; were to run the <b>tcpdump </b>command without <b>sudo</b>, it would resemble as:</p>
<p><b><i>john@localhost:~$ /usr/sbin/tcpdump<br />
tcpdump: no suitable device found</i></b></p>
<p>But for user &#8220;<i>john</i>&#8221; to run the tcpdump command, he simply types the following sudo command:</p>
<p><i><b>john@localhost:~$  sudo /usr/sbin/tcpdump</b></i></p>
<p><b>Password:</b></p>
<div style="text-align:center;"><img src="http://farm3.static.flickr.com/2117/2180109601_458af7c439.jpg?v=0" alt="sudo tcpdump" height="375" width="500" /></div>
<p align="center"><i><b>Running tcpdump using sudo </b></i></p>
<p> Hence in this way, we can give a normal user some privilege to run a command to which only a superuser is allowed to.</p>
<p>Please note that I have touched only the tip of the <b>sudo </b>program. However below is a summary of what you can achieve using <b>sudo</b>:</p>
<ol>
<li>Accountability is much improved because of command logging</li>
<li>Operators can do chores without unlimited root privileges</li>
<li>The real root password can only be known to one or few users</li>
<li>Privileges can be revoked without the need to change the root password</li>
<li>A single file /etc/sudoers can be used to control access for an entire network.</li>
</ol>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="center"><b>Linux/Unix Filesystem</b></p>
<p align="left">In the Linux/Unix world, almost everything is represented by the file system. Processes, Serial ports, devices, you name it, is represented and managed via the file system.</p>
<p align="left">In a nutshell, the filesystem can be summarized as:</p>
<ol>
<li>A namespace &#8211; a way of naming things and organizing them in a hierarchy</li>
<li>An API &#8211; a set of system calls for navigating and manipulating objects</li>
<li>A security model &#8211; a scheme for protecting, hiding, and sharing things</li>
<li>An implementation &#8211; software that ties the logical model to actual hardware</li>
</ol>
<p>The filesystem is presented as a single unified hierarchy that starts at the directory / and continues downward through an arbitrary number of subdirectories. / is also called the root directory.</p>
<p>The list of directories that must be traversed to locate a particular file, together with it&#8217;s filename, form a &#8220;pathname&#8221;. Pathnames can be either absolute (<b>/tmp/foo</b>) or relative (<b>mydocs/chap4</b>) . Relative pathnames are interpreted starting at the current directory.</p>
<p>The terms <i>file, filename, pathname</i>, and <i>path </i>are more or less interchangeable.  <i>Filename </i>and <i>path </i>can be used for both absolute and relative paths; <i>pathnames </i>generally suggests an absolute path.</p>
<p>The filesystem can be arbitrarily deep. However, each component of a pathname must have a name no more than <b>255 </b>characters long, and a single path may not contain more than <b>4095 </b>characters. To access a file with a pathname longer than <b>4095 </b>characters, you must<b> cd </b>to an intermediate directory and use relative <i>pathname</i>.</p>
<p>There are no restrictions on the naming of files and directories, except that the names are limited in <b>length </b>and must not contain the <b>&#8220;/&#8221;</b> character or <b>nulls</b>. Spaces are permitted but because of <b>UNIX&#8217;s</b> long tradition of separating command-line arguments at whitespace, legacy software tends to break when spaces appear within filenames. However, these cases are very rare nowadays.</p>
<p>In shell and in scripts, spaceful filenames  just need to be quoted to keep their pieces together. For example, the command:</p>
<p><i><b>-bash-3.00$ more &#8220;My very long file.txt&#8221; </b></i></p>
<p>would preserve <b>My very long file.txt</b> as a single argument to <b>more </b>command.</p>
<p>Below is a graphical summary representing the Linux/Unix File System:</p>
<div style="text-align:center;"><img src="http://farm3.static.flickr.com/2072/2177589356_a23789e4c0.jpg?v=0" alt="Linux File Structure" height="324" width="500" /></div>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="left"><b> MOUNTING  AND </b><b>UNMOUNTING FILESYSTEMS</b></p>
<p align="left">As seen on the diagram above, the filesystem is composed of smaller chunks &#8211; also called filesystems- each of which consists of one directory and it&#8217;s subdirectories and files. For clarity, we use the term &#8220;file tree&#8221; to refer to the overall layout of the filesystem and reserve the word &#8220;filesystem&#8221; for the chunks attached to the tree!</p>
<p align="left">Most filesystems are disk partitions but they can be anything that obeys the proper API: network file servers, kernel components, memory-based disk emulators, etc.</p>
<p align="left">Filesystems are  attached to the tree with the <b>mount</b> command. <b>mount </b>maps a directory within the existing file tree, called the mount point, to the root of the newly attached filesystem.</p>
<p align="left">For example on a Linux host,</p>
<p align="left"><i><b>root@localhost# mount  /dev/hda4  /mbox</b></i></p>
<p align="left">The above command will install the filesystem stored on the disk partition represented by <b>/dev/hda4</b> under the path <b>/mbox</b>. You can then use command <b>&#8220;ls  /mbox&#8221;</b> to see that filesystem&#8217;s contents.</p>
<p align="left"> On a Solaris host:</p>
<p align="left"><b># mount /dev/dsk/c2d0s6 /mbox</b></p>
<p>The above command will mount a secondary hard drive represented by <b>/dev/dsk/c2d0s6 </b>to the path <b>/mbox</b> in Solaris.</p>
<p>A list of the filesystems that are mounted on a particular system is kept in the <b>/etc/fstab  </b>file in Linux/FreeBSD machines. On a Solaris machines, it is kept in the <b>/etc/vfstab </b>file<b>.</b></p>
<p>The information contained in this file allows filesystems to be checked <b>(fsck -A)</b> and mounted <b>(mount -a)</b> automatically at boot time. It also serves as documentation for the layout of the filesystems on disk and enables short commands such as <b>mount /var</b> for which the location of the filesystem to mount is looked up in <b>/etc/fstab </b>or<b> /etc/vfstab</b>.</p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="left">Filesystems are detached with the <b>umount </b>command. You cannot unmount a filesystem that is &#8220;busy&#8221; or in use! There must not be any open files or processes whose current directories are located on that filesystem, and if the filesystem contains executable programs, they cannot be running!</p>
<p align="left">When you are trying to <b>umount </b>a filesystem and the kernel complains that the filesystem is busy, you can run <b>fuser</b> to find out why.</p>
<p align="left">For example, running the <b>df -h </b>command below shows:</p>
<p align="left">&nbsp;</p>
<div style="text-align:center;"><img src="http://farm3.static.flickr.com/2067/2177804532_e125657b47.jpg?v=0" alt="Linux df command" height="188" width="500" /></div>
<p align="center"><b>df -h command</b></p>
<p align="left">Viewing the contents of <b>/etc/fstab:</b></p>
<p align="left">&nbsp;</p>
<div style="text-align:center;"><img src="http://farm3.static.flickr.com/2288/2177804686_21834a9b14.jpg?v=0" alt="Linux /etc/fstab" height="188" width="500" /></div>
<p align="center"><b>Linux /etc/fstab </b></p>
<p align="center">&nbsp;</p>
<p align="left">If we try to <b>umount /usr :</b></p>
<p align="left">&nbsp;</p>
<div style="text-align:center;"><img src="http://farm3.static.flickr.com/2326/2177012909_6c10f32a83.jpg?v=0" alt="umount /usr busy" height="141" width="500" /></div>
<p align="center"><b>umount /usr  showing as busy!</b></p>
<p align="center">&nbsp;</p>
<p align="left">Running <b>fuser -mv /usr:</b></p>
<p align="left">&nbsp;</p>
<div style="text-align:center;"><img src="http://farm3.static.flickr.com/2149/2177028373_21d82bcce6.jpg?v=0" alt="fuser -mv /usr" height="375" width="500" /></div>
<p align="center"><b>&#8220;fuser -mv&#8221; command showing why /usr can&#8217;t be unmounted</b></p>
<p align="center">&nbsp;</p>
<p align="center"><b>File Types and Permissions</b></p>
<p align="left">Linux/Unix  defines <b>seven (7) </b>types of files. They are defined as follows:</p>
<ol>
<li>Regular files</li>
<li>Directories</li>
<li>Character device files</li>
<li>Block device files</li>
<li>Local domain sockets</li>
<li>Named pipes (FIFOs)</li>
<li> Symbolic links</li>
</ol>
<p>We can determine the type of an existing file with the <b>ls -ld </b>command. The <b>first (1st)</b> character of the <b>ls </b>output encodes the type of file.</p>
<p>For example,</p>
<p><i><b># ls -ld /etc/ssh</b></i></p>
<p><i><b><br />
drwxr-xr-x   2 root     sys          512 Nov 21 14:28 /etc/ssh</b></i></p>
<p>Remembering that the <b>1st character </b>determines the type of file, the table below are the codes representing various types of files:</p>
<p><img src="http://farm3.static.flickr.com/2386/2180908656_2bf928387c.jpg?v=0" alt="Linux/Unix File Types Table" height="375" width="500" /></p>
<p>As can be seen from the table above, <b>rm</b> is the universal tool for deleting files you don&#8217;t want anymore!</p>
<p>A word of caution: Use <b>rm</b> very carefully. You could mistakenly remove a very important file such needed by your system. If that happens, your system might not boot anymore!</p>
<p>If in doubt, always use the <b>-i </b>option with the <b>rm </b>command.</p>
<p>For example,</p>
<p><i><b># rm -i /etc/rmmount.conf<br />
rm: remove /etc/rmmount.conf (yes/no)? </b></i><br />
<i><b></b></i></p>
<p><i><b>(1.) Regular files</b></i></p>
<p>A regular file is just a file containing certain amount of bytes! Linux/Unix imposes no structure on its contents. Text files, data files, executable programs like <b>gcc</b>,  shared libraries are all stored as regular files.</p>
<p><i><b>(2.)  Directories</b></i></p>
<p>A directory contains named references to other files. You can create directories with the <b>mkdir </b>command and delete them with the <b>rmdir </b>command if they are empty. If the directory is not empty, you are wipe it with the <b>rm -r </b>command.</p>
<p>For example, let&#8217;s list the contents of the <b>/etc/ssh</b></p>
<p><i><b></b><b># ls -al /etc/ssh</b></i></p>
<p><i><b><br />
total 208<br />
drwxr-xr-x   2 root     sys          512 Nov 21 14:28 .<br />
drwxr-xr-x  87 root     sys         4608 Jan  7 11:24 ..<br />
-rw-r&#8211;r&#8211;   1 root     sys        88301 Jan 22  2005 moduli<br />
-rw-r&#8211;r&#8211;   1 root     sys          861 Jan 22  2005 ssh_config<br />
-rw&#8212;&#8212;-   1 root     root         668 Nov 21 14:28 ssh_host_dsa_key<br />
-rw-r&#8211;r&#8211;   1 root     root         605 Nov 21 14:28 ssh_host_dsa_key.pub<br />
-rw&#8212;&#8212;-   1 root     root         883 Nov 21 14:28 ssh_host_rsa_key<br />
-rw-r&#8211;r&#8211;   1 root     root         225 Nov 21 14:28 ssh_host_rsa_key.pub<br />
-rw-r&#8211;r&#8211;   1 root     sys         5215 Jan  7 15:38 sshd_config</b></i></p>
<p>If you have noticed, in every directory, there are two (2) special entries <b>&#8220;.&#8221; </b>and <b>&#8220;..&#8221;</b>.</p>
<p>They refer to  the directory itself and to its parent directory respectively; hence they cannot be removed! Since the root directory has no parent directory, the path <b>&#8220;/..&#8221;</b> is equivalent to the path <b>&#8220;/.&#8221; </b>(and both are equivalent to /).</p>
<p><i><b>(3.)  Character and Block device files</b></i></p>
<p><b>Device </b>files allow programs to communicate with the system&#8217;s hardware and peripherals. When the <i><b>kernel </b></i>is configured, <i>modules </i>that know how to communicate with each of the system&#8217;s devices are linked in. These days, the <i><b>kernel </b></i>can also load modules dynamically.</p>
<p>But what exactly is a <i><b>kernel module</b></i>?   <i>Modules </i>are pieces of code that can be loaded and unloaded into the <i><b>kernel </b></i>upon 	demand.  They extend the functionality of the <i><b>kernel </b></i>without the need to reboot the system.  For example, one type of module 	is the device driver, which allows the kernel to access hardware connected to the system.  Without modules, we would have to 	build <b>monolithic kernels</b> and add new functionality directly into the kernel image.  Besides having larger kernels, this has 	the disadvantage of requiring us to rebuild and reboot the kernel every time we want new functionality.</p>
<p><b>Microsoft Windows </b> needs to reboot so often because they lack the support of <b>modules </b>from their NT kernel unlike Linux/Unix!</p>
<p>The <b>module </b>for a particular device, called a <b>device driver</b>, takes care of the messy details of managing the device.</p>
<p>Device drivers present a standard communication interface that looks like a regular file. When the kernel is given a request that refers to a <b>character </b>or <b>block</b> device file, it simply passes the request to the appropriate device driver.</p>
<p>It is important to differentiate between <i><b>device files</b></i> and <b><i>device drivers</i></b>. The device files are are just ordinary points that are used to communicate with the drivers. They are not the drivers themselves.</p>
<p>But what is the difference between a <i><b>character device file</b></i> and a <b><i>block device file</i></b>?  <b>Character device files</b> allow their associated drivers to do their own i<b>nput and output (I/O) </b>buffering.</p>
<p><b>Block device files</b> are used by drivers that handle <b>input and output (I/O)</b> in large chunks and want the kernel to perform the buffering for them.</p>
<p>Simply, a <b>block device</b> would read/write bytes in fixed size blocks, as in disk sectors. <b>Character devices </b>read/write 0 or more bytes, in a stream, such as a TTY or a keyboard.</p>
<p>Device files are characterized by two numbers, called the major and minor device numbers. The major device number tells the kernel which driver the file refers to, and  the minor device number tells the driver which physical unit to address.</p>
<p>If we on at the example below,</p>
<p><i><b>09:26:57 root@gw-dml-sp:~$ ls -l /dev/lp0</b></i></p>
<p><i><b><br />
crw-rw&#8212;-  1 root lp 6, 0 Jan  4 13:05 /dev/lp0</b></i></p>
<p>From above, the <i><b>major </b></i>device number is <b>6 </b>and the <i><b>minor </b></i>device number is <b>0</b>.</p>
<p>We can create device files with the <b>mknod </b>command and remove them with the <b>rm </b>command. Most systems provide a script called <b>/dev/MAKEDEV</b> that creates the appropriate sets of device files for common devices.</p>
<p><i><b>(4.) Local domain sockets</b></i></p>
<p>Sockets are connections between processes that allow them to communicate in a proper manner. Linux/Unix provides several different kinds of sockets, most of which involve the use of a network. Local domain sockets are accessible <i><b>only </b></i>from the <b><i>local host </i></b>and are referred to through a filesystem object rather than a network port. They are also known as &#8220;<b>UNIX domain sockets</b>&#8220;.</p>
<p>Although socket files are visible to other processes as directory entries, they cannot be read from or written to by processes not involved in the connection. Some standard facilities that use <b>local domain sockets</b> are the <b>printing </b>system, the <b>GNOME </b>and <b>KDE </b>Window Systems, and <b>syslog</b>.</p>
<p>Local domain sockets are created with the <b>socket </b>system call and can be removed with the <b>rm </b>command or the <b>unlink </b>system call once they have no more users.</p>
<p><i><b>(5.) Named pipes</b></i></p>
<p>Like <i><b>local domain sockets</b></i>, <b><i>named pipes</i></b> allow communication between two processes running on the same host. They are also known as &#8220;FIFO files&#8221; (FIFO is short form for &#8220;First In, First Out&#8221;).</p>
<p>You can create named pipes with the <b>mknod </b>command and remove them with <b>rm.</b></p>
<p>Like local domain sockets, real-world instances of named pipes are very few and rarely need administrative action.</p>
<p><i><b>(6.)  Symbolic links</b></i></p>
<p><i><b>Symbolic links</b></i> consist of a special type of file that serves as a reference to another file or directory. Unix-like operating systems in particular often feature symbolic links. Basically, a symbolic or soft link points to a file by name.</p>
<p>You can think of symbolic links in a similar way when you create &#8220;desktop shortcuts&#8221; in MS-Windows!<br />
Unlike a <b>hard link</b>, which points directly to data and represents another name for the same file, a <b>symbolic link</b> contains a path which identifies the target of the symbolic link. Thus, when a user removes a symbolic link, the file to which it pointed remains unaffected. Symbolic links may refer to files even on other mounted file systems.</p>
<p>We create symbolic links with the <b>ln -s </b>command and remove them with the <b>rm </b>command.</p>
<p>For example, if we want to make a symbolic link between the file <b>/etc/ssh/sshd_config</b> and <b>/home/tek/myssh_config</b>, we issue the following command:</p>
<p><i><b> # ln -s /etc/ssh/sshd_config /home/tek/mysshd_config </b></i></p>
<p><i><b># ls -l </b></i><i><b>/home/tek/mysshd_config </b></i></p>
<p>lrwxrwxrwx  1 tek tek 20 Jan  8 21:48 /home/tek/mysshd_config -&gt; /etc/ssh/sshd_config</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><b>FILE ATTRIBUTES AND PERMISSIONS</b></p>
<p>Every file has a set of nine (9) permission bits that control who can read, write, and execute the contents of the file. The nine permission bits are used to determine what operations on a file, and by whom.</p>
<p>Linux/Unix does not allow permissions to be set on a per-user basis. Instead, there are sets of permissions for the owner of the file, the group owners of the file, and everyone else. Each set has three bits: a read bit, a write bit, and an execute bit.</p>
<p>In a summary, there are three types of people that can do things to files &#8211; the <b>Owner </b>of the file, anyone in the <b>Group </b>that the file belongs to, and <b>Others </b>(everyone else). In UNIX they are referred to using the letters <b>U</b> (for Owner or User), <b>G</b> (for Group), and <b>O</b> (for Others).</p>
<p>Therefore there are three types of permissions:</p>
<pre>   r  - read the file or directory
   w  - write to the file or directory
   x  - execute the file or search the directory</pre>
<p>Each of these permissions can be set for any one of three types of user:</p>
<pre>u  - the user who owns the file (you)
g  - members of the group to which the owner belongs
o  - all other users</pre>
<p>Let us look at an example:</p>
<p><i><b> -bash-3.00$ ls -l /usr/bin/yelp </b></i></p>
<p><i><b><br />
-rwxr-xr-x   1 root     other     107504 Dec 17  2004 /usr/bin/yelp<br />
</b></i></p>
<p>As you can see above, there are nine (9) permission bits on the file <b>/usr/bin/yelp</b></p>
<p>On the left side, you can see the file attributes and permissions:</p>
<p><i><b>-rwxr-xr-x </b></i></p>
<div align="left">
<table class="body" border="0" cellpadding="2" width="448">
<tr>
<td align="center"><b></b><b>-</b></td>
<td align="center"><b>r</b></td>
<td align="center"><b>w</b></td>
<td align="center"><b>x</b></td>
<td align="center"><b>r</b></td>
<td align="center"><b></b><b>-</b></td>
<td align="center"><b>x</b></td>
<td align="center"><b>r</b></td>
<td align="center"><b></b><b>-</b></td>
<td align="center"><b>x</b></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="3" align="center"><b><i>Owner</i></b></td>
<td colspan="3" align="center"><b><i>Group</i></b></td>
<td colspan="3" align="center"><b><i>Other</i></b></td>
</tr>
<tr>
<td>File</td>
<td>Read</td>
<td>Write</td>
<td>Execute</td>
<td>Read</td>
<td>No-Write</td>
<td>Execute</td>
<td>Read</td>
<td>No-Write</td>
<td>Execute</td>
</tr>
</table>
</div>
<p>As can be seen, the following users have the following permissions on the file:</p>
<p>Owner &#8211; can read, write, and execute</p>
<p>Group &#8211; can read, no-write, and execute</p>
<p>Other &#8211; can read, no-write, and execute</p>
<p>Owner of  <i><b>/usr/bin/yelp </b></i>is<b> root </b>and group owner of <i><b>/usr/bin/yelp </b></i>is<b> other.</b></p>
<p><b>More examples: </b></p>
<p><b>drwxrwxrwx : </b>a folder which has read, write and execute permissions for the owner, the group and for other users.<br />
<b>-rwxr&#8211;r&#8211; : </b>a file that can be read and written by the user, but only read and executed by the group, and only read by everyone else.</p>
<p align="center"><b>Using numbers (octal) for permissions<br />
</b></p>
<p>We can also use numbers for setting file and folder permissions. Each of the three numbers corresponds to each of the three sections of letters. The first number determines the <b>owner</b> permissions, the second number determines the <b>group</b> permissions and the third number determines the <b>other</b> permissions. Each number can have one of eight values ranging from 0 to 7. Each value corresponds to a certain setting of the <b>read</b>, <b>write</b> and <b>execute</b> permissions.</p>
<p>These values are added together for any one user category:</p>
<pre>    1   =   execute only
    2   =   write only
    3   =   write and execute (1+2)
    4   =   read only
    5   =   read and execute (4+1)
    6   =   read and write (4+2)
    7   =   read and write and execute (4+2+1)</pre>
<p>For example:</p>
<p><b>777</b> is the same as <b>rwxrwxrwx<br />
</b><b>755</b> is the same as <b>rwxr-xr-x</b></p>
<p><b>ls</b> output is slightly different for a device file. For example,</p>
<p><i><b>09:17:07 root@gw-dml-sp:~$ ls -l  /dev/tty0</b></i></p>
<p><i><b><br />
crw-rw&#8212;-  1 root tty 4, 0 Jan  4 13:05 /dev/tty0</b></i></p>
<p><i><b>crw-rw&#8212;-<br />
</b></i></p>
<div align="left">
<table class="body" border="0" cellpadding="2" width="588">
<tr>
<td align="center"><b>-</b></td>
<td align="center"><b>r</b></td>
<td align="center"><b>w</b></td>
<td align="center"><b>x</b></td>
<td align="center"><b>r</b></td>
<td align="center"><b>-</b></td>
<td align="center"><b>x</b></td>
<td align="center"><b>r</b></td>
<td align="center"><b>-</b></td>
<td align="center"><b>x</b></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="3" align="center"><b><i>Owner</i></b></td>
<td colspan="3" align="center"><b><i>Group</i></b></td>
<td colspan="3" align="center"><b><i>Other</i></b></td>
</tr>
<tr>
<td>Character file</td>
<td>Read</td>
<td>Write</td>
<td>Non-Execute</td>
<td>Read</td>
<td>Write</td>
<td>Non-Execute</td>
<td>No-Read</td>
<td>No-Write</td>
<td>Non-Execute</td>
</tr>
</table>
</div>
<p>As can be seen, the file <i><b>/dev/tty0 </b></i>is a <b>Character </b>device file whose owner and group owner can <b>read, write </b>but could not <b>execute </b>it since this is a <b>character </b>device file!</p>
<p>The filesystem maintains about forty (40) separate pieces of information for each file! But the good news is that most of them are only useful for the filesystem itself. As a system administrator, we should be concerned mostly with the <b>link count, owner, group, mode, size, last access time, last modification time, and type.</b></p>
<p>Looking at the next example,</p>
<p><i><b>09:32:10 root@gw-dml-sp:~$ ls -l /bin/gzip</b></i></p>
<p><i><b><br />
-rwxr-xr-x  3 root root 55792 Feb 22  2005 /bin/gzip</b></i></p>
<p><b> Summary:</b></p>
<p>The first field specifies the file&#8217;s type and mode. The first character is a dash, so <b>/bin/gzip</b> is a regular file.</p>
<p>The next nine characters in this field are the three sets of permission bits. I have stressed several times the order of this <b>3 sets of permission bits</b>. The order is <b>owner-group-other</b>.</p>
<p>In the example of<i><b>:  </b><b>-rwxr-xr-x  3 root root 55792 Feb 22  2005 /bin/gzip</b></i></p>
<p>In this case, the <b>owner </b>can <i><b>read</b></i>-<i><b>write</b></i>-<i><b>execute</b></i>,  the <b>Group owner</b> can only <i>execute</i>-<i>read </i>and <b>Others </b>can only <i><b>execute</b></i>.</p>
<p>The next field in the listing is the <b>link count</b> for the file. In this case, it is <b>3</b>, indicating that <b>/bin/gzip </b>is just one of three names for this file (the others are <b>/bin/gunzip</b> and <b>/bin/zcat</b>). Each time a hard link is made to a file, the count link is incremented by <b>1</b>.
</p>
<p align="center"><b>The setuid and setgid bits</b></p>
<p align="left">The bits with octal values <b>4000 </b>and <b>2000 </b>are the <b>setuid </b>and <b>setgid </b>bits. These bits allow programs to access files and processes that would otherwise be off-limits to the user that runs them.</p>
<p align="left">When set on a directory, the <i><b>setuid</b></i> bit causes newly created files within the directory to take on the group ownership of the directory rather than the default group of the user of the user that created the file.</p>
<p align="left">&nbsp;</p>
<p align="center"><b>The Sticky Bit</b></p>
<p align="left">The bit with octal value 1000 is called the sticky bit. If a sticky bit is set on a directory, the filesystem won&#8217;t allow anyone to delete or rename a file unless that person is the owner of the directory, the owner of the file, or the superuser. This convention helps to make directories like <b>/tmp</b> a little more secure.</p>
<p align="left">&nbsp;</p>
<p>If the <i><b>setuid </b></i>bit had been set, the <b><i>x</i></b> representing the owner&#8217;s execute permission would have been replaced with an <b><i>s</i></b>, and if the <b><i>setgid</i></b> bit had been set, the <b><i>x</i></b> for the group would also have been replaced with an <i><b>s</b>.</i></p>
<p>The last character of the permissions (execute permission for &#8220;other&#8221;) is shown as <i><b>t </b></i>if the <i><b>sticky bit</b></i> of the file is turned on.  If either the setuid/setgid bit or the sticky bit is set but the corresponding execute bit is not, these bits appear as <i><b>S </b></i>or <i><b>T.</b></i></p>
<p>The filesystem automatically keeps track of modification time stamps, link counts, and file size information. The permission bits, ownership, and group ownership can only be changed by with the <b>chmod, chown, chgrp</b> commands.</p>
<p align="center">&nbsp;</p>
<p align="center"><b>chmod: change permissions</b></p>
<p>The <b>chmod </b>command changes the permissions on a file. Only the owner of the file and the superuser can change its permissions.</p>
<p>The <b>octal </b>notation is generally more convenient for administrators but the <b>mnemonic </b>syntax can be useful for new comers.</p>
<p>The first argument to <b>chmod </b>is a specification of the permissions to be assigned, and the second and subsequent arguments are names of files on which these permissions apply to.</p>
<p><img src="http://farm3.static.flickr.com/2119/2182765428_bd30b1b7ca.jpg?v=0" alt="chmod-encoding-table" height="375" width="500" /></p>
<p align="left">&nbsp;</p>
<p align="left">To see <b>chmod</b> in action,</p>
<p align="left"><img src="http://farm3.static.flickr.com/2311/2181990487_b44c7ac437.jpg?v=0" alt="chmod-711-action" height="188" width="500" /></p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="left"> As can be seen above, the original permission of the file <b>/home/tek/myprog </b>was:</p>
<p align="left"> -rw-rw-r&#8211;</p>
<p align="left">Upon issuing  the command <b>chmod 711 /home/tek/myprog</b>, the permission was changed to:</p>
<p align="left">-rwx&#8211;x&#8211;x</p>
<p align="left">&nbsp;</p>
<p align="left">The same effect can be applied using <b>mnemonic </b>syntax instead of <b>octal </b>notation.</p>
<p align="left">For example,</p>
<p align="left"><img src="http://farm3.static.flickr.com/2068/2182789578_7cfc4d22c5.jpg?v=0" alt="chmod-mnemonic-action" height="188" width="500" /></p>
<p align="left">&nbsp;</p>
<p align="left"> chown: change ownership and group</p>
<p align="left">The <b>chown </b>command changes the file&#8217;s ownership and group ownership. It&#8217;s syntax mirrors that of <b>chmod</b>, except that the first argument specifies the new owner and group in the form of <i>user.group (user:group). </i>Either of <i>user </i>or <i>group</i> may be left out. If there is no group, you don&#8217;t need the dot either.</p>
<p align="left">Looking at the example below:</p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<div style="text-align:center;"><img src="http://farm3.static.flickr.com/2276/2183410458_f62330b83b.jpg?v=0" alt="chown-action" height="188" width="500" /></div>
<p align="left">&nbsp;</p>
<p align="left">The above command changes the <i>owner</i>:<i>group </i>of the file <i><b>/home/tek/robots.txt</b></i> from <b>root:root</b> to <b>tek:wheel</b>.</p>
<p align="left">To change a file&#8217;s group, you must either be the owner of the file and belong to the group you&#8217;re changing to or be the <b>superuser</b>. However, you <i><b>must </b></i>be the <b>superuser </b>to change the file&#8217;s <i>owner</i>.</p>
<p align="left">Like <b>chmod</b>, <b>chown </b>offers the recursive <b>-R</b> flag to change the settings of a directory and all the files underneath it. For example, the sequence:</p>
<p align="left"><i><b># chmod -755 ~john</b></i></p>
<p align="left"><i><b># chown -R john:wheel ~john</b></i></p>
<p align="left">&nbsp;</p>
<p align="left">might be used to setup the home directory of a new user called <i>john </i>after copying the default startup files. The commands above will set the directory <b>/home/john </b>and all it&#8217;s files and sub directories to be owned by <i>user john and group wheel.</i></p>
<p align="left">&nbsp;</p>
<p align="left"><b>chgrp</b></p>
<p align="left">Traditional UNIX uses a separate command called <b>chgrp</b>, to change the group owner of a file. Linux provides the <b>chgrp </b>command too. It works just like <b>chown</b> but <b>chgrp </b>takes just a parameter which is the <b>group </b>owner.</p>
<p align="left">For example:</p>
<p align="left"><img src="http://farm3.static.flickr.com/2410/2184231959_2f67bd455a.jpg?v=0" alt="chgrp-wheel-group" height="188" width="500" /></p>
<p align="left">The above <b>chgrp </b>command will change the <b>group owner </b>from <i>tek </i>to <i>wheel.</i></p>
<p align="left">I hope that the materials above will serve as a basis to understand the file system and structure of your Linux/Unix machines. It should also give you hindsights to avoid common <i>mistakes </i>such as making a important file to be <i>read</i>, <i>written</i>, or <i>executed </i>by everybody. It should also provide you how to protect and give access to important files and directories only to certain users on your system.</p>
<p align="left">&nbsp;</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/teklimbu.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/teklimbu.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/teklimbu.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/teklimbu.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/teklimbu.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/teklimbu.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/teklimbu.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/teklimbu.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/teklimbu.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/teklimbu.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/teklimbu.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/teklimbu.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=20&subd=teklimbu&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://teklimbu.wordpress.com/2008/01/06/files-permissions-processes-root-and-sudo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dac1f65f8303afbf89a5d1d2c98c8e8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">teklimbu</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2117/2180109601_458af7c439.jpg?v=0" medium="image">
			<media:title type="html">sudo tcpdump</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2072/2177589356_a23789e4c0.jpg?v=0" medium="image">
			<media:title type="html">Linux File Structure</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2067/2177804532_e125657b47.jpg?v=0" medium="image">
			<media:title type="html">Linux df command</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2288/2177804686_21834a9b14.jpg?v=0" medium="image">
			<media:title type="html">Linux /etc/fstab</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2326/2177012909_6c10f32a83.jpg?v=0" medium="image">
			<media:title type="html">umount /usr busy</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2149/2177028373_21d82bcce6.jpg?v=0" medium="image">
			<media:title type="html">fuser -mv /usr</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2386/2180908656_2bf928387c.jpg?v=0" medium="image">
			<media:title type="html">Linux/Unix File Types Table</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2119/2182765428_bd30b1b7ca.jpg?v=0" medium="image">
			<media:title type="html">chmod-encoding-table</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2311/2181990487_b44c7ac437.jpg?v=0" medium="image">
			<media:title type="html">chmod-711-action</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2068/2182789578_7cfc4d22c5.jpg?v=0" medium="image">
			<media:title type="html">chmod-mnemonic-action</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2276/2183410458_f62330b83b.jpg?v=0" medium="image">
			<media:title type="html">chown-action</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2410/2184231959_2f67bd455a.jpg?v=0" medium="image">
			<media:title type="html">chgrp-wheel-group</media:title>
		</media:content>
	</item>
		<item>
		<title>Network Management using Nagios</title>
		<link>http://teklimbu.wordpress.com/2008/01/01/network-management-using-nagios/</link>
		<comments>http://teklimbu.wordpress.com/2008/01/01/network-management-using-nagios/#comments</comments>
		<pubDate>Tue, 01 Jan 2008 17:56:03 +0000</pubDate>
		<dc:creator>teklimbu</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[network managment]]></category>

		<guid isPermaLink="false">http://teklimbu.wordpress.com/2008/01/01/network-management-using-nagios/</guid>
		<description><![CDATA[
If you are reading this article, then you should be well aware that there are various and different types of  network devices,  servers, electronic gadgets, transport mediums, media converters, etc, which are somehow connected to each other to form the Internet.
The internet is the biggest network in the world consisting of billions of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=19&subd=teklimbu&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Flinux_unix%2FNetwork_Management_using_Nagios' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
<p>If you are reading this article, then you should be well aware that there are various and different types of  network devices,  servers, electronic gadgets, transport mediums, media converters, etc, which are somehow connected to each other to form the Internet.</p>
<p>The internet is the biggest network in the world consisting of billions of computers, servers, workstations, routers, switches, printers, mainframes, mobile devices, etc, connected to each other in one way or another.</p>
<p>1 question certainly arises, which is, how do we keep track of this giant network and it&#8217;s billions of network devices connected to the Internet?</p>
<p><span id="more-19"></span></p>
<p>If you are a system administrator, then I&#8217;m sure you are in charge of maintaining at least a couple of servers and network devices such as a router. In truth, a system administrator&#8217;s job is unlimited and sad but truth is also thankless job. We look after a lot of different servers ranging from web servers, proxy servers, dns servers, mail servers just to name a few. In fact, any given system administrator could well be managing any where from 5 to 500 different kinds of servers and network devices.</p>
<p>On average, a single server could be serving approximately 500 users. Hence if one of your server should go down, then 500 people will be banging your phone and speaking some horrible or alien language to you!</p>
<p>If you add 2 dozen more servers and network devices and for some reason they should go down, then that&#8217;s when you know that you are in real deep trouble!</p>
<p>So how do we keep ourselves sane and how to we keep ourselves informed if all our servers and network services are working in fine shape and condition. The answer is to use a host and service monitoring system designed to inform us of network problems before our clients, end-users or managers do!</p>
<p>There are various different tools used for monitoring servers and network devices out of which the 2 best known tools are Nagios and Zabbix.</p>
<p>In a nutshell,</p>
<p>Nagios is a popular open source computer system and network monitoring application software. It watches hosts and services that you specify, alerting you when things go bad and again when they get better.</p>
<p>It can be used for monitoring of network services (SMTP, POP3, HTTP, NNTP, ICMP, SNMP, FTP, SSH, etc) .</p>
<p>The best part of it is that it supports simple plugins designed to allow users to easily develop their own service checks depending on needs, by using the tools of choice (Bash, C++, Perl, Ruby, Python, PHP, C#, etc.)</p>
<p>Zabbix is also an open source network monitoring system designed to monitor and track the status of various network services, servers, and other network hardware. The main difference between Nagios and Zabbix is that Zabbix uses MySQL, PostgreSQL, SQLite or Oracle to store data. Its web based frontend is written in PHP.</p>
<p>The point to note is that whichever tool you choose to use, the tool must allow us to be constantly aware of change in our environment to which we should be aware and to record data points over a period of time to allow for trend analysis, capacity planning, and fault isolation down the road.</p>
<p>In this article, we will go about installing and configuring Nagios for monitoring our network devices and servers.</p>
<p>For Nagios to work, you must have an existing Apache web server running. If not, then simply follow the steps below to configure a simple running Apache-2.2.6 web server:</p>
<p><b>(1.) Add User and Group &#8220;apache&#8221; and download Apache-2.2.6</b></p>
<p>groupadd apache</p>
<p>useradd -g apache apache</p>
<p>mkdir -p /usr/local/src/httpd</p>
<p>cd   /usr/local/src/httpd</p>
<p>wget   http://mirror.nyi.net/apache/httpd/httpd-2.2.6.tar.gz</p>
<p><b>(2.)  unzip the sources</b></p>
<p>tar   zxvf   httpd-2.2.6.tar.gz</p>
<p><b>(3.)  Configure Apache</b></p>
<p>cd    httpd-2.2.6</p>
<p>./configure</p>
<p>–prefix=/usr/local/httpd \</p>
<p>–enable-so</p>
<p><b>(4.) Compile and install Apache </b></p>
<p>make  &amp;&amp;   make  install</p>
<p><i><b>(5.)  Start the Apache web server </b></i></p>
<p>/usr/local/httpd/bin/apachectl start</p>
<p>That’s it. Apache 2.2.6 should now be running!</p>
<p align="center">&nbsp;</p>
<p align="center"><b> NAGIOS INSTALLATION</b></p>
<p>Now that our web server is running, we move on to the installation of Nagios itself.</p>
<p><i><b>(1.)  Create the user &#8220;nagios&#8221; and group &#8220;nagcmd&#8221;. Then add user &#8220;nagios&#8221; and &#8220;apache&#8221; to the nagcmd group.</b></i></p>
<p>useradd nagios</p>
<p>groupadd nagcmd</p>
<p>usermod -G nagcmd nagios<br />
usermod -G nagcmd apache<br />
<b><i></i></b></p>
<p><b><i>(2.)  Download the latest version of Nagios to your regular download directory. As of 01-Jan-2008, the latest version of Nagios is nagios-3.0rc1. We also have to download the nagios-plugins.</i></b></p>
<p>mkdir -p /usr/local/src/nagios</p>
<p>cd  /usr/local/src/nagios</p>
<p>wget http://superb-east.dl.sourceforge.net/sourceforge/nagios/nagios-3.0rc1.tar.gz</p>
<p>wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz</p>
<p><i><b>(3.)  Unzip and unpack the sources files.</b></i></p>
<p>cd  /usr/local/src/nagios</p>
<p>tar zxvf /usr/local/src/nagios/nagios-3.0rc1.tar.gz</p>
<p><b><i>(4.) Configure your nagios installation </i></b></p>
<p>cd /usr/local/src/nagios/nagios-3.0rc1<br />
./configure &#8211;prefix=/usr/local/nagios \<br />
&#8211;with-nagios-user=nagios \<br />
&#8211;with-nagios-group=nagios \<br />
&#8211;with-cgiurl=/usr/local/nagios/share/nagios/cgi-bin</p>
<p><b><i>(5.)  Compile and make install</i></b></p>
<p>make all</p>
<p><b><i>(6.)  Install binaries, init script, sample config files and set permissions on the external command directory.</i></b></p>
<p>make install<br />
make install-init<br />
make install-config<br />
make install-commandmode</p>
<p><b><i>(7.) Configure </i></b><b><i>admin </i></b><b><i>email address<br />
</i></b></p>
<p>vi /usr/local/nagios/etc/objects/contacts.cfg</p>
<p>###Change the following###</p>
<p>email   nagios@localhost</p>
<blockquote><p>to</p></blockquote>
<p>email   tekbdrlimbu@hotmail.com<br />
<b><i></i></b></p>
<p><b><i> (8.)  Configure the Web interface</i></b></p>
<p>ln -s /usr/local/httpd/conf /etc/httpd<br />
ln -s /usr/local/httpd/conf /etc/httpd</p>
<p>cd /usr/local/src/nagios/nagios-3.0rc1</p>
<p>make install-webconf</p>
<p><b><i>(9.)  Add password to username &#8220;nagiosadmin&#8221;<br />
</i></b><br />
/usr/local/httpd/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin<br />
<i><b><br />
(10.)   Unzip and unpack the nagios plugins</b></i></p>
<p>cd /usr/local/src/nagios</p>
<p>tar zxvf  /usr/local/src/nagios/nagios-plugins-1.4.11.tar.gz</p>
<p>cd /usr/local/src/nagios/nagios-plugins-1.4.11/</p>
<p><b><i>(11.) Run configure</i></b></p>
<p>./configure &#8211;with-nagios-user=nagios &#8211;with-nagios-group=nagios</p>
<p><b><i>(12.)  Compile and make install</i></b></p>
<p>make</p>
<p>make install<br />
<b><i></i></b></p>
<p><b><i> (13.)  Verify Nagios configuration files and rung Nagios in Daemon mode<br />
</i></b></p>
<p><b><i></i></b><br />
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg<br />
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg</p>
<p><i><b>(14.) Copy the Nagios config files to Apache config directory</b></i></p>
<p>cp /usr/local/nagios/etc/nagios.cfg /usr/local/httpd/conf/</p>
<p><i><b>(15.)  Include nagios.conf in your httpd.conf file and restart Apache</b></i></p>
<p>vi /usr/local/httpd/conf/httpd.conf</p>
<p>##Add the following line to httpd.conf###</p>
<p>Include /usr/local/httpd/conf/nagios.conf</p>
<p>###Save httpd.conf and exit and restart Apache###</p>
<p>/usr/local/httpd/bin/apachectl restart</p>
<p><i><b>(16.)  Fire your web browser to check your Nagios installation</b></i></p>
<p>http://localhost/nagios</p>
<p>or</p>
<p>http://192.168.0.1/nagios</p>
<p>You should see something like the following:</p>
<p><img src="http://farm3.static.flickr.com/2384/2154414417_55b12babb5.jpg?v=0" alt="Nagios Initial Screen" height="375" width="500" /></p>
<p align="center"><i><b>Nagios initial screen</b></i></p>
<p align="center">&nbsp;</p>
<p align="center"><img src="http://farm3.static.flickr.com/2396/2155268556_02f9369b31.jpg?v=0" alt="Nagios Service Detail" height="375" width="500" /></p>
<p align="center"><i><b>Nagios Service Detail Screenshot </b></i></p>
<p align="center">&nbsp;</p>
<p>That&#8217;s it. Nagios is installed now. Next we will go about configuring checks on various hosts and network devices on our network.</p>
<p>To be continued tomorrow &#8230;..</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/teklimbu.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/teklimbu.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/teklimbu.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/teklimbu.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/teklimbu.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/teklimbu.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/teklimbu.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/teklimbu.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/teklimbu.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/teklimbu.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/teklimbu.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/teklimbu.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=19&subd=teklimbu&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://teklimbu.wordpress.com/2008/01/01/network-management-using-nagios/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dac1f65f8303afbf89a5d1d2c98c8e8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">teklimbu</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2384/2154414417_55b12babb5.jpg?v=0" medium="image">
			<media:title type="html">Nagios Initial Screen</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2396/2155268556_02f9369b31.jpg?v=0" medium="image">
			<media:title type="html">Nagios Service Detail</media:title>
		</media:content>
	</item>
		<item>
		<title>Monitoring your Linux/Unix servers and network devices using MRTG and SNMP</title>
		<link>http://teklimbu.wordpress.com/2007/12/05/monitoring-your-linuxunix-servers-and-network-devices-using-mrtg-and-snmp/</link>
		<comments>http://teklimbu.wordpress.com/2007/12/05/monitoring-your-linuxunix-servers-and-network-devices-using-mrtg-and-snmp/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 15:57:25 +0000</pubDate>
		<dc:creator>teklimbu</dc:creator>
				<category><![CDATA[mrtg]]></category>
		<category><![CDATA[snmp]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[net-snmp]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://teklimbu.wordpress.com/2007/12/05/monitoring-your-linuxunix-servers-and-network-devices-using-mrtg-and-snmp/</guid>
		<description><![CDATA[
This tutorial will guide you to create MRTG graphs for your Linux/Unix Server or just about any network device which supports SNMP.
This guide will present you the layout in a practical way and will not go in depth to explain the theories behind how they work. This is because the users will explore and learn [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=6&subd=teklimbu&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Flinux_unix%2FMonitor_your_Linux_Unix_server_using_MRTG_graphing' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
<p>This tutorial will guide you to create MRTG graphs for your Linux/Unix Server or just about any network device which supports SNMP.</p>
<p>This guide will present you the layout in a practical way and will not go in depth to explain the theories behind how they work. This is because the users will explore and learn them by themselves.</p>
<p><b>SNMP </b>stands for <b>Simple Network Management Protocol</b>.</p>
<p><span id="more-6"></span></p>
<p>It is an application layer protocol that helps the exchange of management information between network devices. It is based on <b>TCP/IP</b> and allows us to extract various information like network traffic and performance which in turn help us plan our network for growth and problems.</p>
<p>More information about SNMP can be found at it&#8217;s site at: <a href="http://net-snmp.sourceforge.net/" title="net-snmp homepage">http://net-snmp.sourceforge.net/ </a></p>
<p>First of all, you need the MRTG package.</p>
<p><b>MRTG </b>stands for <b>Multi Router Traffic Grapher</b>. It can be used to monitor and graphically display traffic and usage of an internet connection among many other things.</p>
<p>More information about MRTG can be found on it&#8217;s creator&#8217;s site at: <a href="http://oss.oetiker.ch/mrtg/" title="MRTG Homepage" target="_blank">http://oss.oetiker.ch/mrtg/</a></p>
<p>In addition to MRTG, you will need a Web server to display the graphs and statistics generated by MRTG. More information to setup an Apache web server can be found in the following URL:</p>
<p><a href="http://teklimbu.wordpress.com/2007/10/08/configuring-apache-2x-with-php-5x-and-mysql-5x/" title="Apache installation" target="_blank">http://teklimbu.wordpress.com/2007/10/08/configuring-apache2</a></p>
<p>In case, you are in a hurry, follow the steps below to install a very basic Apache web server.</p>
<p><b>(1.)  Download Apache</b></p>
<p>cd   /usr/local/src</p>
<p>wget   http://mirror.nyi.net/apache/httpd/httpd-2.2.6.tar.gz</p>
<p><b>(2.)  unzip the sources</b></p>
<p>tar   zxvf   httpd-2.2.6.tar.gz</p>
<p><b>(3.)  Configure Apache</b></p>
<p>cd    httpd-2.2.6</p>
<p>./configure</p>
<p>–prefix=/usr/local/httpd \</p>
<p>–enable-so</p>
<p><b>(4.) Compile and install Apache </b></p>
<p>make  &amp;&amp;   make  install</p>
<p><i><b>(5.)  Start the Apache web server </b></i></p>
<p>/usr/local/httpd/bin/apachectl start</p>
<p>That’s it. Apache 2.2.6 should now be running!</p>
<p>Moving on, we will next compile and install the MRTG package.</p>
<p><b>MRTG Installation</b></p>
<p><b><i>(1.)  Create local directory and change to that directory.</i></b></p>
<p>mkdir  -p  /usr/local/src/mrtg</p>
<p>cd   /usr/local/src/mrtg</p>
<p><i><b>(2.) Download MRTG. The latest version of MRTG as on 05-Dec-2007 is 2.15.2.<br />
</b></i></p>
<p>wget http://oss.oetiker.ch/mrtg/pub/mrtg-2.15.2.tar.gz</p>
<p><b><i>(3.)   Unzip the package.</i></b></p>
<p>tar   zxvf mrtg-2.15.2.tar.gz</p>
<p>cd   mrtg-2.15.2</p>
<p><b><i>(4.)   Configure MRTG</i></b></p>
<p>./configure   &#8211;prefix=/usr/local/mrtg-2</p>
<p>Note: you may need to install the GD library. For Debian users, it&#8217;s just a matter of typing: apt-get install libgd-dev</p>
<p align="left">&nbsp;</p>
<p> <b><i> (5.)    Compile and install the MRTG software.</i></b></p>
<p>make &amp;&amp; make  install</p>
<p>That&#8217;s it. MRTG is now installed in the prefixed directory:  /usr/local/mrtg-2</p>
<p><b>Net-SNMP Installation</b></p>
<p><b><i>(1.)  Create local directory to your download SNMP</i></b></p>
<p>mkdir -p  /usr/local/src/snmp</p>
<p>cd  /usr/local/src/snmp</p>
<p><b><i>(2.) Download the latest source package of net-snmp. The latest version of net-snmp as on 05-Dec-2007 is 5.2.4. </i></b></p>
<p>wget http://nchc.dl.sourceforge.net/sourceforge/net-snmp/net-snmp-5.2.4.tar.gz</p>
<p><b><i>(3.)   Unzip the source file</i></b></p>
<p>tar zxvf net-snmp-5.2.4.tar.gz</p>
<p><b><i>(4.)  Configure your SNMP package</i></b></p>
<p>cd /usr/local/src/snmp/net-snmp-5.2.4<br />
./configure &#8211;prefix=/usr/local/net-snmp</p>
<p>Note: You will be asked some questions regarding setting up SNMP such as the following:</p>
<p>(a.)  Default version of SNMP to use: Choose 2</p>
<p>(b.)  System Contact Information: type in your email address</p>
<p>(c.)  System Location: Type in the location of this box</p>
<p>(d.)  Location to write log file: /var/log/snmpd.log</p>
<p>(e.)  Location to write persistent information: /var/net-snmp</p>
<p>If your configuration options was successful you will see something the following:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Net-SNMP configuration summary:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>SNMP Versions Supported:    1 2c 3<br />
Net-SNMP Version:           5.2.4<br />
Building for:               linux<br />
Network transport support:  Callback Unix TCP UDP<br />
SNMPv3 Security Modules:    usm<br />
Agent MIB code:             mibII ucd_snmp snmpv3mibs notification target agent_mibs agentx utilities<br />
SNMP Perl modules:          disabled<br />
Embedded perl support:      disabled<br />
Authentication support:     MD5 SHA1<br />
Encryption support:         DES AES</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
<i><b> (5.)  Compile and install SNMP</b></i></p>
<p>make  &amp;&amp;  make install</p>
<p>If everything completes without any errors, that&#8217;s it. Net-SNMP is installed in your machine!</p>
<p align="center"><b>Configuration of snmpd.conf</b></p>
<p>Let us now create a snmpd.conf file which contains the basic elements for extracting information about your machine.</p>
<p><b><i>(1.)  Create the etc directory to hold your snmpd.conf file.</i></b><br />
mkdir -p /usr/local/net-snmp/etc</p>
<p><b><i>(2.)  Create the snmpd.conf</i></b></p>
<p>vi /usr/local/net-snmp/etc/snmpd.conf</p>
<p>##Copy and paste the following##</p>
<p>#############Start of snmpd.conf###########################<br />
#<br />
# snmpd.conf<br />
#<br />
#   &#8211; created by Tek Limbu on 05-Dec-2007<br />
#<br />
#######################################################<br />
# SECTION: System Information Setup<br />
#<br />
#   This section defines some of the information reported in<br />
#   the &#8220;system&#8221; mib group in the mibII tree.</p>
<p># syslocation: The [typically physical] location of the system.<br />
#   Note that setting this value here means that when trying to<br />
#   perform an snmp SET operation to the sysLocation.0 variable will make<br />
#   the agent return the &#8220;notWritable&#8221; error code.  IE, including<br />
#   this token in the snmpd.conf file will disable write access to<br />
#   the variable.<br />
#   arguments:  location_string</p>
<p>syslocation Kathmandu-Nepal</p>
<p># syscontact: The contact information for the administrator<br />
#   Note that setting this value here means that when trying to<br />
#   perform an snmp SET operation to the sysContact.0 variable will make<br />
#   the agent return the &#8220;notWritable&#8221; error code.  IE, including<br />
#   this token in the snmpd.conf file will disable write access to<br />
#   the variable.<br />
#   arguments:  contact_string</p>
<p>syscontact tekbdrlimbu@hotmail.com</p>
<p>#####################################################<br />
# SECTION: Access Control Setup<br />
#<br />
#   This section defines who is allowed to talk to your running<br />
#   snmp agent.</p>
<p># rocommunity: a SNMPv1/SNMPv2c read-only access community name<br />
#   arguments:  community [default|hostname|network/bits] [oid]</p>
<p>rocommunity MyPass333</p>
<p>#Disk size in Megabytes (MB).</p>
<p>disk  /usr</p>
<p>disk  /var</p>
<p>#################End of snmpd.conf########################</p>
<p>The most important data in any SNMP configuration is the community string which can be compared to a password. In the above snmpd.conf file, the <i>rocommunity </i>stands for <i>read-only community</i> string which has the value &#8220;MyPass333&#8243;. As with passwords, this has to be kept as as secret!</p>
<p><b><i>(3.)  Run the SNMP daemon using the above snmpd.conf file.<br />
</i></b></p>
<p>/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/etc/snmpd.conf</p>
<p><i><b>(4.)  </b></i><b><i>Test to see if SNMP is working and functioning properly.</i></b></p>
<p><i>/usr/local/net-snmp/bin/snmpwalk -v2c -c MyPass333 localhost system</i><br />
You should see something like the following:</p>
<p>###############################################</p>
<p>SNMPv2-MIB::sysDescr.0 = STRING: Linux gw-npj-sp 2.6.18-4-686 #1 SMP Mon Mar 26 17:17:36 UTC 2007 i686<br />
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10<br />
SNMPv2-MIB::sysUpTime.0 = Timeticks: (168913) 0:28:09.13<br />
SNMPv2-MIB::sysContact.0 = STRING: tekbdrlimbu@hotmail.com<br />
SNMPv2-MIB::sysName.0 = STRING: linux-box-hostname<br />
SNMPv2-MIB::sysLocation.0 = STRING: Kathmandu-Nepal<br />
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00</p>
<p>##############################################</p>
<p>Looks familiar doesn&#8217;t it? This is because we supplied the information in the snmpd.conf file!</p>
<p><i><b>Creating your 1st MRTG graph using SNMP</b></i></p>
<p>Assuming that you have did everything mentioned above correctly, then we will move on to generate a very simple graph showing the traffic status of your machine&#8217;s network interfaces.</p>
<p><b><i>(1.)  Create the directory to store your MRTG configuration (cfg) files. </i></b></p>
<p>mkdir -p /usr/local/mrtg-2/etc</p>
<p><b><i>(2.)  Create the directories to store your MRTG cfg files and it&#8217;s output files in your Apache DocumentRoot directory.</i></b></p>
<p>Assuming that you followed the steps outlined in the URL:</p>
<p><a href="http://teklimbu.wordpress.com/2007/10/08/configuring-apache-2x-with-php-5x-and-mysql-5x/" title="Apache installation" target="_blank">http://teklimbu.wordpress.com/2007/10/08/configuring-apache2</a></p>
<p>Then, your DocumentRoot will be the default &#8220;/usr/local/httpd/htdocs/&#8221; directory.</p>
<p>mkdir -p  /usr/local/httpd/htdocs/mrtg/traffic</p>
<p><b><i>(3.)  Run the cfgmaker tool installed from the MRTG package</i></b></p>
<p>/usr/local/mrtg-2/bin/cfgmaker &#8211;output=/usr/local/mrtg-2/etc/mrtg.cfg &#8211;global &#8220;workdir: /usr/local/httpd/htdocs/mrtg/traffic&#8221; -ifref=ip &#8211;global &#8216;options[_]: growright,bits&#8217; MyPass333@localhost</p>
<p>The above command will produce the output file &#8220;mrtg.cfg&#8221; and all graphs generated will be stored in  the &#8220;workdir&#8221; directory.</p>
<p>output file= /usr/local/mrtg-2/etc/mrtg.cfg</p>
<p>workdir=  /usr/local/httpd/htdocs/mrtg/traffic/</p>
<p><i><b>(4.)  Finally run the mrtg tool to generate the graphs.</b></i></p>
<p><i><b>         </b></i><br />
env LANG=C /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/etc/mrtg.cfg</p>
<p><i><b>(5.)  Your graphs should now be generated. Fire up your web browser and enter the IP address or hostname of your machine.</b></i></p>
<p>http://192.168.0.1/mrtg/traffic</p>
<p>If this machine is your desktop, simply type:</p>
<p>http://localhost/mrtg/traffic</p>
<p>Note:  Replace the IP above with the actual IP of your Linux machine.</p>
<p><i><b>(5.)  Generate your index.html file using the tool called indexmaker which comes with the MRTG package.</b></i></p>
<p>/usr/local/mrtg-2/bin/indexmaker &#8211;title=&#8221;Traffic Status&#8221; \</p>
<p>/usr/local/mrtg-2/etc/mrtg.cfg \</p>
<p>&gt;  /usr/local/httpd/htdocs/mrtg/traffic/index.html</p>
<p>You should see something like the following graph:</p>
<p align="center"><img src="http://farm3.static.flickr.com/2072/2086765264_bd59af0ddb.jpg?v=0" alt="eth0 traffic" height="135" width="500" /></p>
<p align="center"><i>Graph showing traffic analysis for eth0 </i></p>
<p><i><b>(6.)  We need to setup an entry in the cron table to update the MRTG graphs every 5 minutes. On a Linux or FreeBSD machine, you can do it the following way:</b></i></p>
<p>vi  /etc/crontab</p>
<p>##### Copy and paste the following #####</p>
<p>*/5    *    *    *    *     root env LANG=C /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/etc/mrtg.cfg   &gt; /dev/null 2&gt;&amp;1</p>
<p>Note: The above statement should be in a single line, i.e. no line breaks.</p>
<p>There you have it. Your graphs will update every 5 minutes indicating the traffic flow in your eth0 network interface.</p>
<p>Now that you have used cfgmaker to extract the traffic of the network interfaces of your Linux machine, it can be used on any network devices which support SNMP.</p>
<p>Moving on, to explore more about SNMP and MRTG, we will create a new configuration file which will generate graphs showing the CPU load, Memory Usage, TCP connections and disk partitions   of your Linux/Unix machine.</p>
<p>The cfg file used for this task is taken from the site: www.linuxhomenetworking.com. This is a great site for all level of Linux/Unix users.</p>
<p>MRTG and SNMP are covered in depth at:</p>
<p><a href="http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch22_:_Monitoring_Server_Performance" title="Linuxhomenetworking chaper 22" target="_blank">http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch22</a></p>
<p><a href="http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch23_:_Advanced_MRTG_for_Linux" title="Linuxhomenetworking chaper 23" target="_blank">http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch23</a></p>
<p>Having said that, let&#8217;s move on..</p>
<p><b><i>(1.)  Create a new directory for Apache to store the graphs</i></b></p>
<p>mkdir  -p  /usr/local/httpd/htdocs/mrtg/server</p>
<p><b><i>(2.)  Create a new configuration file called server-mrtg.cfg</i></b></p>
<p>vi   /usr/local/mrtg-2/etc/server-mrtg.cfg</p>
<p>##### Copy and paste the following:######</p>
<p>#####Start of server-mrtg.cfg########</p>
<p># Configuration file for non bandwidth server statistics<br />
#</p>
<p>#<br />
# Define global options<br />
#</p>
<p>LoadMIBs: /usr/local/net-snmp/share/snmp/mibs/UCD-SNMP-MIB.txt,</p>
<p>/usr/local/net-snmp/share/snmp/mibs/TCP-MIB.txt<br />
workdir: /usr/local/httpd/htdocs/mrtg/server</p>
<p>#<br />
# CPU Monitoring<br />
# (Scaled so that the sum of all three values doesn&#8217;t exceed 100)<br />
#</p>
<p>Target[server.cpu]:ssCpuRawUser.0&amp;ssCpuRawUser.0:MyPass333@localhost + ssCpuRawSystem.0&amp;ssCpuRawSystem.0:MyPass333@localhost + ssCpuRawNice.0&amp;ssCpuRawNice.0:MyPass333@localhost<br />
Title[server.cpu]: Server CPU Load<br />
PageTop[server.cpu]: &lt;H1&gt;CPU Load &#8211; System, User and Nice Processes&lt;/H1&gt;<br />
MaxBytes[server.cpu]: 100<br />
ShortLegend[server.cpu]: %<br />
YLegend[server.cpu]: CPU Utilization<br />
Legend1[server.cpu]: Current CPU percentage load<br />
LegendI[server.cpu]: Used<br />
LegendO[server.cpu]:<br />
Options[server.cpu]: growright,nopercent<br />
Unscaled[server.cpu]: ymwd</p>
<p>#<br />
# Memory Monitoring (Total Versus Available Memory)<br />
#</p>
<p>Target[server.memory]: memAvailReal.0&amp;memTotalReal.0:MyPass333@localhost<br />
Title[server.memory]: Free Memory<br />
PageTop[server.memory]: &lt;H1&gt;Free Memory&lt;/H1&gt;<br />
MaxBytes[server.memory]: 100000000000<br />
ShortLegend[server.memory]: B<br />
YLegend[server.memory]: Bytes<br />
LegendI[server.memory]: Free<br />
LegendO[server.memory]: Total<br />
Legend1[server.memory]: Free memory, not including swap, in bytes<br />
Legend2[server.memory]: Total memory<br />
Options[server.memory]: gauge,growright,nopercent<br />
kMG[server.memory]: k,M,G,T,P,X</p>
<p>#<br />
# Memory Monitoring (Percentage usage)<br />
#<br />
Title[server.mempercent]: Percentage Free Memory<br />
PageTop[server.mempercent]: &lt;H1&gt;Percentage Free Memory&lt;/H1&gt;<br />
Target[server.mempercent]: ( memAvailReal.0&amp;memAvailReal.0:MyPass333@localhost ) * 100 / ( memTotalReal.0&amp;memTotalReal.0:MyPass333@localhost )<br />
options[server.mempercent]: growright,gauge,transparent,nopercent<br />
Unscaled[server.mempercent]: ymwd<br />
MaxBytes[server.mempercent]: 100<br />
YLegend[server.mempercent]: Memory %<br />
ShortLegend[server.mempercent]: Percent<br />
LegendI[server.mempercent]: Free<br />
LegendO[server.mempercent]: Free<br />
Legend1[server.mempercent]: Percentage Free Memory<br />
Legend2[server.mempercent]: Percentage Free Memory</p>
<p>#<br />
# New TCP Connection Monitoring (per minute)<br />
#</p>
<p>Target[server.newconns]: tcpPassiveOpens.0&amp;tcpActiveOpens.0:MyPass333@localhost<br />
Title[server.newconns]: Newly Created TCP Connections<br />
PageTop[server.newconns]: &lt;H1&gt;New TCP Connections&lt;/H1&gt;<br />
MaxBytes[server.newconns]: 10000000000<br />
ShortLegend[server.newconns]: c/s<br />
YLegend[server.newconns]: Conns / Min<br />
LegendI[server.newconns]: In<br />
LegendO[server.newconns]: Out<br />
Legend1[server.newconns]: New inbound connections<br />
Legend2[server.newconns]: New outbound connections<br />
Options[server.newconns]: growright,nopercent,perminute</p>
<p>#<br />
# Established TCP Connections<br />
#</p>
<p>Target[server.estabcons]: tcpCurrEstab.0&amp;tcpCurrEstab.0:MyPass333@localhost<br />
Title[server.estabcons]: Currently Established TCP Connections<br />
PageTop[server.estabcons]: &lt;H1&gt;Established TCP Connections&lt;/H1&gt;<br />
MaxBytes[server.estabcons]: 10000000000<br />
ShortLegend[server.estabcons]:<br />
YLegend[server.estabcons]: Connections<br />
LegendI[server.estabcons]: In<br />
LegendO[server.estabcons]:<br />
Legend1[server.estabcons]: Established connections<br />
Legend2[server.estabcons]:<br />
Options[server.estabcons]: growright,nopercent,gauge</p>
<p>#<br />
# Disk Usage Monitoring<br />
#</p>
<p>Target[server.disk]: dskPercent.1&amp;dskPercent.2:MyPass333@localhost<br />
Title[server.disk]: Disk Partition Usage<br />
PageTop[server.disk]: &lt;H1&gt;Disk Partition Usage /usr and /var&lt;/H1&gt;<br />
MaxBytes[server.disk]: 100<br />
ShortLegend[server.disk]: %<br />
YLegend[server.disk]: Utilization<br />
LegendI[server.disk]: /usr<br />
LegendO[server.disk]: /var<br />
Options[server.disk]: gauge,growright,nopercent<br />
Unscaled[server.disk]: ymwd<br />
######End of server-mrtg.cfg#######</p>
<p><b><i>(3.)  Generate the MRTG graphs </i></b></p>
<p>env LANG=C /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/etc/server-mrtg.cfg</p>
<p><i><b>(4.)  Create the index.html file running indexmaker </b></i></p>
<p>/usr/local/mrtg-2/bin/indexmaker &#8211;title=&#8221;Server Status&#8221; \<br />
/usr/local/mrtg-2/etc/server-mrtg.cfg \<br />
&gt;   /usr/local/httpd/htdocs/mrtg/server/index.html</p>
<p>(5.)  Fire up your web browser and point it to:</p>
<p>http://192.168.0.1/mrtg/server/</p>
<p>or if this is your local machine</p>
<p>http://localhost/mrtg/server</p>
<p>You should see something like the following graphs:</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><img src="http://farm3.static.flickr.com/2114/2121889287_5d783bc4ed.jpg?v=0" alt="linux-server-mrtg" height="320" width="500" /></p>
<p align="center"><i>MRTG graph showing your server status</i></p>
<p align="center">&nbsp;</p>
<p align="left"><b><i>(6.)  Finally create a cron table entry to generate update these graphs every 5 minutes. </i></b></p>
<p align="left">&nbsp;</p>
<p align="left">vi  /etc/crontab</p>
<p align="left">&nbsp;</p>
<p align="left">###Copy and paste the following###</p>
<p align="left"> */5     *     *     *    *     root     env LANG=C /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/etc/server-mrtg.cfg</p>
<p align="left">&nbsp;</p>
<p align="left">That&#8217;s it. You have just created an effective method for monitoring your Linux/Unix box!</p>
<p align="left">Of course, MRTG is very versatile and can generate traffic graphs from your Squid proxy, Apache Web, Bind DNS, Qmail, routers, switches, just to mention a few. We will visit these topics in the coming days to come.</p>
<p align="left">Till then, enjoy monitoring your server with your newly generated MRTG graphs!</p>
<p align="left">&nbsp;</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/teklimbu.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/teklimbu.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/teklimbu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/teklimbu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/teklimbu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/teklimbu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/teklimbu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/teklimbu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/teklimbu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/teklimbu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/teklimbu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/teklimbu.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=6&subd=teklimbu&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://teklimbu.wordpress.com/2007/12/05/monitoring-your-linuxunix-servers-and-network-devices-using-mrtg-and-snmp/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dac1f65f8303afbf89a5d1d2c98c8e8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">teklimbu</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2072/2086765264_bd59af0ddb.jpg?v=0" medium="image">
			<media:title type="html">eth0 traffic</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2114/2121889287_5d783bc4ed.jpg?v=0" medium="image">
			<media:title type="html">linux-server-mrtg</media:title>
		</media:content>
	</item>
		<item>
		<title>WWW, Open Source and Nepal</title>
		<link>http://teklimbu.wordpress.com/2007/11/23/www-open-source-and-nepal/</link>
		<comments>http://teklimbu.wordpress.com/2007/11/23/www-open-source-and-nepal/#comments</comments>
		<pubDate>Fri, 23 Nov 2007 09:47:11 +0000</pubDate>
		<dc:creator>teklimbu</dc:creator>
				<category><![CDATA[ISP]]></category>
		<category><![CDATA[Nepal]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[VSAT]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://teklimbu.wordpress.com/2007/11/23/www-open-source-and-nepal/</guid>
		<description><![CDATA[
I am diverting from my regular technical articles regarding operating systems and softwares to a different topic. This article represents the general aspect of the internet services provided in Nepal and also gives general information of my country.
The Internet is making the world smaller, that&#8217;s the latest buzz we hear everyday. A day never goes [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=17&subd=teklimbu&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Flinux_unix%2FWWW_Open_Source_and_Nepal' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
<p>I am diverting from my regular technical articles regarding operating systems and softwares to a different topic. This article represents the general aspect of the internet services provided in Nepal and also gives general information of my country.</p>
<p>The Internet is making the world smaller, that&#8217;s the latest buzz we hear everyday. A day never goes and passes by without the mention of the word &#8220;GOOGLE&#8221;. Everybody around the world seems to be bracing social networking such as Facebook, Orkut, Bebo or Myspace.</p>
<p>However, to a 3rd world country like Nepal, does it really matter?</p>
<p>Let me brief the audience about Nepal in a few sentences.</p>
<p><span id="more-17"></span></p>
<p>Nepal is a land locked country and home place of natural beauty. The northern <i>Himalayan </i>range is covered with snow over the year where the highest peak of the world, the <i>Mount Everest</i>, stands tall at<b> 29029 feet</b>. The middle <i>Hill </i>range is surrounded and covered by beautiful mountains, high hill peaks, valleys and lakes. Nepal&#8217;s total area coverage is <b>147,000</b> square meters. Natural resources like lakes and rivers give Nepal the advantage and edge for producing hydro electricity.</p>
<p>Nepal has a huge potential of hydro power that comes to about <b>83,000                MW</b> out of which <b>43,000 MW</b> is economically viable.</p>
<p>According to statistics, <b>5000 megawatts</b> (MW) of power can serve 5 million average homes. If we consider that the average household in Nepal has 6 persons, then 5000 MW of energy can serve a population of 28 million. That is roughly equal to the population of Nepal which is approximately 28 million.</p>
<p>We will have a surplus of <b>38,000 MW</b> of hydro power! This surplus energy can be exported and utilized in different sectors including technology, education, health care, manufacturing, etc. In fact, Water to Nepal is what Oil is to Iraq!</p>
<p>To the dismay of the reader, which is sad but true, however only about 700 MW is currently being utilized! That is less than <b>2%</b> of the total potential hydro power energy that Nepal can produce!</p>
<p>The point that I am trying to make is that more could be done to tap this vast amount of hydro power out of which a fraction can be invested in building high speed multiple fiber optical lines connecting Nepal to the rest of the Internet.</p>
<p>Remember that we are sandwiched between China and India which are the fasting growing economical countries in the world. They both have superior technical infrastructures and high speed fiber optical carriers. By sharing borders with both of them (China 1,236 km, India 1,690 km), this is in fact an advantage for Nepal in terms of getting fiber optical data carriers from them.</p>
<p><img src="http://farm3.static.flickr.com/2221/2030300229_1d7e228d60.jpg?v=0" alt="Map Of Nepal" height="326" width="500" /></p>
<p align="center"><i>The 3 geographical divisions of Nepal. Courtesy of www.nepalvista.com </i></p>
<p>Nepal is also a very diverse country with more more than 100 caste/ethnic groups speaking more than 75 different dialects with the total population being at 28 million at 2006.</p>
<p>The preliminary estimate of per capita GDP is just U.S. $ 315. Thirty-one (31%)  percent of the population live below the absolute poverty line. The GDP growth is a minimal 2.3 % but this too is overshadowed by the population growth at 2.25 %.</p>
<p>Due to this factors, it&#8217;s hardly surprising that Nepal rank near the bottom of virtually every measure of development.</p>
<p>The active Internet users in Nepal is only about 175,000 with approximately 9 local ISPs. Now if we compare 175,000 internet users with the population of 28 million, that&#8217;s less than 1%. Therefore, I believe that Information Technology (IT)  has more room and a bright future in Nepal.</p>
<p>With only negative data and values, does Nepal have a future in the internet? Or can Nepal benefit from the internet and the world wide web? Yes it can. How? Effective governance, efficient use of man power and by using open source technologies to power the Internet for Nepal.</p>
<p>Due to various political events during the past 2 years, a lot of  the internal level of fighting inside the country has resided. This is given new hopes for peace and prosperity to the  people of Nepal. I don&#8217;t think that matters will get any worse from here onwards because we have already faced the worst! Nepal deserves better times and better growth in the coming years.</p>
<p><img src="http://farm3.static.flickr.com/2269/2030324715_ccb95837e5.jpg?v=0" alt="Map Of Nepal 2" height="253" width="500" /></p>
<p align="center"><i>Major Towns in Nepal having internet connectivity. Courtesy of www.nepalvista.com </i></p>
<p align="center">&nbsp;</p>
<p>Being a third world country brings it&#8217;s own share of technical burdens. High speed fiber optical lines generally do not exists in 3rd world countries like Nepal. Or simply, getting internet bandwidth via underground fiber optical carriers is not economically viable to private ISPs. The government owned Internet Service Provider despite having fiber optical data connections is almost non existent or simply is not utilizing it&#8217;s full capacities.</p>
<p>Therefore, satellites had and have been playing a major role for relaying international bandwidth from Nepal to the rest of the Internet network.</p>
<p>Below is a description of how many third world countries like Nepal get access to the Internet.</p>
<p>There are over 300 communications satellites in the geostationary orbit, directly above the equator, spaced typically 2 or 3 degrees apart. Because they orbit the earth at the same speed and in the same direction as the earth rotates they remain fixed in the sky and we can use a fixed pointing Very Small Aperture Terminal (VSAT) to communicate.</p>
<p>For Internet traffic, we use a geosynchronous based satellite for communication. A geosynchronous satellite is a satellite whose orbital track on the Earth repeats regularly over points on the Earth over time.</p>
<p>If such a satellite&#8217;s orbit lies over the equator, it is called a geostationary satellite. The orbits of the satellites are known as the geosynchronous orbit and geostationary orbit.</p>
<p>When satellites communicate with each other, the portion of the radioelectric phantom that they will use determines practically everything: the capacity of the system, the power and the price. The different wavelengths have different properties. The long wavelengths can cross great distances and cross obstacles.</p>
<p>The most common frequencies used for Satellite based internet networks are C band (3700-6425 MHz) and Ku band (10,700-12,7500 MHz). A simple diagram  illustrating this satellite setup is shown below</p>
<p><img src="http://farm3.static.flickr.com/2128/2046641852_15ef369daf.jpg" alt="VSAT Satellite Setup" height="380" width="500" /></p>
<p><i><b>Typical ISP Internet Network Operation Setup via satellite<br />
</b></i></p>
<p>Actually satellite based internet services are not really bad or unreliable. In fact, it is very stable and reliable too. Bandwidth speeds up to 100 mbps (downlink) and 50 mbps (uplink) can be achieved using this types of Satellite mediums.</p>
<p>The 1st major disadvantage of using satellites (VSAT) is a result of their high altitude: radio signals take approximately 0.25 of a second to reach and return from the satellite, resulting in a small but significant signal delay. This delay increases the difficulty of telephone conversation and reduces the performance of common network protocols such as TCP/IP, but does not present a problem with non-interactive systems such as television broadcasts.</p>
<p>This is also the reason why we get to see the minimum latency of 500 ms while connecting to international networks.</p>
<p>The 2nd major disadvantage of using satellites (VSAT) is the high price for international bandwidth resulting in significant bandwidth prices for the average internet user.</p>
<p>Besides the necessary satellite equipments such as the satellite modem, DVB modem,  router and switch, all other servers providing critical internet services are based on Open Source software which of course are stable, secure, flexible and most importantly FREE.</p>
<p>Moving on, you can see that we need a minimum of 7 Linux/Unix servers. This comprises the following:</p>
<p><b>(1.)  Bandwidth Manager (B/W Mgr) running on Linux and using HTB.</b></p>
<p>This server running with a Linux kernel greater than 2.4.20 will act as bandwidth shaper which will shape the bandwidth of clients. The shaping is done using special tools from the <b>iproute2 </b>package which consists of the program <b>tc </b>(traffic controller).<br />
It uses the <b>HTB </b>queuing technique to shape, rate-limit, priorizing and share the<br />
bandwidth. In addition to <b>HTB</b>, the <b>Mangle </b>table of <b>IPTABLES </b>are used to for mangling packets. It is used to change the <b>TOS</b>, <b>TTL </b>and <b>MARK </b>values of <b>IP </b>packets. This machine will have at least <b>3 network interfaces</b>.</p>
<p>The other main purpose of this server is to provide <b>Firewall </b>services in addition with the router to protect the whole network behind it.</p>
<p><b>(2.)  FreeRadius and Database server running on Linux/FreeBSD for authentication and  accounting purposes.</b></p>
<p>This server  will be running the software or service called <b>FreeRadius </b>which will be used for Authentication and Accounting purposes for various types of network access.</p>
<p>In addition to authentication, an <b>SQL  </b>database (Mysql, PostgreSQL, Oracle) will store all information including traffic volume, time volume, account types and all other tables used for accounting purposes.</p>
<p>In simple terms, for an ISP, this server provides the basis for accounting and billing of it&#8217;s customers.</p>
<p><b>(3.)  Bind DNS server running on Solaris/FreeBSD for providing Domain Name Services.</b></p>
<p>DNS is the service which translates a hostname  (www.example.com) to an IP address (123.123.123.123).</p>
<p>An <b>IP address</b> (<b>Internet Protocol address</b>) is a unique address that computers and network devices use in order to identify and communicate with each other on a network.</p>
<p>An IP address, uses 32-bit values, usually represented in dotted-decimal notation (four numbers, each ranging from 0 to 255, separated by dots, e.g. 123.123.123.123).</p>
<p>Without DNS,  in order to browse a website such as www.cnn.com, we would have to type it&#8217;s computer&#8217;s IP address. Now imagine the consequences without having DNS service.</p>
<p>Or Simply, if DNS do not exists, <b>98%</b> of all networks connected to the Internet would be impossible to be accessed! Or we will have keep a very very long list mapping the IP address to each of the individual computer connected to the Internet. To be exact, we will have to keep an IP address book with <b>120 million </b>IP addresses.</p>
<p>Similarly, reverse DNS maps an IP address to it&#8217;s hostname. Reverse DNS is mainly used by Email systems for anti-spamming purposes.</p>
<p><b>(4.)  Postfix/Qmail SMTP Server running on FreeBSD offering SMTP, IMAP, POP services.</b></p>
<p>It is believed that 70 % of all internet users uses it for Email purposes. A <b>mail transfer agent</b> or <b>MTA</b> is a computer program or software agent that transfers electronic mail messages from one computer to another.</p>
<p>A <b>MTA </b>speaks the <b>SMTP </b>protocol is used by all email systems on the internet to interact with different mail systems. Therefore, to provide email services, Unix systems since the 1970s have deployed the software called <b>Sendmail</b>. However, due to many security exploits in the <b>Sendmail </b>MTA<b>, </b>other MTAs such <b>Postfix </b>or <b>Exim </b>are deployed these days. The <b>Qmail </b>MTA also has a large installation base.</p>
<p><b>(5.)  Squid Proxy Server running on Solaris/FreeBSD for caching web traffic for improved performance and bandwidth savings.</b></p>
<p>A proxy server is a machine which services the web requests of its clients by forwarding requests to other servers. A proxy server may service requests without contacting the specified server, by retrieving content saved from a previous request, made by the same client or even other clients. This is also called caching.</p>
<p>Caching proxies keep local copies of frequently requested resources, allowing large organizations and ISPs to significantly reduce their upstream and downlink bandwidth usage and cost, while at the same time increasing performance significantly.<br />
In reality, a proxy server can save as much as <b>30-50%</b> of the actual bandwidth utilization and costs by serving content from it&#8217;s cache and it&#8217;s siblings.</p>
<p><b>(6.) PPPoE Server running on FreeBSD for authenticating PPPoE clients and PPPoE traffic control.</b></p>
<p>PPPoE, Point-to-Point Protocol over Ethernet, is a network protocol for encapsulating PPP frames inside Ethernet frames.<br />
Ethernet networks are packet-based and have no concept of a connection or circuit. But using PPPoE, users can virtually &#8220;dial&#8221; from one machine to another over an Ethernet network, establish a point to point connection between them and then transport data packets over the connection.<br />
PPPoE is also a specification for connecting multiple computer users on an Ethernet local area network to a remote site through common customer premises equipment, which could be a SM modem, ADSL modem, Cable modem or simply a cable line distributed from our Cable network.<br />
To handle PPPoE authentication requests, shape bandwidth for PPPoE clients and to route it&#8217;s traffic, we will need this PPPoE server.</p>
<p><b>(7.)  Web Server for providing web hosting services and control panel running on Solaris/FreeBSD/Linux.</b></p>
<p>This web hosting server will provide clients the necessary tools to host their own websites accessible via the World Wide Web (WWW).</p>
<p>Typically, once their choice of domain names (www.thisismysite.com) are registered, clients are given a certain amount of storage on the web hosting server and a control panel to manage various services like web pages, FTP, Email, etc.  For an e-commerce site, <b>Secure Sockets Layer</b> (<b>SSL</b>) is required which provides secure communications using cryptographic protocols.</p>
<p>We normally use the term <b>LAMP </b>(Linux, Apache,Mysql,PHP) or <b>SAMP </b>(Solaris, Apache, Mysql,PHP)   or <b>FAMP </b>(FreeBSD, Apache, Mysql, PHP) <span>as the platform of choice for the development and deployment of high performance web applications. These are minimum features any web developer wants supported on his/her web hosting platform.</span></p>
<p><i>We will go through the details of setting up each of these servers in future articles.</i></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>The <b>7 servers</b> mentioned above are the absolute minimum setup required for a small ISP. If the customer base grows, there will be a need to add more hardware devices and servers. In fact, for an ISP serving 30,000 customers, the number of different servers required range anywhere from 50 &#8211; 600.</p>
<p>Regarding the server&#8217;s hardware, a refurbished Dell GX-270 machine costs U.S. $250 and an entry level Dell SC-430 costs about U.S.$ 599. Besides that, all we need is Free Open Source software and a few good system administrators to utilize them.</p>
<p>Now imagine a middle size ISP running 500 servers based on Open Source operating systems and softwares. If those 500 servers were running Windows based operating systems which costs in the range of $999 &#8211; $3,999 and multiply that amount by 500, you can actually see the total costs sky rocketing.</p>
<p>Even on the 7 servers setup in the diagram above, we are already saving a minimum of U.S.$ 7,000.</p>
<p>And we still have not added the extra costs for other softwares besides the operating systems!!</p>
<p>Frankly speaking,  open source softwares can fulfill 95 % of the total demands for an ISP with the remaining 5 % being fulfilled by Windows based products.</p>
<p>Given that the government and private parties can work out a solution mutually, then I can foresee the internet user base grow from the current 175,000 mark to 2,000,000 within a period of 5 years.</p>
<p>That is because the Nepali government have the capacity to deliver Dial-UP and DSL internet services up to 1,000,000 clients. With help from neighboring countries, a high speed fiber optical internet gateway has already been installed. Now if the government decides to share this fiber optical line with the private ISPs, imagine the speed improvements and the reduced internet costs! The private ISPs already have stable wireless networks and cable networks just to mention a few.</p>
<p>So I believe that the 2 million internet users mark can be achieve easily. The only remaining part is to educate our citizens regarding information technology. And I am sure it will start with introducing them to the world of open source.</p>
<p>How will Nepal actually benefit from the Internet and it&#8217;s vast amount of resources. The 2 most importance sectors are E-commerce and Education.</p>
<p><b>(1.)  E-commerce</b></p>
<p>Nepal produces one of the best handmade carpets in the world. The carpets are hand-woven  first, then are, washed, trimmed, stretched and fine-trimmed for finishing by hand. Currently most of those carpets are exported to European and North American countries using a very traditional and tedious method.</p>
<p>The same goes for handicrafts, garments and other exports. Now, if the manufacturer deploys a small IT department to provide a website providing various information of it&#8217;s products and a secure site for e-commerce, it will improve the speed of the transaction tremendously.  This will also guarantee the overall quality and cheaper prices for the products because they clients will be purchasing directly from the manufacturer.</p>
<p>Introducing e-commerce in this sector will go a long way to benefit this under estimated economy.</p>
<p><b>(2.)  Education</b></p>
<p>Education is the ultimate tool for the development of any country. In fact, I believe, that education is directly proportional to the economy and development of a country given it follows healthy standard. Take for example, Singapore, which places Education and Healthcare in the topmost priority. Since gaining it&#8217;s independence in 1965, it achieved it&#8217;s status from being a third world country to being the most advanced and dynamic country in the world within a single generation. To be exact, it took Singapore just 26 years to develop from a village to become the most advanced financial hub in the world! If there is any country where Nepal can learn and get inspired, then it&#8217;s going to be Singapore.</p>
<p>In the past fifty years in Nepal, there has been a dramatic expansion of educational facilities. Beginning with about ten thousand students in 1951, there now are approximately 5.5 million students.</p>
<p>However, there are many defects, problems and challenges with the education system in Nepal. Educational management, it&#8217;s qualities and it&#8217;s access are some of the critical issues haunting Nepal.  There is too much social disparities based on gender, ethnicity, economic class, etc.  Primary resources like books, proper classrooms, properly trained  teachers are always below required level.</p>
<p>And most important of all,  political parties should stop the politics practiced in schools and stop the poisoning of our education system with unwanted politics.</p>
<p>I believe that providing a couple of internet connected computers in every school will give some life to our education system. This way, students will get access to all kinds of study materials, learn about different education cultures and approaches, apply for online study courses among other things and of course make new acquaintances.</p>
<p>It should also be noted that 50% of the population in Nepal falls under than age of 30 years. In fact, this will be the next generation who will drive and lead this gorgeous and beautiful country. Therefore, providing quality education should be the number 1 priority.</p>
<p>We have the capabilities to deliver internet content even to remote areas and villages in different parts of the country. It&#8217;s just that it&#8217;s impractical and impossible financially for private business ventures to actually setup a internet hub in those places.</p>
<p>However, this can be changed if private ISPs get the support from the government and international donor agencies.</p>
<p>We have a 800,000 workforce working abroad, some working as Gurkhas in the British army and the Singaporean police force while others are contributing to the man power in the Gulf and Malaysia. They contribute a total remittance value worth around U.S. $ 1 billion.</p>
<p>If you compare that amount to the government&#8217;s yearly budget which is about US$1.2 billion, they will be on par with each other!</p>
<p>If we can utilized this capital, promote tourism and manage our water resources intelligently, then, I believe that every family in Nepal will get internet connectivity within a single generation.</p>
<p>Getting internet content to these homes will of course be powered by Open Source technology.</p>
<p>Finally, I will end this article saying that Nepal is not a POOR country and she can definitely become fully independent herself. We just don&#8217;t seem to realize that we are a chicken hen which can actually lay golden eggs if she wants!</p>
<p style="text-align:center;"><img src="http://farm3.static.flickr.com/2213/2056250289_6d81ed3a3f.jpg?v=0" height="256" width="213" /></p>
<p align="center"> Long Live Nepal!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/teklimbu.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/teklimbu.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/teklimbu.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/teklimbu.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/teklimbu.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/teklimbu.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/teklimbu.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/teklimbu.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/teklimbu.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/teklimbu.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/teklimbu.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/teklimbu.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=17&subd=teklimbu&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://teklimbu.wordpress.com/2007/11/23/www-open-source-and-nepal/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dac1f65f8303afbf89a5d1d2c98c8e8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">teklimbu</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2221/2030300229_1d7e228d60.jpg?v=0" medium="image">
			<media:title type="html">Map Of Nepal</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2269/2030324715_ccb95837e5.jpg?v=0" medium="image">
			<media:title type="html">Map Of Nepal 2</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2128/2046641852_15ef369daf.jpg" medium="image">
			<media:title type="html">VSAT Satellite Setup</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2213/2056250289_6d81ed3a3f.jpg?v=0" medium="image" />
	</item>
		<item>
		<title>An Encounter with Solaris 10</title>
		<link>http://teklimbu.wordpress.com/2007/10/30/an-encounter-with-solaris-10/</link>
		<comments>http://teklimbu.wordpress.com/2007/10/30/an-encounter-with-solaris-10/#comments</comments>
		<pubDate>Tue, 30 Oct 2007 07:01:27 +0000</pubDate>
		<dc:creator>teklimbu</dc:creator>
				<category><![CDATA[solaris]]></category>

		<guid isPermaLink="false">http://teklimbu.wordpress.com/2007/10/30/an-encounter-with-solaris-10/</guid>
		<description><![CDATA[
2 weeks ago, our main festival started for which we had 5 days off! Now that is a considerable amount of free time to any system administrator. Free time to system administrators gives us the ability to think freely from the daily workload and unnecessary pressure.
Before the holidays started, I had decided to learn something [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=16&subd=teklimbu&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Fsoftware%2FSolaris_Operating_System_Get_Solaris_10' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
<p>2 weeks ago, our main festival started for which we had 5 days off! Now that is a considerable amount of free time to any system administrator. Free time to system administrators gives us the ability to think freely from the daily workload and unnecessary pressure.</p>
<p>Before the holidays started, I had decided to learn something new to further enhance my experience and understanding about the open source operating systems world. I am not really an expert on Linux or BSD based operating systems. However, I do have some years of experience with Redhat and Debian based Linux operating systems. Since 2 years back, I have been running some server stuffs mostly on FreeBSD operating systems.</p>
<p>Trying out Gentoo has always been on my mind but I thought it&#8217;s Linux after all and suddenly Solaris came to my mind. I have to admit that I had always been biased to Solaris. I thought that it was not really an open source operating system and it ran only on those weird looking SPARC boxes manufactured by Sun Microsystems.</p>
<p>But I was wrong! Solaris seems to be full of promises and definitely seems to be the operating system of the future. In fact, it is probably the only Unix operating system which still contains the original Unix code when Unix was first developed in the 1970s. That may explain why it&#8217;s stability is so rock solid.</p>
<p><span id="more-16"></span></p>
<p>And I learned that it&#8217;s almost as free and open source like the GPL or BSD license!  A majority of the codebase has been open-sourced by Sun Microsystems.</p>
<p>Solaris&#8217; source code (with a few exceptions) has been released under the <a href="http://en.wikipedia.org/wiki/Common_Development_and_Distribution_License" target="_blank" title="Common Development and Distribution License">Common Development and Distribution License</a> (CDDL) via the <a href="http://en.wikipedia.org/wiki/OpenSolaris" target="_blank" title="OpenSolaris">OpenSolaris</a> project. The CDDL is an OSI-approved license. It is considered by the <a href="http://en.wikipedia.org/wiki/Free_Software_Foundation" target="_blank" title="Free Software Foundation">Free Software Foundation</a>  to be free but incompatible with the <a href="http://en.wikipedia.org/wiki/GNU_General_Public_License" target="_blank" title="GNU General Public License">GPL</a>.</p>
<p>As I searched and read more articles and reviews about the Solaris 10 operating systems, 3 strong points stood out in almost all of the articles and reviews. They are ZFS, DTrace and Containers.</p>
<ul>
<li><b>(A.) ZFS </b></li>
</ul>
<p>The first  is <span style="font-weight:bold;">ZFS </span>(Zettabyte File System) which is a 128-bit file system, so it can store 18 billion billion (18 x billion x billion) times more data than current 64-bit systems! <span style="font-style:italic;">Quoting from the OpenSolaris project, ZFS is a new kind of file system that provides simple administration, transactional semantics, end-to-end data integrity, and immerse scalability.</span></p>
<p>ZFS has an inbuilt Volume Manager and ZFS file systems are built on top of virtual storage pools called <span style="font-style:italic;font-weight:bold;">zpools</span>. Zpools may be configured in different ways such as RAID-0, RAID-1, RAID-Z or RAID-Z2 using cheap disks. Because cheap disks can fail, so ZFS provides  disk scrubbing which is to read all data to detect latent errors while they are still correctable.</p>
<p>In a sentence, ZFS is a totally different rewrite of existing file systems and is actually supposed to be very simple and fun to use.</p>
<p>I believe that ZFS will be the predominate file system to be deployed in data centers all over the world in the not to distance future!</p>
<p>To sum it up, check out the cool and amusing video below:</p>
<p><a href="http://video.google.com.au/videoplay?docid=8100808442979626078" title="ZFS Video">http://video.google.com.au/videoplay?docid=8100808442979626078 </a></p>
<ul>
<li><b>(B.) DTrace </b></li>
</ul>
<p>The second convincing point of Solaris 10 is it&#8217;s <i><b>DTrace </b></i>utility. It is a comprehensive dynamic tracing framework for Solaris. It is built into Solaris so that it can be used by admins and developers to examine the behavior of user programs and operating system itself. Quoting from the dtrace blog at blogs.sun.com/dtrace/entry/what_is_dtrace&#8230;</p>
<p><i>DTrace </i>dynamically modifies the Operating System kernel itself and user processes. It records the data at locations of interest called probes. <i>DTrace </i>uses the <i><b>D </b></i>scripting language (a subset of the <i><b>C</b></i> language), designed specifically for dynamic tracing.  Users write scripts in <i><b>D </b></i>which tell <i>DTrace</i>, what functions are to be traced, what is to be done and what information is required. So if there is an mis-configured application out there in your system to which you are finding hard to debug and trace, then <i>DTrace </i>should do it for you.</p>
<p>Since it is dynamic,  when Dtrace is in use or in action, only those modules that are needed by a particular command are loaded and used. This will greatly improve performance since lesser resources are required or accessed.</p>
<p>And according to it&#8217;s documentation, <i>DTrace </i>is completely safe to use. It will never you to damage the system through it&#8217;s use. But I have to admit that I have never used <i>DTrace </i>extensively and only time and experience will tell us if <i>DTrace </i>is indeed suppose to be a sysadmin&#8217;s best friend!</p>
<p>However, although <i>DTrace </i>is supposed to be the most powerful tracing and debugging utility in the world, using it can prove to be very challenging.</p>
<p>Since it both a tool and a scripting language, learning to use it effectively can be quite tough. But there are some graphical based programs utilizing DTrace appearing in the market which should make DTrace more easier to use. One of them is &#8220;Chime&#8221;, which can be downloaded from:</p>
<p><a href="http://www.opensolaris.org/os/project/dtrace-chime/" title="Chime Visualization Tool for DTrace" target="_blank">http://www.opensolaris.org/os/project/dtrace-chime/ </a></p>
<ul>
<li><b>(C.) Containers </b></li>
</ul>
<p>The third notable point of Solaris 10 is <i><b>Zones </b></i>or <i><b>Containers</b></i>. If you have used <i>FreeBSD jails</i>, then Solaris <i>Containers </i>are going to be familiar. They are based on the same basic concept. Each <i>Container </i>is like a virtual OS, complete with IP address, separate configuration and even a separate package manager.</p>
<p>This may seem similar to <i>VMware </i>or <i>Xen </i>but it isn&#8217;t. The difference is that all the <i>Zones/Containers/Jails</i> share the same kernel. Using Zones, we can use just one  server allocating different applications to different groups. Administrators can configure CPU, memory, network bandwidth as they wish to each secured container. The end result is better utilization of expensive hardware and fewer physical systems to house and power.</p>
<p>Moving forward, the first step of installation software is to check if it meets the hardware requirements. You can visit the URL below to check to make sure if your hardware is supported:</p>
<p><a href="http://www.sun.com/bigadmin/hcl/" title="Solaris Hardware Compatibility Lists">http://www.sun.com/bigadmin/hcl/</a></p>
<p>From my experience with Linux and FreeBSD based operating systems, even, if your hardware is not yet supported on OS platforms, there is always a way or a  hack to make your hardware devices work. So you don&#8217;t really have to worry if your hardware is not yet supported. Since I will probably be using Solaris on a server platform, I did not have to worry about devices such as sound cards or graphical cards being not supported yet!</p>
<p>The next big step is the actual installation of Solaris 10 itself. Just follow either of the 2 excellent guides below and your Solaris box will be up and running within 2 hours!</p>
<p><a href="http://www.blastwave.org/docs/s10u3_howto.html" title="Blastwave Full Installation Guide" target="_blank">http://www.blastwave.org/docs/s10u3_howto.html</a></p>
<p>Or</p>
<p><a href="http://www.sun.com/software/solaris/howtoguides/installationhowto.jsp#1" title="Sun Installation Guide" target="_blank">http://www.sun.com/software/solaris/howtoguides/installationhowto.jsp#1</a></p>
<p>The following are the basic questions you will be asked in order to setup a fully functional Solaris networked box:</p>
<p><b>(1.)  Your IP address, subnet mask and default gateway</b></p>
<p><b>(2.)  Your hostname for this Solaris box</b></p>
<p><b>(3.)  Your time zone</b></p>
<p><b>(4.)  The Root password of this box (keep it simple for the 1st time. You can later change it later!). There is nothing worse than forgetting the root user&#8217;s password after the complete installation!!!</b></p>
<p><b>(5.)   Selecting and enabling the network services.</b></p>
<p><b>(6.)  The rest of the installation are just a matter of selections with either a &#8220;Yes&#8221; or &#8220;No&#8221;!</b></p>
<p><b>(7.) Selecting the primary boot disk and allocate the partitions for Solaris. You may just want to accept the defaults here if you are confused.   </b></p>
<p><b>(8.) The last step of the installation will ask you to &#8220;reboot&#8221;. Remember to remove your Solaris CD from your cd-rom before rebooting!  </b></p>
<p>Note: The images below are the actual snapshots from <a href="http://www.blastwave.org/" title="Blastwave's version of Debian apt-get (pkg-get)" target="_blank">http://www.blastwave.org</a></p>
<p>One image has also been used from wikepedia.</p>
<p>In fact, I have never seen or read an OS installation guide as detailed and informative like the one created by the folks at www.blastwave.org! Thanks a lot blastwave.org and great work folks.</p>
<p>They should also be given an applause for creating a &#8220;Debian like apt-get&#8221; package management tool with &#8220;pkg-get&#8221; for Solaris.</p>
<p>After the installation is complete, your will see a very nice and beautiful screen like the one below:</p>
<p><img src="http://www.blastwave.org/docs/images/s10u3/122.png" alt="Solaris Login Screen" height="464" width="620" /></p>
<p align="center"><i>Solaris Login Screen (image from blastwave.org)</i></p>
<p>Wow that&#8217;s cool! Who would have thought that Solaris installation is this easy! I am quite surprised. So Ubuntu should watch out!</p>
<p>The next step is to create a normal user/group account. In the Linux/Unix world, it&#8217;s often considered a bad thing to login as root either remotely or locally! It  will also compromise the security of your system!</p>
<p>Select &#8220;Command Line Login&#8221; from the &#8220;Options&#8221; menu of your Login Screen.</p>
<p>We will create a User called &#8220;admin&#8221; and a group called &#8220;wheel&#8221;. Then we will add user &#8220;admin&#8221; to the &#8220;wheel&#8221; group.</p>
<p>Run the following command on the root&#8217;s console:</p>
<p>#  groupadd  wheel</p>
<p>#  useradd -c &#8220;admin&#8221; -d /export/home/admin  -g wheel -m -s /bin/bash admin</p>
<p># passwd  admin</p>
<p>Exit from the command line shell and use your newly created Username and Password to login.</p>
<p>You will then be prompted to select a default Desktop Window Manager. Just select  Select &#8220;Java Desktop System Release 3&#8243;  because  it&#8217;s much more flexible and is in fact Solaris&#8217;s version of the Gnome Desktop!<br />
<img src="http://www.blastwave.org/docs/images/s10u3/146.png" alt="Sun Java Desktop " height="480" width="640" /></p>
<p align="center"><i> Solaris Desktop (image from blastwave.org)</i><br />
That&#8217;s great graphics which I did not expected from Solaris! Below are 2 more snapshots of the Sun Java Desktop running Gnome.
</p>
<p align="center"><i><img src="http://www.blastwave.org/docs/images/s10u3/148.png" alt="Java Desktop running Gnome" height="600" width="800" /></i></p>
<p align="center">&nbsp;</p>
<p align="center"><i>Screenshot 1 of Sun Java Desktop running Gnome (blastwave.org)</i></p>
<p align="center">&nbsp;</p>
<p><img src="http://upload.wikimedia.org/wikipedia/en/2/25/Solaris10.jpg" alt="Sun Java Desktop Snapshot 2" height="300" width="400" /></p>
<p><i>Screenshot 2 of Sun Java Desktop running Gnome (wikipedia.org)</i></p>
<p>Next we will setup our DNS servers for our Solaris box and connect our new Solaris box to the rest of our network and to the internet.</p>
<p><b> (1.)  Edit the file /etc/inet/resolv.conf</b></p>
<p>vi   /etc/inet/resolv.conf</p>
<p><b>(2.)  Type in your name servers to make /etc/inet/resolv.conf look something like the following:</b></p>
<p>search  example.com</p>
<p>nameserver  192.168.1.1</p>
<p>nameserver  IP.OF.ISP.DNS_SERVER</p>
<p>Of course, you need to change the above to reflect to your own name server!</p>
<p><b>(3.)  Create a symbolic link of /etc/inet/resolv.conf  to /etc/resolv.conf</b></p>
<p>ln  -s  /etc/inet/resolv.conf   /etc/resolv.conf</p>
<p><b>(4.)   Edit  /etc/nsswitch.conf  to use your DNS settings for name resolving.</b></p>
<p>vi    /etc/nsswitch.conf</p>
<p>Add the following &#8220;dns&#8221; entry to /etc/nsswitch.conf to look something like:</p>
<p>hosts    files    dns</p>
<p><b>(5.)   Verify your default router in   /etc/defaultrouter  and make sure that your gateway is listed in that file!</b></p>
<p>cat   /etc/defaultrouter</p>
<p><b>(6.)  Verify the hostname and IP address for your new Solaris machine.</b></p>
<p>cat   /etc/hosts</p>
<p>cat  /etc/ipnodes</p>
<p>Next time, if you have to change your machine&#8217;s hostname or IP address, then these are the files where you have to look into.</p>
<p><b>(6.)  Open a shell prompt and verify that you can ping other hosts on the Internet such as yahoo.com or google.com. Or just fire your web browser and make sure that you can access websites!</b></p>
<p># ping www.yahoo.com<br />
www.yahoo.com is alive<br />
# ping -s www.yahoo.com<br />
PING www.yahoo.com: 56 data bytes<br />
64 bytes from f1.www.vip.sp1.yahoo.com (209.131.36.158): icmp_seq=0. time=604. ms<br />
64 bytes from f1.www.vip.sp1.yahoo.com (209.131.36.158): icmp_seq=1. time=1.05e+03 ms<br />
64 bytes from f1.www.vip.sp1.yahoo.com (209.131.36.158): icmp_seq=2. time=602. ms<br />
64 bytes from f1.www.vip.sp1.yahoo.com (209.131.36.158): icmp_seq=3. time=684. ms<br />
64 bytes from f1.www.vip.sp1.yahoo.com (209.131.36.158): icmp_seq=4. time=605. ms</p>
<p>The high latency of the above ping results is due to my satellite based link!!</p>
<p>Well that&#8217;s it! You have your Solaris box up and connected to the internet. Because I am new to Solaris myself, I still have a lot of reading, experimenting, hacking to do!!</p>
<p>Below are the summary of some of the commands which you might find useful:</p>
<p>(1.)      <b>uname -aX</b></p>
<p>This command will display  the current name of your system,  architecture, Solaris version and various other information.</p>
<p>(2.)  <b>prtconf -v</b></p>
<p>This command will provide all the PCI hardware  details residing on your Solaris box.</p>
<p>(3.)  <b>prstat</b></p>
<p>This is similar to Linux or FreeBSD &#8220;top&#8221; utility and provides current live processes running on your Solaris box.</p>
<p>(5.)   <b>psrinfo -v</b></p>
<p>This command will display the CPU information of your Solaris box</p>
<p>(5.)  <b>prtconf  |  grep Memory</b></p>
<p>This command will provide the current physical memory (RAM) on your Solaris box.</p>
<p>(6.)   <b>ifconfig  -a</b></p>
<p>Displays your current IP address, netmask, broadcast, name and status of your network card.</p>
<p>Please note that I am just covering a small fish in an ocean full of Solaris!<br />
We will dive into more complex topics like the IPFilter  firewall, the next generation ZFS file system and the most powerful debugging tool called DTrace in the future.</p>
<p>Till then, enjoy your new Sun Java Desktop and visit the following sites for much more information on Solaris:</p>
<p>(1.)    <a href="http://www.sun.com/bigadmin/home/index.html" title="Sun Administrators Guide" target="_blank">Bigadmin</a></p>
<p>(2.)  <a href="http://www.cuddletech.com/blog/" title="The Blog of Ben Rockwood (Use Unix or Die)" target="_blank">The Blog of Ben Rockwood</a></p>
<p>(3.)  <a href="http://www.blastwave.org/" title="Blastwave (pkg-get)" target="_blank">Blastwave.org</a></p>
<p>(4.)   <a href="http://sunfreeware.com/" title="Sunfreeware (sfw)" target="_blank">Sunfreeware.com</a></p>
<p>(5.)  <a href="http://www.opensolaris.org/os/" title="The Open Source Kernel for Solaris" target="_blank">OpenSolaris.org</a></p>
<p>(6.) <a href="http://blogs.sun.com/jonathan/" title="SUN's CEO Blog" target="_blank">http://blogs.sun.com/jonathan/ </a></p>
<p><a href="http://www.opensolaris.org/os/" title="The Open Source Kernel for Solaris" target="_blank"></a><br />
These sites are all you need to stay up to date with the latest news and technology related to the Solaris operating system. Take out some of your free time and make a point in reading the materials found on these sites. They will make you very familiar and conversant to the Solaris operating system.</p>
<p>The last blog is from SUN&#8217;s CEO (Jonathan Schwartz) himself!</p>
<p>My first days with Solaris has really been enriching and an enchanting experience. It gave me the &#8220;Deva Vu&#8221; feeling, reminding me of the good old times when I first started using Linux way back in the year 2000! I hope that your <b><i>Encounter </i><i>with Solaris 10 </i></b>will also be the same as mine!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/teklimbu.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/teklimbu.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/teklimbu.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/teklimbu.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/teklimbu.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/teklimbu.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/teklimbu.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/teklimbu.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/teklimbu.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/teklimbu.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/teklimbu.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/teklimbu.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=16&subd=teklimbu&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://teklimbu.wordpress.com/2007/10/30/an-encounter-with-solaris-10/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dac1f65f8303afbf89a5d1d2c98c8e8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">teklimbu</media:title>
		</media:content>

		<media:content url="http://www.blastwave.org/docs/images/s10u3/122.png" medium="image">
			<media:title type="html">Solaris Login Screen</media:title>
		</media:content>

		<media:content url="http://www.blastwave.org/docs/images/s10u3/146.png" medium="image">
			<media:title type="html">Sun Java Desktop </media:title>
		</media:content>

		<media:content url="http://www.blastwave.org/docs/images/s10u3/148.png" medium="image">
			<media:title type="html">Java Desktop running Gnome</media:title>
		</media:content>

		<media:content url="http://upload.wikimedia.org/wikipedia/en/2/25/Solaris10.jpg" medium="image">
			<media:title type="html">Sun Java Desktop Snapshot 2</media:title>
		</media:content>
	</item>
		<item>
		<title>Managing your Linux/Unix log files using logrotate</title>
		<link>http://teklimbu.wordpress.com/2007/10/16/managing-your-linuxunix-log-files-using-logrotate/</link>
		<comments>http://teklimbu.wordpress.com/2007/10/16/managing-your-linuxunix-log-files-using-logrotate/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 09:31:42 +0000</pubDate>
		<dc:creator>teklimbu</dc:creator>
				<category><![CDATA[logrotate]]></category>

		<guid isPermaLink="false">http://teklimbu.wordpress.com/2007/10/16/managing-your-linuxunix-log-files-using-logrotate/</guid>
		<description><![CDATA[
This How-To details the steps required to manage and rotate your server&#8217;s log files. A simple truth about Linux/Unix logs are that they are everywhere. Your kernel, program daemons, firewalls, etc, generate their respective log files. In fact, there are so many log files of various levels that sometimes, it can be a nightmare to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=13&subd=teklimbu&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Flinux_unix%2FKeep_your_Linux_Unix_log_files_under_control_using_logrotate' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
<p>This How-To details the steps required to manage and rotate your server&#8217;s log files. A simple truth about Linux/Unix logs are that they are everywhere. Your kernel, program daemons, firewalls, etc, generate their respective log files. In fact, there are so many log files of various levels that sometimes, it can be a nightmare to maintain them. Hence, this guide is a simple step towards maintaining those log files to keep your system in check and in good health.</p>
<p>Log files are one of the most important files where almost all precious and sometimes unnecessary information are stored in regard to your server&#8217;s running state. For example, if your system&#8217;s security has been breached or compromised, it&#8217;s these log files which will come to your rescue to help you identity where or what went wrong.</p>
<p>In case if you don&#8217;t know, your Linux/Unix server is currently logging kernel and security logs in the file called /var/log/messages. Just do a simple &#8221; tail  -f   /var/log/messages &#8221; to get feel and see the actual current logs generated by various daemons running on your system.</p>
<p>Now if your server also has a Apache Web server or a Squid Proxy server running and you want to manage their respective logs in your own fashion, then the following information might help you out.</p>
<p><span id="more-13"></span></p>
<p>First of all, you will need the program called &#8220;logrotate&#8221;. Logrotate is very useful utility which can rotate log files and archive them in a location that you specify. We will be using &#8220;<i>logrotate</i>&#8221; in conjunction with &#8220;<i>cron</i>&#8220;.</p>
<p>In Linux/Unix, <i>cron </i>is a time-based scheduling service in Unix-like computer operating systems. It is available on almost all versions of Linux and Unix.</p>
<p>Having said that, <i>logrotate  </i>should be installed in your Linux/Unix distribution but if is not, simply use your system package management system to install it.</p>
<p>For example, for Debian based system, all you need to do to install logrotate is:</p>
<p><b>apt-get  install  logrotate</b></p>
<p>For this guide, we will be rotating and managing the log files generated by Apache and Squid on a<b> FreeBSD-6.x</b> and a <b>Linux Debian-4.1</b> box. However, it should be also work on other Linux distributions like <b>RedHat</b>, <b>Slackware </b>or <b>SuSE </b>since the fundamentals are the same of all Linux based distributions.</p>
<p>I also assume that your Apache logs are kept in  /var/log/apache   and your Squid logs are kept in  /var/log/squid.</p>
<p><b><i>On a FreeBSD-6.x box:</i></b></p>
<p><b>(1.)  Make and Install from ports:</b></p>
<p>cd /usr/ports/sysutils/logrotate</p>
<p><b>(2.)   Configure and Compile</b></p>
<p>make     install     clean</p>
<p>If all goes well, we are done and logrotate is installed.</p>
<p><b>(3.)  Create a new logrotate.conf file.</b></p>
<p>vi   /usr/local/etc/logrotate.conf</p>
<p># Added the following to rotate Apache and Squid logs</p>
<p># see &#8220;man logrotate&#8221; for details<br />
# rotate log files weekly<br />
#weekly<br />
daily</p>
<p># keep 4 weeks worth of backlogs<br />
rotate 7</p>
<p># send errors to root<br />
#errors root</p>
<p># create new (empty) log files after rotating old ones<br />
create</p>
<p># uncomment this if you want your log files compressed<br />
compress</p>
<p># RPM packages drop log rotation information into this directory<br />
include /usr/local/etc/logrotate.d</p>
<p>/var/log/lastlog {<br />
monthly<br />
rotate 12<br />
}</p>
<p># system-specific logs may be configured here</p>
<p><b>(4.)  Create a directory for specific logrotate files</b></p>
<p>mkdir   -p   /usr/local/etc/logrotate.d</p>
<p><b>(5.)   First, create a logrotate file for Squid to rotate it&#8217;s access.log files for 90 days and cache.log for 7 days.</b></p>
<p>cd     /usr/local/etc/logrotate.d/</p>
<p>vi     /usr/local/etc/logrotate.d/squid</p>
<p>#Copy and paste the following</p>
<p>/var/log/squid/access.log {<br />
daily<br />
rotate 90<br />
copytruncate<br />
compress<br />
notifempty<br />
missingok<br />
}<br />
/var/log/squid/cache.log {<br />
daily<br />
rotate 7<br />
copytruncate<br />
compress<br />
notifempty<br />
missingok<br />
}</p>
<p><b>(6.)  Create the necessary directories and files for logrotate and test and debug logrotate</b></p>
<p>mkdir /var/lib/</p>
<p>touch    /var/lib/logrotate.status</p>
<p>/usr/local/sbin/logrotate -d   /usr/local/etc/logrotate.conf<br />
/usr/local/sbin/logrotate -f   /usr/local/etc/logrotate.conf</p>
<p><b>(7.)  Next, we will rotate and manage Apache logs</b></p>
<p>vi      /usr/local/etc/logrotate.d/apache</p>
<p>#Add the following to rotate and manage Apache access_log and error_log  for 30 days.</p>
<p>#Note: If your Apache logs may be in a different directory,  simply change the directory.</p>
<p>/var/log/apache/access_log {<br />
daily<br />
rotate 30<br />
copytruncate<br />
compress<br />
notifempty<br />
missingok<br />
}<br />
/var/log/apache/error_log {<br />
daily<br />
rotate 30<br />
copytruncate<br />
compress<br />
notifempty<br />
missingok<br />
}</p>
<p>If all goes well, that&#8217;s it. Your Apache and Squid logs should be rotated.</p>
<p>The last thing is to add an entry into crontab and letting the cron daemon rotate your Apache and Squid logs automatically.</p>
<p><b>(8.)  Automating logrotate using crontab</b></p>
<p>vi     /etc/crontab</p>
<p>#Add the following to rotate your logs at 1 AM in the morning</p>
<p>#Logrotate<br />
0 1 * * *   root    /usr/local/sbin/logrotate /usr/local/etc/logrotate.conf &gt; /dev/null 2&gt;&amp;1</p>
<p>That&#8217;s it. Your Apache and Squid logs will be rotating without manual intervention!!</p>
<p><i><b>Using logrotate on a Debian-4.1 box</b></i></p>
<p><b>(1.)   Install the logrotate program</b></p>
<p>apt-get    install    logrotate</p>
<p><b>(2.)   Create the necessary directories and files</b></p>
<p>mkdir   -p   /var/lib/logrotate/</p>
<p>touch /var/lib/logrotate/status</p>
<p>mkdir  -p   /etc/logrotate.d/</p>
<p><b>(3.)   Create a new logrotate.conf </b></p>
<p>vi   /etc/logrotate.conf</p>
<p>#Copy and paste the following</p>
<p># see &#8220;man logrotate&#8221; for details<br />
# rotate log files weekly<br />
weekly</p>
<p># keep 4 weeks worth of backlogs<br />
rotate 4</p>
<p># create new (empty) log files after rotating old ones<br />
create</p>
<p># uncomment this if you want your log files compressed<br />
#compress</p>
<p># packages drop log rotation information into this directory<br />
include /etc/logrotate.d</p>
<p># no packages own wtmp, or btmp &#8212; we&#8217;ll rotate them here<br />
/var/log/wtmp {<br />
missingok<br />
monthly<br />
create 0664 root utmp<br />
rotate 1<br />
}</p>
<p>/var/log/btmp {<br />
missingok<br />
monthly<br />
create 0664 root utmp<br />
rotate 1<br />
}</p>
<p># system-specific logs may be configured here<br />
<b>(4.)  Create the squid logrotate file to rotate and manage access.log for 90 days and cache.log for 7 days.</b></p>
<p>vi    /etc/logrotate.d/squid</p>
<p>#Copy and paste the following</p>
<p>/var/log/squid/access.log {<br />
daily<br />
rotate 90<br />
copytruncate<br />
compress<br />
notifempty<br />
missingok<br />
}<br />
/var/log/squid/cache.log {<br />
daily<br />
rotate 7<br />
copytruncate<br />
compress<br />
notifempty<br />
missingok<br />
}</p>
<p><b>(5.)  Create the Apache logrotate file to rotate and manage access_log for 30 days and error_log for 30days. </b></p>
<p>vi   /etc/logrotate.d/apache</p>
<p>#Copy and paste the following. Note: your apache log&#8217;s directory might be different. Simply change the path of your directory.</p>
<p>/var/log/apache/access_log {<br />
daily<br />
rotate 30<br />
copytruncate<br />
compress<br />
notifempty<br />
missingok<br />
}<br />
/var/log/apache/error_log {<br />
daily<br />
rotate 30<br />
copytruncate<br />
compress<br />
notifempty<br />
missingok<br />
}<br />
<b>(6.)  Test and debug your logrotate configuration for any errors</b></p>
<p>/usr/sbin/logrotate     -d     /etc/logrotate.conf</p>
<p>/usr/sbin/logrotate     -f     /etc/logrotate.conf</p>
<p>If all goes well, you are good to go.</p>
<p><b>(7.)  Now all that is left is to automate the logrotate process from  crontab</b></p>
<p>vi /etc/crontab</p>
<p>#Copy and paste the following</p>
<p>#Logrotate at 1 AM in the morning</p>
<p>0 01 * * * root /usr/sbin/logrotate  /etc/logrotate.conf &gt; /dev/null 2&gt;&amp;1</p>
<p>That&#8217;s it! The cron daemon will automatically rotate your Apache and Squid logs at 1 AM on a daily basis.</p>
<p>Happy Log rotating !!!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/teklimbu.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/teklimbu.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/teklimbu.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/teklimbu.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/teklimbu.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/teklimbu.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/teklimbu.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/teklimbu.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/teklimbu.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/teklimbu.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/teklimbu.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/teklimbu.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=13&subd=teklimbu&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://teklimbu.wordpress.com/2007/10/16/managing-your-linuxunix-log-files-using-logrotate/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dac1f65f8303afbf89a5d1d2c98c8e8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">teklimbu</media:title>
		</media:content>
	</item>
		<item>
		<title>Running A Transparent Linux Squid Bridge / Turn your Linux box into a Cisco like Catalyst switch</title>
		<link>http://teklimbu.wordpress.com/2007/10/11/running-a-transparent-linux-squid-bridge/</link>
		<comments>http://teklimbu.wordpress.com/2007/10/11/running-a-transparent-linux-squid-bridge/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 09:38:17 +0000</pubDate>
		<dc:creator>teklimbu</dc:creator>
				<category><![CDATA[bridge]]></category>
		<category><![CDATA[bridge-utils]]></category>
		<category><![CDATA[ebtables]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[STP]]></category>
		<category><![CDATA[transparent]]></category>

		<guid isPermaLink="false">http://teklimbu.wordpress.com/2007/10/11/running-a-transparent-linux-squid-bridge/</guid>
		<description><![CDATA[This How-To guides you to run your Linux box with Squid in a transparent bridge mode.

Let us face some facts. Not everybody, especially  a small office network or a small home network can afford a Cisco catalyst switch. To replicate the features of a sophisticated switch like a Cisco catalyst switch, we can setup [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=9&subd=teklimbu&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This How-To guides you to run your Linux box with Squid in a transparent bridge mode.</p>
<p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Flinux_unix%2FTurn_your_Linux_box_into_a_Cisco_like_Catalyst_switch' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
<p>Let us face some facts. Not everybody, especially  a small office network or a small home network can afford a Cisco catalyst switch. To replicate the features of a sophisticated switch like a Cisco catalyst switch, we can setup a Linux box with more than 2 network interfaces to run in bridging mode.  Or more simply, a Linux bridged box having switching capabilities.</p>
<p>A bridge is a way to connect two <span class="extiw">Ethernet</span> segments together in a protocol independent way.  Packets are forwarded based on Ethernet address, rather than IP address (like a router). Since forwarding is done at Layer 2, all protocols can go transparently through a bridge.<span id="more-9"></span></p>
<p>You can think of a bridge like a network switch. We will be using this Linux Transparent Squid Bridge like a switch according to the network diagram below:</p>
<blockquote><p>Internet  (5)</p></blockquote>
<blockquote>
<blockquote><p>↑↓</p></blockquote>
</blockquote>
<blockquote><p>Router  (4)</p></blockquote>
<blockquote>
<blockquote><p>↑↓</p></blockquote>
</blockquote>
<blockquote><p>Linux Bridge  (3)</p></blockquote>
<blockquote>
<blockquote><p>↑↓</p></blockquote>
</blockquote>
<blockquote><p>Physical Switch  (2)</p></blockquote>
<blockquote>
<blockquote><p>↑↓</p></blockquote>
</blockquote>
<blockquote><p>LAN Network  (1)</p></blockquote>
<p><i><b>Reasons for running a Linux bridge are:</b></i></p>
<p>(A.)   The job of the bridge is to examine the destination of the     data packets one at a time and decide whether or not to pass the     packets to the other side of the Ethernet segment.     The result is a faster, quieter network with less collisions.</p>
<p>(B.)   You can overcome hardware incompatibilities with a     bridge, without leaving the address-range of your IP-net or subnet.     E.g. it&#8217;s possible to bridge between different physical media like     10 Base T and 100 Base TX.</p>
<p>(C.)   You don&#8217;t need to change your existing network layout. You just plug in the bridge and you start working. If for some reasons, your Linux bridge box should go down, reconnect the cables from your switch (2) to  your router (4), and nobody will even notice that something was not working!</p>
<dl>
<dt><i> </i>
</dt>
<dt><i><b>Features of a Linux Bridge box:</b></i></dt>
<dt>
</dt>
<dt>STP</dt>
<dd>The Spanning Tree Protocol is a nifty method of keeping           Ethernet devices connected in multiple paths working.           The participating switches negotiate the shortest available path           by STP. </dd>
<dt>Multiple Bridge Instances</dt>
<dd>Multiple bridge instances allow you to have more than one           bridge on your box up and running, and to control each instance           separately. </dd>
<dt>Fire-walling</dt>
</dl>
<p> Because we are running a Linux box with a kernel 2.4.x or 2.6.x, we can also apply some IPTABLES firewall rules.</p>
<p><i><b>What do I need to run such a Linux Bridge?</b></i></p>
<p>You just need a Linux OS with a kernel greater than 2.4. I prefer the 2.6 kernel. The minimum number of network interfaces in your Linux box should at least be 2. This guide assumes that the Linux box has 2 network interfaces, i.e., eth0   and eth1.</p>
<p>However, you may use any number of network interfaces supported on by the hardware of your Linux box.</p>
<p>You then need the &#8220;<b>bridge-utils</b>&#8221; package. The 2nd tool needed is <b>&#8220;ebtables&#8221;.</b></p>
<p>You can use either the binaries installed by your OS distribution or simply download them from the internet.</p>
<p>On a Debian box , it&#8217;s as simple as:   apt-get   install  bridge-utils  ebtables</p>
<p>The Bridge-Utils package contains the main tools required to setup and configure a Linux bridge. Among the tools provided by bridge-utils, <b>brctl </b>will primarily be used to construct the bridge.</p>
<p>The ebtables program is a filtering tool for a bridging firewall. The filtering is focussed on the Link Layer Ethernet frame fields. It also gives us the ability to alter the Ethernet MAC addresses.</p>
<p>Now that you have a 2.4/2.6 Linux kernel box and you have somehow managed to install the bridge-utils and ebtables packages, we can move on to the next topic of configuring the bridge and running a transparent squid on it.</p>
<p><b>Installing and configuring Squid </b></p>
<p><b>(1.)   Create the user squid and group squid</b></p>
<p>groupadd squid</p>
<p>useradd   -g   squid   squid</p>
<p><b>(2.) Download the latest version of squid in /usr/local/src</b></p>
<p>cd /usr/local/src<br />
wget http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE18.tar.gz</p>
<p><b>(3.) Unzip it’s contents</b></p>
<p>tar zxvf squid-2.6.STABLE18.tar.gz</p>
<p><b>(4.) Configure squid with the following parameters</b></p>
<p>cd   squid-2.6.STABLE18</p>
<p>./configure     –bindir=/usr/local/sbin \</p>
<p>–sysconfdir=/usr/local/etc/squid \<br />
–datadir=/usr/local/etc/squid \<br />
–libexecdir=/usr/local/libexec/squid \<br />
–localstatedir=/usr/local/squid \<br />
–enable-removal-policies=heap,lru \<br />
–enable-storeio=diskd,aufs,coss,ufs,null \<br />
–enable-time-hack \<br />
–enable-snmp \<br />
–with-large-files \<br />
–enable-large-cache-files \<br />
–prefix=/usr/local \<br />
–disable-ident-lookups  \<br />
–enable-cache-digests \<br />
–enable-underscores \<br />
–enable-kill-parent-hack \<br />
–enable-follow-x-forwarded-for</p>
<p><b>(5.) If all goes well, run</b></p>
<p>make all<br />
make install</p>
<p>That&#8217;s it. Squid should now be installed. It&#8217;s time to do some Squid configurations.</p>
<p>Note: If you encounter problems in configuring or compilation, 99% of them can be solved. The errors are either related to missing compilers, packages or dependencies.</p>
<p><b> (6.)  Create a new Cache directory for Squid</b></p>
<p>mkdir   -p   /usr/local/squid/cache</p>
<p><b>(7.)  Create a new /usr/local/etc/squid/squid.conf</b></p>
<p>cd   /usr/local/etc/squid</p>
<p>mv   /usr/local/etc/squid/squid.conf    /usr/local/etc/squid/squid.conf.default.config</p>
<p>vi    /usr/local/etc/squid/squid.conf</p>
<p>##Copy and paste following working configuration<br />
########### Start of squid.conf ##############<br />
cache_effective_user squid<br />
cache_effective_user squid</p>
<p>http_port 3128 transparent</p>
<p>cache_dir ufs /usr/local/squid/cache 2000 16 256</p>
<p>cache_access_log /usr/local/squid/logs/access.log<br />
cache_log /usr/local/squid/logs/cache.log<br />
cache_store_log none</p>
<p>emulate_httpd_log on</p>
<p>cache_mem 16 MB</p>
<p>hierarchy_stoplist cgi-bin ?<br />
acl QUERY urlpath_regex cgi-bin \?<br />
no_cache deny QUERY</p>
<p>hosts_file /etc/hosts</p>
<p>refresh_pattern ^ftp: 1440 20% 10080<br />
refresh_pattern ^gopher: 1440 0% 1440<br />
refresh_pattern . 0 40% 4320</p>
<p>acl all src 0.0.0.0/0.0.0.0</p>
<p>##Define your network below</p>
<p>acl mynetwork src 192.168.0.0/24<br />
acl manager proto cache_object<br />
acl localhost src 127.0.0.1/255.255.255.255<br />
acl to_localhost dst 127.0.0.0/8<br />
acl purge method PURGE<br />
acl CONNECT method CONNECT</p>
<p>acl Safe_ports port 80          # http<br />
acl Safe_ports port 21          # ftp<br />
acl Safe_ports port 443         # https</p>
<p>acl Safe_ports port 1025-65535   #unregistered ports</p>
<p>acl SSL_ports port 443 563</p>
<p>http_access allow manager localhost<br />
http_access deny manager<br />
http_access allow purge localhost<br />
http_access deny purge<br />
http_access deny !Safe_ports<br />
http_access deny CONNECT !SSL_ports</p>
<p>http_access allow localhost<br />
http_access allow mynetwork<br />
http_access deny all<br />
http_reply_access allow all<br />
icp_access allow mynetwork</p>
<p>icp_access deny all</p>
<p>visible_hostname  proxybridge.hostname.com</p>
<p>coredump_dir /usr/local/squid</p>
<p>######## End of squid.conf ##########</p>
<p><b>(8.)   Change the permissions of squid logs and cache_dir</b></p>
<p>chown    -R    squid:squid    /usr/local/squid/</p>
<p>chown    -R    squid:squid    /usr/local/etc/squid/</p>
<p>(9.)   Initialize Squid&#8217;s cache and run Squid in daemon mode</p>
<p>/usr/local/sbin/squid   -z</p>
<p>/usr/local/sbin/squid    -D</p>
<p>Check for any errors. If there are none, put the proxy server manually in your web browser and try browsing websites!</p>
<p><i><b>Next, we will setup a bridge using the tools provided by the package &#8220;bridge_utils&#8221;</b></i></p>
<pre></pre>
<p>As stated above, 1 of the most important tools installed by the bridge-utils package is brctl command.</p>
<p>We will be using the brctl command for creating a logical bridge instance with the name br0.  You will need at least 1 bridge instance for bridging to work.</p>
<p><b>(1.) Creating the logical bridge instance called br0.</b></p>
<p>#Add bridge instance called br0</p>
<p>brctl    addbr   br0</p>
<p>#Show your bridge status<br />
brctl    show</p>
<p>#Show MAC addresses on your bridge</p>
<p>brctl     showmacs     br0<br />
<b> (2.)   Add your network interfaces to the bridge.</b></p>
<p>brctl       addif       br0      eth0</p>
<p>brctl       addif         br0        eth1</p>
<p><b>(3.)   Zero in your IP network interfaces to 0.0.0.0 and bring it up.</b><br />
ifconfig    eth0    0.0.0.0        promisc        up</p>
<p>ifconfig    eth1    0.0.0.0        promisc         up</p>
<p>(<b>4.)  Bring up the bridge.  Since we also want to administer this bridge box, we point an IP address to the br0 interface.</b></p>
<p>ifconfig     br0        192.168.100.9        netmask      255.255.255.0        up</p>
<p><b>(5.)  Give your  bridge interface br0 a default gateway so that you can access it via SSH, etc.</b></p>
<p>route     add    default    gw      192.168.100.1        dev    br0</p>
<p>That&#8217;s it. You have a simple yet a very effective Linux bridge  box!</p>
<h3><b><i>The final remaining part is to redirect the web requests from your network to your bridged box running Squid transparently.</i></b></h3>
<p><b>(1.)  To redirect web traffic from your LAN to your Bridge box transparently, run the following script called rc.bridge.</b></p>
<p>#####Start of rc.bridge script ######</p>
<p>#!/bin/sh</p>
<p>###Date: 12-Oct-2007</p>
<p>###tekbdrlimbu@hotmail.com####</p>
<p>/sbin/ebtables -t broute -A BROUTING -p IPv4 &#8211;ip-protocol 6  \<br />
&#8211;ip-destination-port 80 -j redirect &#8211;redirect-target ACCEPT<br />
/sbin/iptables -t nat -A PREROUTING -i br0 -p tcp &#8211;dport 80  \<br />
-j REDIRECT &#8211;to-port 3128<br />
/sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp &#8211;dport 80 -j REDIRECT &#8211;to-ports 3128<br />
/sbin/iptables -t nat -A PREROUTING -i eth1 -p tcp &#8211;dport 80 -j REDIRECT &#8211;to-ports 3128<br />
/sbin/iptables -t nat -A PREROUTING -i br0 -p tcp &#8211;dport 80 -j REDIRECT &#8211;to-ports 3128</p>
<p>######### End of rc.bridge script #####</p>
<p>Run this script and restart Squid. You will have a working Squid transproxy running in a Linux bridged box!!!</p>
<p>We will cover more advanced topics like Spanning Tree Protocol (STP) , MAC and ARP filtering , etc, in the coming days ahead.</p>
<h2 class="SECT2"><a title="STP" name="STP"></a></h2>
<p>Happy bridging!!!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/teklimbu.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/teklimbu.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/teklimbu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/teklimbu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/teklimbu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/teklimbu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/teklimbu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/teklimbu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/teklimbu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/teklimbu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/teklimbu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/teklimbu.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=9&subd=teklimbu&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://teklimbu.wordpress.com/2007/10/11/running-a-transparent-linux-squid-bridge/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dac1f65f8303afbf89a5d1d2c98c8e8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">teklimbu</media:title>
		</media:content>
	</item>
		<item>
		<title>Configuring WCCP2 on a Cisco 3620/7206 router with Squid-2.6.18 running on FreeBSD-6.x</title>
		<link>http://teklimbu.wordpress.com/2007/10/10/configuring-wccp2-on-a-cisco-36207206-router-with-squid-2616-running-on-freebsd-6x/</link>
		<comments>http://teklimbu.wordpress.com/2007/10/10/configuring-wccp2-on-a-cisco-36207206-router-with-squid-2616-running-on-freebsd-6x/#comments</comments>
		<pubDate>Wed, 10 Oct 2007 07:21:04 +0000</pubDate>
		<dc:creator>teklimbu</dc:creator>
				<category><![CDATA[cisco]]></category>
		<category><![CDATA[cisco-3620]]></category>
		<category><![CDATA[cisco-7206]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[wccp]]></category>

		<guid isPermaLink="false">http://teklimbu.wordpress.com/2007/10/10/configuring-wccp2-on-a-cisco-36207206-router-with-squid-2616-running-on-freebsd-6x/</guid>
		<description><![CDATA[
This How-To details the steps required to configure WCCP version 2 with a Cisco 3620 or 7206 router together with Squid-2.6.STABLE18 running on FreeBSD-6.2.
Cisco&#8217;s WCCP (Web Cache Control Protocol) version 2 is used for sending web requests from clients to 1 or more Squid proxy servers. WCCP feature allows us to redirect Web traffic to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=8&subd=teklimbu&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Flinux_unix%2FConfiguring_WCCP2_on_a_Cisco_router_with_Squid_2_6_16_on_FreeBSD' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
<p>This How-To details the steps required to configure WCCP version 2 with a Cisco 3620 or 7206 router together with Squid-2.6.STABLE18 running on FreeBSD-6.2.</p>
<p><span>Cisco&#8217;s WCCP (Web Cache Control Protocol) version 2 is used for sending web requests from clients to 1 or more Squid proxy servers. WCCP </span>feature allows us to redirect Web traffic to our proxy servers which in turn provides Web caching, filtering, or other services, thus reducing transmission costs and downloading time.</p>
<p style="margin-bottom:0;" align="left">With WCCP, we can build a “cache cluster” for load balancing, scaling, and fault tolerance.</p>
<p style="margin-bottom:0;" align="left">For example, in the case of 2 proxy severs,  if 1 proxy server goes down, WCCP redirects clients requests to the 2nd working proxy server.</p>
<p style="widows:0;orphans:0;">In the rare circumstance where both or all of your proxy servers should go down, WCCP will determine the dead proxy servers and will route clients web requests directly from your cisco router.</p>
<p style="margin-bottom:0;widows:0;orphans:0;" align="left"> <font size="3">Note:  Only </font><span class="content"> Cisco IOS Release 12.1 and later releases allow the use of either Version 1 (WCCPv1) or Version 2 (WCCPv2) of the WCCP.</span></p>
<p style="margin-bottom:0;widows:0;orphans:0;" align="left"><span id="more-8"></span></p>
<p style="margin-bottom:0;widows:0;orphans:0;" align="left">&nbsp;</p>
<ul>
<p style="widows:0;orphans:0;" align="center"><font size="3"><b>How 	WCCP and transparent intercepting Squid caches work?</b></font></p>
<li>
<p style="widows:0;orphans:0;">A<font size="3"><span> 	Client&#8217;s Web browser makes a request, which goes to the cisco router. </span></font></p>
</li>
<li>
<p style="widows:0;orphans:0;"><font size="3">The router intercepts the request. </font></p>
</li>
<li>
<p style="widows:0;orphans:0;"><font size="3">The 	router redirects the request to a new location inside a generic 	routing encapsulation (GRE) frame to prevent any modifications to 	the original packet. </font></p>
</li>
<li>
<p style="widows:0;orphans:0;"><font face="Helvetica, sans-serif">A 	(GRE) tunnel is established between our FreeBSD squid boxes and the cisco 3620/7206 router.</font></p>
</li>
<li>
<p style="widows:0;orphans:0;"><font size="3">All 	redirected requests from the router are encapsulated down the GRE 	tunnel to our FreeBSD Squid caches. </font></p>
</li>
<li>
<p style="widows:0;orphans:0;"><font face="Helvetica, sans-serif">The 	FreeBSD Squid boxes decapsulates the GRE traffic and redirects the 	WCCP packets onto Squid.</font></p>
</li>
<li>
<p style="widows:0;orphans:0;"><font face="Helvetica, sans-serif">This 	redirection is achieved transparently using</font> FreeBSD IP 	forwarding and IPFW firewall.</p>
</li>
<li>
<p style="widows:0;orphans:0;"><font face="Helvetica, sans-serif">Squid 	pulls apart the request, then attempts to deliver the content either 	from the local cache or via direct request from target.</font></p>
</li>
<li>
<p style="widows:0;orphans:0;"><font face="Helvetica, sans-serif">The 	content is then delivered back to the router for delivery to the 	originator (ie. client&#8217;s browser).</font></p>
</li>
</ul>
<p>Now to connect all the pieces of information regarding WCCP, the following steps are required:</p>
<p><b>(1.)    Configure and compile your kernel</b></p>
<p>cd   /usr/src/sys/i386/conf/</p>
<p>cp     GENERIC       SQUID_WCCP</p>
<p>vi       SQUID_WCCP</p>
<p><b>(2.)  Copy and paste the following kernel parameters</b></p>
<p>machine         i386<br />
cpu             I686_CPU<br />
ident           SQUID_WCCP</p>
<p>options         SCHED_4BSD              # 4BSD scheduler<br />
options         PREEMPTION              # Enable kernel thread preemption<br />
options         INET                    # InterNETworking<br />
options         FFS                     # Berkeley Fast Filesystem<br />
options         SOFTUPDATES             # Enable FFS soft updates support<br />
options         UFS_ACL                 # Support for access control lists<br />
options         UFS_DIRHASH             # Improve performance on big directories<br />
options         MD_ROOT                 # MD is a potential root device<br />
options         NFSCLIENT               # Network Filesystem Client<br />
options         NFSSERVER               # Network Filesystem Server<br />
options         NFS_ROOT                # NFS usable as /, requires NFSCLIENT<br />
options         MSDOSFS                 # MSDOS Filesystem<br />
options         CD9660                  # ISO 9660 Filesystem<br />
options         PROCFS                  # Process filesystem (requires PSEUDOFS)<br />
options         PSEUDOFS                # Pseudo-filesystem framework<br />
options         GEOM_GPT                # GUID Partition Tables.<br />
options         COMPAT_43               # Compatible with BSD 4.3 [KEEP THIS!]<br />
options         COMPAT_FREEBSD4         # Compatible with FreeBSD4<br />
options         COMPAT_FREEBSD5         # Compatible with FreeBSD5<br />
options         SCSI_DELAY=5000         # Delay (in ms) before probing SCSI<br />
options         KTRACE                  # ktrace(1) support<br />
options         SYSVSHM                 # SYSV-style shared memory<br />
options         SYSVMSG                 # SYSV-style message queues<br />
options         SYSVSEM                 # SYSV-style semaphores<br />
options         _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time #extensions<br />
options         KBD_INSTALL_CDEV        # install a CDEV entry in /dev<br />
options         ADAPTIVE_GIANT          # Giant mutex is adaptive.</p>
<p>device          apic                    # I/O APIC<br />
device          eisa<br />
device          pci<br />
device          fdc<br />
device          ata<br />
device          atadisk         # ATA disk drives<br />
device          ataraid         # ATA RAID drives<br />
device          atapicd         # ATAPI CDROM drives<br />
device          atapifd         # ATAPI floppy drives<br />
device          atapist         # ATAPI tape drives<br />
options         ATA_STATIC_ID   # Static device numbering<br />
device          ahb             # EISA AHA1742 family<br />
device          ahc             # AHA2940 and onboard AIC7xxx devices<br />
options         AHC_REG_PRETTY_PRINT    # Print register bitfields in debug<br />
# output.  Adds ~128k to driver.<br />
device          ahd             # AHA39320/29320 and onboard AIC79xx devices<br />
options         AHD_REG_PRETTY_PRINT    # Print register bitfields in debug<br />
# output.  Adds ~215k to driver.<br />
device          amd             # AMD 53C974 (Tekram DC-390(T))<br />
device          isp             # Qlogic family<br />
device          mpt             # LSI-Logic MPT-Fusion<br />
device          sym             # NCR/Symbios Logic (newer chipsets + those of `ncr&#8217;)<br />
device          trm             # Tekram DC395U/UW/F DC315U adapters<br />
device          adv             # Advansys SCSI adapters<br />
device          adw             # Advansys wide SCSI adapters<br />
device          aha             # Adaptec 154x SCSI adapters<br />
device          aic             # Adaptec 15[012]x SCSI adapters, AIC-6[23]60.<br />
device          bt              # Buslogic/Mylex MultiMaster SCSI adapters<br />
device          ncv             # NCR 53C500<br />
device          nsp             # Workbit Ninja SCSI-3<br />
device          stg             # TMC 18C30/18C50<br />
device          scbus           # SCSI bus (required for SCSI)<br />
device          ch              # SCSI media changers<br />
device          da              # Direct Access (disks)<br />
device          sa              # Sequential Access (tape etc)<br />
device          cd              # CD<br />
device          pass            # Passthrough device (direct SCSI access)<br />
device          ses             # SCSI Environmental Services (and SAF-TE)<br />
device          amr             # AMI MegaRAID<br />
device          arcmsr          # Areca SATA II RAID<br />
device          asr             # DPT SmartRAID V, VI and Adaptec SCSI RAID<br />
device          ciss            # Compaq Smart RAID 5*<br />
device          dpt             # DPT Smartcache III, IV &#8211; See NOTES for options<br />
device          hptmv           # Highpoint RocketRAID 182x<br />
device          rr232x          # Highpoint RocketRAID 232x<br />
device          iir             # Intel Integrated RAID<br />
device          ips             # IBM (Adaptec) ServeRAID<br />
device          mly             # Mylex AcceleRAID/eXtremeRAID<br />
device          twa             # 3ware 9000 series PATA/SATA RAID<br />
device          aac             # Adaptec FSA RAID<br />
device          aacp            # SCSI passthrough for aac (requires CAM)<br />
device          ida             # Compaq Smart RAID<br />
device          mfi             # LSI MegaRAID SAS<br />
device          mlx             # Mylex DAC960 family<br />
device          pst             # Promise Supertrak SX6000<br />
device          twe             # 3ware ATA RAID<br />
device          atkbdc          # AT keyboard controller<br />
device          atkbd           # AT keyboard<br />
device          psm             # PS/2 mouse<br />
device          kbdmux          # keyboard multiplexer<br />
device          vga             # VGA video card driver<br />
device          splash          # Splash screen and screen saver support<br />
device          sc<br />
device          agp             # support several AGP chipsets<br />
device          pmtimer<br />
device          cbb             # cardbus (yenta) bridge<br />
device          pccard          # PC Card (16-bit) bus<br />
device          cardbus         # CardBus (32-bit) bus<br />
device          sio             # 8250, 16[45]50 based serial ports<br />
device          ppc<br />
device          ppbus           # Parallel port bus (required)<br />
device          lpt             # Printer<br />
device          plip            # TCP/IP over parallel<br />
device          ppi             # Parallel port interface device<br />
device          de              # DEC/Intel DC21&#215;4x (&#8220;Tulip&#8221;)<br />
device          em              # Intel PRO/1000 adapter Gigabit Ethernet Card<br />
device          ixgb            # Intel PRO/10GbE Ethernet Card<br />
device          txp             # 3Com 3cR990 (&#8220;Typhoon&#8221;)<br />
device          vx              # 3Com 3c590, 3c595 (&#8220;Vortex&#8221;)<br />
device          miibus          # MII bus support<br />
device          bce             # Broadcom BCM5706/BCM5708 Gigabit Ethernet<br />
device          bfe             # Broadcom BCM440x 10/100 Ethernet<br />
device          bge             # Broadcom BCM570xx Gigabit Ethernet<br />
device          dc              # DEC/Intel 21143 and various workalikes<br />
device          fxp             # Intel EtherExpress PRO/100B (82557, 82558)<br />
device          lge             # Level 1 LXT1001 gigabit Ethernet<br />
device          nge             # NatSemi DP83820 gigabit Ethernet<br />
device          nve             # nVidia nForce MCP on-board Ethernet Networking<br />
device          pcn             # AMD Am79C97x PCI 10/100(precedence over &#8216;lnc&#8217;)<br />
device          re              # RealTek 8139C+/8169/8169S/8110S<br />
device          rl              # RealTek 8129/8139<br />
device          sf              # Adaptec AIC-6915 (&#8220;Starfire&#8221;)<br />
device          sis             # Silicon Integrated Systems SiS 900/SiS 7016<br />
device          sk              # SysKonnect SK-984x &amp; SK-982x gigabit Ethernet<br />
device          ste             # Sundance ST201 (D-Link DFE-550TX)<br />
device          stge            # Sundance/Tamarack TC9021 gigabit Ethernet<br />
device          ti              # Alteon Networks Tigon I/II gigabit Ethernet<br />
device          tl              # Texas Instruments ThunderLAN<br />
device          tx              # SMC EtherPower II (83c170 &#8220;EPIC&#8221;)<br />
device          vge             # VIA VT612x gigabit Ethernet<br />
device          vr              # VIA Rhine, Rhine II<br />
device          wb              # Winbond W89C840F<br />
device          xl              # 3Com 3c90x (&#8220;Boomerang&#8221;, &#8220;Cyclone&#8221;)<br />
device          cs              # Crystal Semiconductor CS89&#215;0 NIC<br />
device          ed              # NE[12]000, SMC Ultra, 3c503, DS8390 cards<br />
device          ex              # Intel EtherExpress Pro/10 and Pro/10+<br />
device          ep              # Etherlink III based cards<br />
device          fe              # Fujitsu MB8696x based cards<br />
device          ie              # EtherExpress 8/16, 3C507, StarLAN 10 etc.<br />
device          lnc             # NE2100, NE32-VL Lance Ethernet cards<br />
device          sn              # SMC&#8217;s 9000 series of Ethernet chips<br />
device          xe              # Xircom pccard Ethernet<br />
device          wlan            # 802.11 support<br />
device          wlan_wep        # 802.11 WEP support<br />
device          wlan_ccmp       # 802.11 CCMP support<br />
device          wlan_tkip       # 802.11 TKIP support<br />
device          an              # Aironet 4500/4800 802.11 wireless NICs.<br />
device          ath             # Atheros pci/cardbus NIC&#8217;s<br />
device          ath_hal         # Atheros HAL (Hardware Access Layer)<br />
device          ath_rate_sample # SampleRate tx rate control for ath<br />
device          awi             # BayStack 660 and others<br />
device          ral             # Ralink Technology RT2500 wireless NICs.<br />
device          wi              # WaveLAN/Intersil/Symbol 802.11 wireless NICs.<br />
device          loop            # Network loopback<br />
device          random          # Entropy device<br />
device          ether           # Ethernet support<br />
device          sl              # Kernel SLIP<br />
device          ppp             # Kernel PPP<br />
device          tun             # Packet tunnel.<br />
device          pty             # Pseudo-ttys (telnet etc)<br />
device          md              # Memory &#8220;disks&#8221;<br />
device          gif             # IPv6 and IPv4 tunneling<br />
device          faith           # IPv6-to-IPv4 relaying (translation)<br />
device          bpf             # Berkeley packet filter<br />
device          uhci            # UHCI PCI-&gt;USB interface<br />
device          ohci            # OHCI PCI-&gt;USB interface<br />
device          ehci            # EHCI PCI-&gt;USB interface (USB 2.0)<br />
device          usb             # USB Bus (required)<br />
device          ugen            # Generic<br />
device          uhid            # &#8220;Human Interface Devices&#8221;<br />
device          ukbd            # Keyboard<br />
device          ulpt            # Printer<br />
device          umass           # Disks/Mass storage &#8211; Requires scbus and da<br />
device          ums             # Mouse<br />
device          ural            # Ralink Technology RT2500USB wireless NICs<br />
device          urio            # Diamond Rio 500 MP3 player<br />
device          uscanner        # Scanners<br />
device          aue             # ADMtek USB Ethernet<br />
device          axe             # ASIX Electronics USB Ethernet<br />
device          cdce            # Generic USB over Ethernet<br />
device          cue             # CATC USB Ethernet<br />
device          kue             # Kawasaki LSI USB Ethernet<br />
device          rue             # RealTek RTL8150 USB Ethernet<br />
device          firewire        # FireWire bus code<br />
device          sbp             # SCSI over FireWire (Requires scbus and da)<br />
device          fwe             # Ethernet over FireWire (non-standard!)</p>
<p>#Enable IPFW in Kernel to DROP packets by default rule</p>
<p>options         IPFIREWALL              #firewall<br />
options         IPFIREWALL_VERBOSE      #enable logging to syslogd(8)<br />
options         IPFIREWALL_FORWARD      #enable transparent proxy support<br />
options         IPFIREWALL_VERBOSE_LIMIT=500    #limit verbosity<br />
options         IPSTEALTH               #support for stealth forwarding<br />
options         DUMMYNET<br />
options         NETGRAPH</p>
<p>options DEVICE_POLLING<br />
options HZ=1000</p>
<p>options         SHMSEG=128<br />
options         SHMMNI=256<br />
options         SHMMAX=50331648 # max shared memory segment size (bytes)<br />
options         SHMALL=16384    # max amount of shared memory (pages)<br />
options         MSGMNB=16384    # max # of bytes in a queue<br />
options         MSGMNI=48       # number of message queue identifiers<br />
options         MSGSEG=768      # number of message segments<br />
options         MSGSSZ=64       # size of a message segment<br />
options         MSGTQL=4096     # max messages in system</p>
<p><b>(3.)     Configure and compile your new kernel</b></p>
<p>(a.)       config        SQUID_WCCP</p>
<p>(b.)   cd        ../compile/SQUID_WCCP/</p>
<p>(c.)       make       cleandepend</p>
<p>(d.)      make      depend</p>
<p>(e.)       make</p>
<p>(f.)      make     install</p>
<p>(g.)      reboot</p>
<p>If all goes well, your kernel has been compiled!!!. Reboot with your new kernel.</p>
<p><b>(4.)    Create the GRE tunnel on your FreeBSD-6.x box</b></p>
<p>ifconfig      gre0      create<br />
ifconfig      gre0     IP.OF.SQUID.BOX       10.20.30.40      netmask      255.255.255.255      link2      tunnel      IP.OF.SQUID.BOX         IP.OF.CISCO.ROUTER   up</p>
<p><b>(3.)  Configuring WCCP on your squid box. Add the following in your squid.conf</b></p>
<p>wccp2_router   IP.OF.CISCO.ROUTER<br />
#wccp2_router   LoopBack.IP.OF.CISCOROUTER</p>
<p>wccp2_forwarding_method  1<br />
wccp2_return_method  1<br />
wccp2_service standard  0<br />
<b> (4.)  Create the firewall rules to redirect web requests to Squid&#8217;s 3128 port via the GRE tunnel.</b></p>
<p>We will create the script called rc.firewall to save our IPFW rules. Use the script below:</p>
<p>#!/bin/sh</p>
<p>##### Start of rc.firewall script  ######</p>
<p>##Change the network interfaces and IP addresses to match your network!</p>
<p>NET_IF=&#8221;em0&#8243;<br />
IPFW=&#8221;/sbin/ipfw -q&#8221;</p>
<p>#IP of Proxy Server<br />
IF_ADDR=&#8221;192.168.0.10&#8243;</p>
<p>NTP_SERVER=&#8221;192.168.0.55&#8243;</p>
<p>PROXY_NET=&#8221;192.168.0.0/27&#8243;</p>
<p>ALL_NET=&#8221;192.168.0.0/24&#8243;<br />
CLIENT_NET=&#8221;192.168.0.128/25&#8243;<br />
WIRELESS_NET=&#8221;172.16.0.128/25&#8243;<br />
ADMIN_NET=&#8221;192.168.0.48/28&#8243;<br />
SSH_PORT=&#8221;12345&#8243;</p>
<p>LOCALHOST=&#8221;127.0.0.1&#8243;</p>
<p>$IPFW -f flush</p>
<p>$IPFW add allow all from any to any via lo0</p>
<p>$IPFW add fwd 127.0.0.1,3128 tcp from any to any 80 via gre0 in</p>
<p>$IPFW add fwd 127.0.0.1,3128 ip from any to any via gre0 in<br />
$IPFW add fwd 127.0.0.1,3128 tcp from any to any 80 in<br />
$IPFW add fwd 127.0.0.1,3128 tcp from any to any http in via gre0</p>
<p>#$IPFW add permit ip from any to any<br />
$IPFW add allow all from $IF_ADDR to any</p>
<p>#$IPFW add fwd 127.0.0.1,3128 ip from any to any via gre0 in<br />
#$IPFW add fwd 127.0.0.1,3128 tcp from any to any http in via gre0<br />
#$IPFW add fwd 127.0.0.1,3128 tcp from any to any 80 in<br />
#$IPFW add permit ip from any to any</p>
<p>#Allow local DNS caching<br />
$IPFW add allow udp from $ALL_NET to any 53</p>
<p>$IPFW add allow udp from any 53 to $IF_ADDR<br />
$IPFW add allow tcp from any 53 to $IF_ADDR</p>
<p>$IPFW add allow all from any to any out via $NET_IF</p>
<p>#######For DNS<br />
#Allow DNS Query<br />
$IPFW add allow udp from $ALL_NET 53 to $IF_ADDR<br />
$IPFW add allow udp from $WIRELESS_NET 53 to $IF_ADDR</p>
<p>#For Proxy access<br />
#$IPFW add fwd 127.0.0.1,3128 tcp from any to any 80 in</p>
<p>$IPFW add allow tcp  from $ALL_NET to any  3128 in via $NET_IF<br />
$IPFW add allow tcp  from $WIRELESS_NET to any  3128 in via $NET_IF</p>
<p>#####Allow Established session<br />
$IPFW add allow tcp from any to any in via $NET_IF established</p>
<p>#$IPFW add allow tcp from any to $IF_ADDR 113</p>
<p>#For ICP Query<br />
$IPFW add allow UDP  from $PROXY_NET  to  $PROXY_NET 3130</p>
<p>$IPFW add allow udp from $NTP_SERVER 123 to $IF_ADDR</p>
<p>###Only needed for Experimental Multicast<br />
#$IPFW add allow all from 224.9.9.1 to any<br />
#$IPFW add allow all from any to 224.9.9.1<br />
#$IPFW add allow all from me to 224.9.9.1</p>
<p>#######For SSH</p>
<p>$IPFW add allow tcp from $ADMIN_NET to $IF_ADDR $SSH_PORT</p>
<p>#for snmpwalk from Admin network<br />
$IPFW add allow udp from $ADMIN_NET  to me 3001<br />
$IPFW add allow udp from $ADMIN_NET  to me 161<br />
$IPFW add allow udp from $ADMIN_NET  to me 161<br />
$IPFW add allow udp from $LOCALHOST   to me 3001<br />
$IPFW add allow udp from $LOCALHOST   to me 161</p>
<p>###########<br />
$IPFW add allow ICMP from $ALL_NET to any<br />
$IPFW add allow ICMP from $WIRELESS_NET to any<br />
#################################################</p>
<p>###Only if you want the world to send ICMP packets to your server!!</p>
<p>#ipfw add allow icmp from any to any icmptypes 8<br />
#ipfw add allow icmp from any to any</p>
<p>$IPFW add allow all from $ADMIN_NET to me<br />
$IPFW add allow all from me to $ADMIN_NET</p>
<p>$IPFW add 65533 deny log  all  from any to any</p>
<p>############# End of rc.firewall ###############</p>
<p><b>(5.)    Configure WCCP on your Cisco router</b></p>
<p>Global Configuration</p>
<pre>Router (config)#  ip wccp version 2</pre>
<pre>Router (config)#  ip wccp web-cache redirect-list 160</pre>
<p>Access-List 160</p>
<pre>permit ip 192.168.0.0 0.0.0.255 any</pre>
<pre>permit ip 172.16.0.0 0.0.0.255 any</pre>
<pre></pre>
<pre>Router (config)#   interface fastethernet 0/0
Router(config-if)# ip wccp web-cache redirect in</pre>
<pre>Router# write</pre>
<p>END of Router WCCP confiruration.</p>
<p><b>(6.)   Restart Squid and reload your firewall. If all goes well, you will have a working WCCP2 on your FreeBSD Box with Squid-2.6.STABLE18.</b></p>
<p>Happy Proxying with Squid + FreeBSD + Cisco WCCP !!!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/teklimbu.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/teklimbu.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/teklimbu.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/teklimbu.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/teklimbu.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/teklimbu.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/teklimbu.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/teklimbu.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/teklimbu.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/teklimbu.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/teklimbu.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/teklimbu.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=teklimbu.wordpress.com&blog=1839359&post=8&subd=teklimbu&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://teklimbu.wordpress.com/2007/10/10/configuring-wccp2-on-a-cisco-36207206-router-with-squid-2616-running-on-freebsd-6x/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dac1f65f8303afbf89a5d1d2c98c8e8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">teklimbu</media:title>
		</media:content>
	</item>
	</channel>
</rss>