<?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/"
	>

<channel>
	<title>Fedora &#187; Administration</title>
	<atom:link href="http://gofedora.com/archives/category/administration/feed/" rel="self" type="application/rss+xml" />
	<link>http://gofedora.com</link>
	<description>How Tos, Tutorials, Tips and Tricks</description>
	<lastBuildDate>Wed, 14 Sep 2011 15:10:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How To: Configure Caching Nameserver (named)</title>
		<link>http://gofedora.com/configure-caching-nameserver-named/</link>
		<comments>http://gofedora.com/configure-caching-nameserver-named/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 18:39:48 +0000</pubDate>
		<dc:creator>Kulbir Saini</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nameserver]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Caching]]></category>
		<category><![CDATA[Caching Nameserver]]></category>
		<category><![CDATA[named]]></category>

		<guid isPermaLink="false">http://172.17.8.64/gofedora/?p=329</guid>
		<description><![CDATA[Mission
To configure a caching nameserver on a local machine which will cascade to another previously configured and functional nameserver (may or may not be caching. It&#8217;ll generally be your ISP nameserver or the one provided by your organization).
Advantage

Reduces the delay in domain name resolution drastically as the requests for frequently accessed websites are served from [...]<p><a href="http://gofedora.com/">Fedora Tutorials</a> and <a href="http://cachevideos.com/">Videocache</a> by <a href="http://saini.co.in/">Kulbir Saini</a>.</p>
]]></description>
			<content:encoded><![CDATA[<p></p><h4><span style="text-decoration: underline;"><strong>Mission</strong></span></h4>
<p>To configure a caching nameserver on a local machine which will cascade to another previously configured and functional nameserver (may or may not be caching. It&#8217;ll generally be your ISP nameserver or the one provided by your organization).</p>
<h4><span style="text-decoration: underline;"><strong>Advantage</strong></span></h4>
<ul>
<li>Reduces the delay in domain name resolution drastically as the requests for frequently accessed websites are served from cache.</li>
</ul>
<h4><span style="text-decoration: underline;"><strong>Working</strong></span></h4>
<ul>
<li><em>named</em> gets a request for domain resolution.</li>
<li>It checks whether the request can be satisfied from cache. If the answer is in cache and not stale, the request is satisfied from cache itself saving a lot of time <img src='http://gofedora.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="How To: Configure Caching Nameserver (named)" /> </li>
<li>If request can&#8217;t be satisfied from cache, named queries the first parent. If it replies with the answer, then named will cache the response and subsequent requests for the same domain name will be satisfied from the cache.</li>
<li>In case first parent fails to reply, named will query the second parent and so on.</li>
</ul>
<p>(<em>The working is my understanding of caching-nameserver using wireshark as traffic analysis tool and caching-nameserver may not behave exactly as explained above.</em>)</p>
<h4><span style="text-decoration: underline;"><strong>How to install</strong></span></h4>
<p><em><strong>named</strong></em> is by default on most of the systems by the package name &#8216;<em><strong>caching-nameserver</strong></em>&#8216;. If its not present on your system, install using</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>localhost ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># yum install caching-nameserver [ENTER]</span>
<span style="color: #666666; font-style: italic;"># If that doesn't work try this</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>localhost ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># yum install bind [ENTER]</span></pre></div></div>

<h4><span style="text-decoration: underline;"><strong>How to configure</strong></span></h4>
<p>The main configuration file for named resides in <em>/var/named/chroot/etc/named.caching-nameserver.conf</em> which is also soft linked from <em>/etc/named.caching-nameserver.conf</em> . named configuration file supports C/C++ style comments.</p>
<p>For a caching nameserver which will cascade to another nameserver, there is nothing much to be configured. You need to configure &#8220;<em><strong>options</strong></em>&#8221; block. Below is a configuration file for a machine with IP address 172.17.8.64 cascading to two nameserver 192.168.36.204 and 192.168.36.210. The comments inline explain what each option does.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">options <span style="color: #008000;">&#123;</span>
  <span style="color: #666666;">// Set the port to 53 which is standard port for DNS.</span>
  <span style="color: #666666;">// Add the IP address on which named will listen separated by semi-colons.</span>
  <span style="color: #666666;">// It'll be your own IP address.</span>
  listen<span style="color: #000040;">-</span>on port <span style="color: #0000dd;">53</span> <span style="color: #008000;">&#123;</span>127.0.0.1<span style="color: #008080;">;</span> 172.17.8.64<span style="color: #008080;">;</span><span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
  <span style="color: #666666;">// These are default. Leave them as it is.</span>
  directory   <span style="color: #FF0000;">&quot;/var/named&quot;</span><span style="color: #008080;">;</span>
  dump<span style="color: #000040;">-</span>file   <span style="color: #FF0000;">&quot;/var/named/data/cache_dump.db&quot;</span><span style="color: #008080;">;</span>
  statistics<span style="color: #000040;">-</span>file <span style="color: #FF0000;">&quot;/var/named/data/named_stats.txt&quot;</span><span style="color: #008080;">;</span>
  memstatistics<span style="color: #000040;">-</span>file <span style="color: #FF0000;">&quot;/var/named/data/named_mem_stats.txt&quot;</span><span style="color: #008080;">;</span>
  <span style="color: #666666;">// The machines which are allowed to query this nameserver.</span>
  <span style="color: #666666;">// Normally you'll allow only your machine. But you can allow other machines also.</span>
  <span style="color: #666666;">// The address should be separated by semi-colons. To allow a network 172.16.31.0/24,</span>
  <span style="color: #666666;">// the line would be</span>
  <span style="color: #666666;">// allow-query {localhost; 172.16.31.0/24; };</span>
  <span style="color: #666666;">// Don't forget the semi-colons.</span>
  allow<span style="color: #000040;">-</span>query     <span style="color: #008000;">&#123;</span> localhost<span style="color: #008080;">;</span> 172.17.8.64<span style="color: #008080;">;</span> <span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
  recursion yes<span style="color: #008080;">;</span>
  <span style="color: #666666;">// The parent nameservers. List all the nameserver which you can query.</span>
  forwarders <span style="color: #008000;">&#123;</span> 192.168.36.204<span style="color: #008080;">;</span> 192.168.36.210<span style="color: #008080;">;</span> <span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
  forward first<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
logging <span style="color: #008000;">&#123;</span>
        channel default_debug <span style="color: #008000;">&#123;</span>
                file <span style="color: #FF0000;">&quot;data/named.run&quot;</span><span style="color: #008080;">;</span>
                severity dynamic<span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
zone <span style="color: #FF0000;">&quot;.&quot;</span> IN <span style="color: #008000;">&#123;</span>
  type hint<span style="color: #008080;">;</span>
  file <span style="color: #FF0000;">&quot;named.ca&quot;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
include <span style="color: #FF0000;">&quot;/etc/named.rfc1912.zones&quot;</span><span style="color: #008080;">;</span></pre></div></div>

<h4><span style="text-decoration: underline;"><strong>Start caching-nameserver</strong></span></h4>
<p>Now start the caching-nameserver using the following command</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>localhost ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># server named start [ENTER]</span></pre></div></div>

<p class="rtecenter"><strong>OR</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>localhost ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># /etc/init.d/named start [ENTER]</span></pre></div></div>

<p>To make named start every time your reboot your machine use following command</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>localhost ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># chkconfig named on [ENTER]</span></pre></div></div>

<h4><span style="text-decoration: underline;"><strong>Using caching-nameserver</strong></span></h4>
<p>To use your caching-nameserver, open /etc/resolv.conf file and add the following line</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">nameserver 127.0.0.1</pre></div></div>

<p>Comment all other lines in the file, so that finally the file looks like</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">; generated by <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>dhclient-script
<span style="color: #666666; font-style: italic;">#search wlan.iiit.ac.in</span>
<span style="color: #666666; font-style: italic;">#nameserver 192.168.36.204</span>
<span style="color: #666666; font-style: italic;">#nameserver 192.168.36.210</span>
nameserver 127.0.0.1</pre></div></div>

<p>Now your system will use your own nameserver (in caching mode) for resolving all domain names. To test if your nameserver use the following command</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>localhost ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># dig fedora.co.in [ENTER]</span></pre></div></div>

<p>Now if you use that command for the second time, the resolution time will be around 2-3 milli seconds while first time it would be around 400-700 milli seconds.</p>
<p><span style="text-decoration: underline;"><strong>Example</strong></span></p>
<p>Below is two subsequent runs of dig for fedora.co.in . Notice the Query time.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bordeaux SPECS<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># dig fedora.co.in</span>
; <span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; DiG 9.4.2rc1 <span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; fedora.co.in
<span style="color: #000000; font-weight: bold;">;;</span> global options:  printcmd
<span style="color: #000000; font-weight: bold;">;;</span> Got answer:
<span style="color: #000000; font-weight: bold;">;;</span> -<span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt;HEADER<span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>lt;- opcode: QUERY, status: NOERROR, <span style="color: #c20cb9; font-weight: bold;">id</span>: <span style="color: #000000;">7839</span>
<span style="color: #000000; font-weight: bold;">;;</span> flags: qr rd ra; QUERY: <span style="color: #000000;">1</span>, ANSWER: <span style="color: #000000;">1</span>, AUTHORITY: <span style="color: #000000;">1</span>, ADDITIONAL: <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">;;</span> QUESTION SECTION:
;fedora.co.in.                  IN      A
<span style="color: #000000; font-weight: bold;">;;</span> ANSWER SECTION:
fedora.co.in.           <span style="color: #000000;">83629</span>   IN      A       72.249.126.241
<span style="color: #000000; font-weight: bold;">;;</span> AUTHORITY SECTION:
fedora.co.in.           <span style="color: #000000;">79709</span>   IN      NS      ns.fedora.co.in.
<span style="color: #000000; font-weight: bold;">;;</span> ADDITIONAL SECTION:
ns.fedora.co.in.        <span style="color: #000000;">79709</span>   IN      A       72.249.126.241
<span style="color: #000000; font-weight: bold;">;;</span> Query <span style="color: #000000; font-weight: bold;">time</span>: <span style="color: #000000;">531</span> msec
<span style="color: #000000; font-weight: bold;">;;</span> SERVER: 127.0.0.1<span style="color: #666666; font-style: italic;">#53(127.0.0.1)</span>
<span style="color: #000000; font-weight: bold;">;;</span> WHEN: Wed Nov <span style="color: #000000;">19</span> <span style="color: #000000;">18</span>:04:<span style="color: #000000;">47</span> <span style="color: #000000;">2008</span>
<span style="color: #000000; font-weight: bold;">;;</span> MSG SIZE  rcvd: <span style="color: #000000;">79</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bordeaux SPECS<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># dig fedora.co.in</span>
; <span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; DiG 9.4.2rc1 <span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; fedora.co.in
<span style="color: #000000; font-weight: bold;">;;</span> global options:  printcmd
<span style="color: #000000; font-weight: bold;">;;</span> Got answer:
<span style="color: #000000; font-weight: bold;">;;</span> -<span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt;HEADER<span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>lt;- opcode: QUERY, status: NOERROR, <span style="color: #c20cb9; font-weight: bold;">id</span>: <span style="color: #000000;">64233</span>
<span style="color: #000000; font-weight: bold;">;;</span> flags: qr rd ra; QUERY: <span style="color: #000000;">1</span>, ANSWER: <span style="color: #000000;">1</span>, AUTHORITY: <span style="color: #000000;">1</span>, ADDITIONAL: <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">;;</span> QUESTION SECTION:
;fedora.co.in.                  IN      A
<span style="color: #000000; font-weight: bold;">;;</span> ANSWER SECTION:
fedora.co.in.           <span style="color: #000000;">83625</span>   IN      A       72.249.126.241
<span style="color: #000000; font-weight: bold;">;;</span> AUTHORITY SECTION:
fedora.co.in.           <span style="color: #000000;">79705</span>   IN      NS      ns.fedora.co.in.
<span style="color: #000000; font-weight: bold;">;;</span> ADDITIONAL SECTION:
ns.fedora.co.in.        <span style="color: #000000;">79705</span>   IN      A       72.249.126.241
<span style="color: #000000; font-weight: bold;">;;</span> Query <span style="color: #000000; font-weight: bold;">time</span>: <span style="color: #000000;">1</span> msec
<span style="color: #000000; font-weight: bold;">;;</span> SERVER: 127.0.0.1<span style="color: #666666; font-style: italic;">#53(127.0.0.1)</span>
<span style="color: #000000; font-weight: bold;">;;</span> WHEN: Wed Nov <span style="color: #000000;">19</span> <span style="color: #000000;">18</span>:04:<span style="color: #000000;">51</span> <span style="color: #000000;">2008</span>
<span style="color: #000000; font-weight: bold;">;;</span> MSG SIZE  rcvd: <span style="color: #000000;">79</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bordeaux SPECS<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;">#</span></pre></div></div>

<p><a href="http://gofedora.com/">Fedora Tutorials</a> and <a href="http://cachevideos.com/">Videocache</a> by <a href="http://saini.co.in/">Kulbir Saini</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gofedora.com/configure-caching-nameserver-named/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hack: A Fast Network Scanning Program</title>
		<link>http://gofedora.com/hack-fast-network-scanning-program/</link>
		<comments>http://gofedora.com/hack-fast-network-scanning-program/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 19:21:06 +0000</pubDate>
		<dc:creator>Kulbir Saini</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Network Scanner]]></category>
		<category><![CDATA[Network Scanning]]></category>
		<category><![CDATA[NMAP]]></category>
		<category><![CDATA[Port Scanner]]></category>

		<guid isPermaLink="false">http://172.17.8.64/gofedora/?p=336</guid>
		<description><![CDATA[I was searching for a simple tool which can do a port scanning in a huge network quickly without making me wait for ages. I first thought of using nmap, but it was a bit too complex and it takes a lot of time to discover the machines even after optimizing the parameters. After searching [...]<p><a href="http://gofedora.com/">Fedora Tutorials</a> and <a href="http://cachevideos.com/">Videocache</a> by <a href="http://saini.co.in/">Kulbir Saini</a>.</p>
]]></description>
			<content:encoded><![CDATA[<p></p><p>I was searching for a simple tool which can do a port scanning in a huge network quickly without making me wait for ages. I first thought of using nmap, but it was a bit too complex and it takes a lot of time to discover the machines even after optimizing the parameters. After searching a lot, I wrote to one of my seniors, <a target="_blank" href="http://web.iiit.ac.in/~sandeep_kr/home/home.html">Sandeep Kumar</a>, asking the details of his program which maintains a list of active FTP servers in the network. He replied with a reference to <a target="_blank" href="http://turbo-technical-report.blogspot.com/2007/05/finding-out-available-ftp-servers-on.html">his own findings about the network scanning tools</a>. He is using an enhanced version of a program originally written by Troy Robinson. I tried the program out of curiosity and found out that its damn fast as compared to nmap (no literal comparison) <img src='http://gofedora.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="Hack: A Fast Network Scanning Program" />  The program can be downloaded from <a href="http://gofedora.com/wp-content/uploads/linux/NetworkScanner.c">here</a>.</p>
<h4><u><strong>How to use</strong></u></h4>
<p>Compile the program using gcc as</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>localhost ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># gcc NetworkScanner.c [ENTER]</span></pre></div></div>

</p>
<p>Now create a file IPRange.txt containing the IP address ranges for your network. The contents of the file may be</p>
<p><strong>172.16.*.*</strong> Meaning all the IP address with first two parts as 172.16 and rest of the address will be generated by permutations.</p>
<p><strong>172.16.1-16.*</strong> Meaning the first two parts are fixed. Third part will vary from 1 to 16. And the fourth part will be permuted from 0 to 255.</p>
<p>So an IPRange.txt may look like</p>
<p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">172.16.1-16.<span style="color: #000000; font-weight: bold;">*</span>
192.168.36.<span style="color: #000000; font-weight: bold;">*</span></pre></td></tr></table></div>

</p>
<p>Now run the program as</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>localhost ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./a.out port_to_be_scanned Parallel_attempts IP_list_file output.txt [ENTER]</span></pre></div></div>

</p>
<p><strong>Parallel_attempts</strong> is the number of processes that&#8217;ll be forked for scanning the network port. It is safe to have its value as 255. A very high value may hog the network or may even slow down your machine. So an example run would be</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>localhost ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./a.out 21 255 IPRange.txt Output.txt [ENTER]</span></pre></div></div>

</p>
<h4><u><strong>Benchmarks</strong></u></h4>
<p>I carried out a lot of test on my network using the following setup and parameters</p>
<p><strong>Machine</strong> : AMD X2 5600+ (2.6GHz Dual Core), 4GB 800MHz DDR2 RAM, Gigabit Ethernet Card (on 100mbps network).</p>
<p><strong>Port</strong> : 21 (FTP)</p>
<p><strong>IPRange.txt : </strong>Total 16896 IP Addresses</p>
<p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Machines on wired <span style="color: #7a0874; font-weight: bold;">&#40;</span>100mbps<span style="color: #7a0874; font-weight: bold;">&#41;</span> network
172.16.1-48.<span style="color: #000000; font-weight: bold;">*</span> 
192.168.36.<span style="color: #000000; font-weight: bold;">*</span>
Machines on wireless <span style="color: #7a0874; font-weight: bold;">&#40;</span>54mbps<span style="color: #7a0874; font-weight: bold;">&#41;</span> network
172.17.0-16.<span style="color: #000000; font-weight: bold;">*</span></pre></td></tr></table></div>

</p>
<table cellspacing="0" cellpadding="0" border="1" align="left" width="100%" style="clear:both;">
<caption>Network Scanner Benchmarks</caption>
<tbody>
<tr>
<td>
<p>Parallel Attempts</p>
</td>
<td>
<p>Scanning Time (seconds)</p>
</td>
<td>
<p>Upload Bandwidth (kbps)</p>
</td>
</tr>
<tr>
<td>255</td>
<td>180</td>
<td>13</td>
</tr>
<tr>
<td>512</td>
<td>90</td>
<td>25</td>
</tr>
<tr>
<td>1024</td>
<td>47</td>
<td>55</td>
</tr>
<tr>
<td>2048</td>
<td>25</td>
<td>100</td>
</tr>
<tr>
<td>4096</td>
<td>14</td>
<td>205</td>
</tr>
<tr>
<td>6144</td>
<td>11</td>
<td>307</td>
</tr>
<tr>
<td>8192</td>
<td>
            9
            </td>
<td>
            374
            </td>
</tr>
</tbody>
</table>
<p>The interval between two scans was almost 30-40 seconds. I think parallelism beyond 8192 will crash my machine, so I didn&#8217;t try. You can try it at your own risk <img src='http://gofedora.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="Hack: A Fast Network Scanning Program" />  I hope this program help you scan your network.</p>
<p><a href="http://gofedora.com/">Fedora Tutorials</a> and <a href="http://cachevideos.com/">Videocache</a> by <a href="http://saini.co.in/">Kulbir Saini</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gofedora.com/hack-fast-network-scanning-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Configure Squid Proxy Server</title>
		<link>http://gofedora.com/how-to-configure-squid-proxy-server/</link>
		<comments>http://gofedora.com/how-to-configure-squid-proxy-server/#comments</comments>
		<pubDate>Fri, 02 May 2008 08:31:31 +0000</pubDate>
		<dc:creator>Kulbir Saini</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[Proxy Server]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Squid]]></category>
		<category><![CDATA[Caching]]></category>
		<category><![CDATA[Traffic Monitoring]]></category>

		<guid isPermaLink="false">http://172.17.8.64/gofedora/?p=3</guid>
		<description><![CDATA[
Mission
To configure squid for simple proxying without caching anything.
Use Cases

When you want to have control on what people browse on your lan.
When number of machine is more than the number of IP addresses you can afford to buy.
When you want to help this holy world in saving some IPV4 addresses  

Assumptions

You have a machine [...]<p><a href="http://gofedora.com/">Fedora Tutorials</a> and <a href="http://cachevideos.com/">Videocache</a> by <a href="http://saini.co.in/">Kulbir Saini</a>.</p>
]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://gofedora.com/how-to-configure-squid-proxy-server/" title="Permanent link to How To: Configure Squid Proxy Server"><img class="post_image alignnone" src="http://gofedora.com/wp-content/uploads/2008/05/Squid-Caching-Proxy-Server.jpg" width="384" height="204" alt="Squid Caching Proxy Server" title="How To: Configure Squid Proxy Server" /></a>
</p><h4><strong>Mission</strong></h4>
<p>To configure squid for simple proxying without caching anything.</p>
<h4><strong>Use Cases</strong></h4>
<ol>
<li>When you want to have control on what people browse on your lan.</li>
<li>When number of machine is more than the number of IP addresses you can afford to buy.</li>
<li>When you want to help this holy world in saving some IPV4 addresses <img src='http://gofedora.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' title="How To: Configure Squid Proxy Server" /> </li>
</ol>
<h4><strong>Assumptions</strong></h4>
<ol>
<li>You have a machine connected directly to internet that you are going to use as a proxy server for other machines on your network.</li>
<li>The machines on your network are using 192.168.0.0/16 as private address space. You can use anyone/multiple address spaces of the available but for this howto we assume 192.168.0.0/16 as the local network.</li>
<li>The local IP address of the machine which will run squid proxy server is 192.168.36.204. You can have any IP, but for this howto we assume this.</li>
</ol>
<h4><strong>How to proceed</strong></h4>
<p>First of all ensure that you have squid installed. After installing squid, you need to set access control in squid configuration file which resides in <em>/etc/squid</em> by default. Open <em>/etc/squid/squid.conf</em> and add/edit following lines according to your preferences. Few lines already exist in the configuration file, you can add the rest.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># The port on which squid will listen for requests</span>
http_port <span style="color: #000000;">8080</span>
<span style="color: #666666; font-style: italic;"># If 'cgi-bin' or '?' is in query, squid should not check with neighbours'/parents' cache</span>
<span style="color: #666666; font-style: italic;"># and should go to target web-server.</span>
hierarchy_stoplist cgi-bin ?
<span style="color: #666666; font-style: italic;"># If url contains 'cgi-bin' or '?', then it must not be cached</span>
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
<span style="color: #666666; font-style: italic;"># Absolute path to squid access log.</span>
access_log <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>squid<span style="color: #000000; font-weight: bold;">/</span>access.log squid
refresh_pattern ^<span style="color: #c20cb9; font-weight: bold;">ftp</span>:           <span style="color: #000000;">1440</span>    <span style="color: #000000;">20</span><span style="color: #000000; font-weight: bold;">%</span>     <span style="color: #000000;">10080</span>
refresh_pattern ^gopher:        <span style="color: #000000;">1440</span>    <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span>      <span style="color: #000000;">1440</span>
refresh_pattern .               <span style="color: #000000;">0</span>       <span style="color: #000000;">20</span><span style="color: #000000; font-weight: bold;">%</span>     <span style="color: #000000;">4320</span>
<span style="color: #666666; font-style: italic;"># Access control list to control every IP address</span>
acl all src 0.0.0.0<span style="color: #000000; font-weight: bold;">/</span>0.0.0.0
<span style="color: #666666; font-style: italic;"># Access control list for source machine in LAN</span>
acl lan_src src 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span>
<span style="color: #666666; font-style: italic;"># Access control list for destination machine in LAN</span>
acl lan_dst dst 192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span>
<span style="color: #666666; font-style: italic;"># Access control list to manage squid cache</span>
acl manager proto cache_object
<span style="color: #666666; font-style: italic;"># Access control list to define IP address allowed for source localhost</span>
acl localhost src 127.0.0.1<span style="color: #000000; font-weight: bold;">/</span>255.255.255.255
<span style="color: #666666; font-style: italic;"># Access control list to define IP addresses allowed for localhost as destination</span>
acl to_localhost dst 127.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>
<span style="color: #666666; font-style: italic;"># Access control list to define Safe ports that should be allowed by default</span>
acl SSL_ports port <span style="color: #000000;">443</span> <span style="color: #000000;">563</span> <span style="color: #000000;">1863</span> <span style="color: #000000;">5190</span> <span style="color: #000000;">5222</span> <span style="color: #000000;">5050</span> <span style="color: #000000;">6667</span>
acl Safe_ports port <span style="color: #000000;">80</span>          <span style="color: #666666; font-style: italic;"># http</span>
acl Safe_ports port <span style="color: #000000;">21</span>          <span style="color: #666666; font-style: italic;"># ftp</span>
acl Safe_ports port <span style="color: #000000;">443</span>         <span style="color: #666666; font-style: italic;"># https</span>
acl Safe_ports port <span style="color: #000000;">70</span>          <span style="color: #666666; font-style: italic;"># gopher</span>
acl Safe_ports port <span style="color: #000000;">210</span>         <span style="color: #666666; font-style: italic;"># wais</span>
acl Safe_ports port <span style="color: #000000;">1025</span>-<span style="color: #000000;">65535</span>  <span style="color: #666666; font-style: italic;"># unregistered ports</span>
acl Safe_ports port <span style="color: #000000;">280</span>         <span style="color: #666666; font-style: italic;"># http-mgmt</span>
acl Safe_ports port <span style="color: #000000;">488</span>         <span style="color: #666666; font-style: italic;"># gss-http</span>
acl Safe_ports port <span style="color: #000000;">591</span>         <span style="color: #666666; font-style: italic;"># filemaker</span>
acl Safe_ports port <span style="color: #000000;">777</span>         <span style="color: #666666; font-style: italic;"># multiling http</span>
acl CONNECT method CONNECT
<span style="color: #666666; font-style: italic;"># Allow cache management only from localhost</span>
http_access allow manager localhost
<span style="color: #666666; font-style: italic;"># Deny cache management from remote hosts</span>
http_access deny manager
<span style="color: #666666; font-style: italic;"># Deny http access via all the ports which are not listed as safe</span>
http_access deny <span style="color: #000000; font-weight: bold;">!</span>Safe_ports
<span style="color: #666666; font-style: italic;"># Deny all connections via all ports which are not listed as safe</span>
http_access deny CONNECT <span style="color: #000000; font-weight: bold;">!</span>SSL_ports
<span style="color: #666666; font-style: italic;"># Allow http access from localhost</span>
http_access allow localhost
<span style="color: #666666; font-style: italic;"># Allow http access from machines on LAN</span>
http_access allow lan_src
http_access deny all
http_reply_access allow all
icp_access allow all
<span style="color: #666666; font-style: italic;"># Deny caching for everyone so that there is not caching at all</span>
cache deny all
coredump_dir <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>spool<span style="color: #000000; font-weight: bold;">/</span>squid
<span style="color: #666666; font-style: italic;"># Never allow direct connection to machines on the internet</span>
prefer_direct off
never_direct allow all
<span style="color: #666666; font-style: italic;"># Allow direct connetion if the destination machine is on LAN</span>
always_direct allow lan_dst
<span style="color: #666666; font-style: italic;"># Delete this line if you don't have /etc/hosts file</span>
hosts_file <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hosts
<span style="color: #666666; font-style: italic;"># Allow AIM connections</span>
<span style="color: #666666; font-style: italic;"># Delete the following 9 lines if you don't want people to connect to AIM</span>
acl AIM_ports port <span style="color: #000000;">5190</span> <span style="color: #000000;">9898</span> <span style="color: #000000;">6667</span>
acl AIM_domains dstdomain .oscar.aol.com .blue.aol.com .freenode.net
acl AIM_domains dstdomain .messaging.aol.com .aim.com
acl AIM_hosts dstdomain login.oscar.aol.com login.glogin.messaging.aol.com toc.oscar.aol.com irc.freenode.net
acl AIM_nets dst 64.12.0.0<span style="color: #000000; font-weight: bold;">/</span>255.255.0.0
acl AIM_methods method CONNECT
http_access allow AIM_methods AIM_ports AIM_nets
http_access allow AIM_methods AIM_ports AIM_hosts
http_access allow AIM_methods AIM_ports AIM_domains
<span style="color: #666666; font-style: italic;"># Allow connections to Yahoo Messenger</span>
<span style="color: #666666; font-style: italic;"># Delete the following 6 lines if you don't want people to connect to Yahoo Messenger</span>
acl YIM_ports port <span style="color: #000000;">5050</span>
acl YIM_domains dstdomain .yahoo.com .yahoo.co.jp
acl YIM_hosts dstdomain scs.msg.yahoo.com cs.yahoo.co.jp
acl YIM_methods method CONNECT
http_access allow YIM_methods YIM_ports YIM_hosts
http_access allow YIM_methods YIM_ports YIM_domains
<span style="color: #666666; font-style: italic;"># Allow connections to Google Talk</span>
<span style="color: #666666; font-style: italic;"># Delete the following 6 lines if you don't want people to connect to Google Talk</span>
acl GTALK_ports port <span style="color: #000000;">5222</span> <span style="color: #000000;">5050</span>
acl GTALK_domains dstdomain .google.com
acl GTALK_hosts dstdomain talk.google.com
acl GTALK_methods method CONNECT
http_access allow GTALK_methods GTALK_ports GTALK_hosts
http_access allow GTALK_methods GTALK_ports GTALK_domains
<span style="color: #666666; font-style: italic;"># Allow connections to MSN</span>
<span style="color: #666666; font-style: italic;"># Delete the following 6 lines if you don't want people to connect to Google Talk</span>
acl MSN_ports port <span style="color: #000000;">1863</span> <span style="color: #000000;">443</span> <span style="color: #000000;">1503</span>
acl MSN_domains dstdomain .microsoft.com .hotmail.com .live.com .msft.net .msn.com .passport.com
acl MSN_hosts dstdomain messenger.hotmail.com
acl MSN_nets dst 207.46.111.0<span style="color: #000000; font-weight: bold;">/</span>255.255.255.0
acl MSN_methods method CONNECT
http_access allow MSN_methods MSN_ports MSN_hosts</pre></div></div>

<p>Now, start the squid proxy server as</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">service squid start</pre></div></div>

<p>Also, if you want squid to be started every time you boot the machine, execute the following command</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">chkconfig <span style="color: #660033;">--level</span> <span style="color: #000000;">345</span> squid on</pre></div></div>

<p>You have a squid proxy server running now. You can ask clients to configure there browsers to use <em>192.168.36.204</em> as a proxy server with <em>8080</em> as proxy port. Command line utilities like elinks, lynx, yum, wget etc. can be asked to use proxy by exporting <em>http_proxy</em> variable as below. Users can also add these lines to <em>~/.bashrc</em> file to avoid exporting every-time.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">http_proxy</span>=<span style="color: #ff0000;">'http://192.168.36.204:8080'</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ftp_proxy</span>=<span style="color: #ff0000;">'http://192.168.36.204:8080'</span></pre></div></div>

<p>I highly recommend the book &#8220;<span id="btAsinTitle"><strong><a href="http://link.packtpub.com/K7JQGy" target="_blank">Squid Proxy Server 3.1: Beginner&#8217;s Guide (Paperback)</a></strong>&#8221; for further reading.</span></p>
<p class="link-exchange">You can get our complete <a href="http://www.thepass4sure.us/MB5-294-dumps.html">MB5-294</a> exam pass resources including our latest <a href="http://www.thepass4sure.biz/MB6-288.html">MB6-288</a> and <a href="http://www.thepass4sure.me/MB7-227.html">MB7-227</a> training courses. Our <a href="http://www.mypass4sure.info/70-272-dumps.html">70-272</a> and <a href="http://www.pass4sures.biz/70-162-testking.html">70-162</a> are also playing vital role in IT world.</p>
<p><a href="http://gofedora.com/">Fedora Tutorials</a> and <a href="http://cachevideos.com/">Videocache</a> by <a href="http://saini.co.in/">Kulbir Saini</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gofedora.com/how-to-configure-squid-proxy-server/feed/</wfw:commentRss>
		<slash:comments>69</slash:comments>
		</item>
		<item>
		<title>How To: Configure Hierarchicy of Proxy Servers (Squid)</title>
		<link>http://gofedora.com/how-to-configure-hierarchicy-proxy-servers-squid/</link>
		<comments>http://gofedora.com/how-to-configure-hierarchicy-proxy-servers-squid/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 10:51:13 +0000</pubDate>
		<dc:creator>Kulbir Saini</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Proxy Server]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Squid]]></category>
		<category><![CDATA[Bandwidth Management]]></category>
		<category><![CDATA[Caching]]></category>
		<category><![CDATA[Hierarchical Caching]]></category>

		<guid isPermaLink="false">http://172.17.8.64/gofedora/?p=16</guid>
		<description><![CDATA[Yesterday I came across this idea of caching all the data that I browse on my hard disk so that the average load time of a website decreases. Actually the idea is I&#8217;ll cache all the static data that I browse like images, static html pages, CSS files and similar things which does not change [...]<p><a href="http://gofedora.com/">Fedora Tutorials</a> and <a href="http://cachevideos.com/">Videocache</a> by <a href="http://saini.co.in/">Kulbir Saini</a>.</p>
]]></description>
			<content:encoded><![CDATA[<p></p><p>Yesterday I came across this idea of caching all the data that I browse on my hard disk so that the average load time of a website decreases. Actually the idea is I&#8217;ll cache all the static data that I browse like images, static html pages, CSS files and similar things which does not change frequently and can be served from the cache. But while setting up the proxy server on my machine, I faced the problem that my machine which is going to act as a proxy server is behind my institute&#8217;s proxy. So, a simple caching proxy server can&#8217;t serve my needs and I have to really figure out how to setup a hierarchical proxy server. Below we&#8217;ll see how to setup a hierarchical proxy server.</p>
<p><u><strong>Approach</strong></u></p>
<p>When I thought of setting up a caching proxy server, squid immediately struck my mind. Actually I don&#8217;t know about any other proxy servers. I never setup proxy server before this ( I tried a lot of time, but in vain). So, I started googling about squid setup. There were a lot of tutorials, but either they were too small to get things going or they were too verbose that I couldn&#8217;t manage to read them. So, I directly jump into squid configuration file squid.conf . And with references from here and there, I managed to setup the proxy server successfully.</p>
<p><u><strong>Note:</strong></u> The configurations below worked on Fedora 7 with squid 2.6STABLE16. The same configurations may work with other squid versions and on other operating systems as well, but try them at your own risk.</p>
<p><u><strong>Part 1 : Setting up simple proxy server with squid</strong></u></p>
<p>Setting up a very simple and usable proxy server is really easy. You need to add/edit only 2-3 lines /etc/squid/squid.conf to get started.</p>
<p>Add your ip to the access list.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">acl myip src 172.17.8.175 <span style="color: #666666; font-style: italic;">#&lt;your_ip_which_will_use_the_proxy_server&gt; (e.g. )</span>
http_access allow myip
http_port <span style="color: #000000;">8080</span> <span style="color: #666666; font-style: italic;">#&lt;http_proxy_port&gt; (this is 3128 by default. you can set it to anything you like. e.g. 8080)</span></pre></td></tr></table></div>

<p>Save the squid.conf file. Then issue these commands.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>localhost squid<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># squid -z [Enter] (as root) (This needs to be executed only once.)</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>localhost squid<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># service squid start [Enter] (as root)</span></pre></td></tr></table></div>

<p>If you want to start the squid server on boot, issue this command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>localhost squid<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># chkconfig --level 345 squid on [Enter] (as root)</span></pre></div></div>

<p>Now, your machine is a proxy server. You can setup your browser to use the machine as a proxy server.</p>
<p><u><strong>Conditions</strong></u></p>
<p>The proxy server will work only if your machine has a public IP and is directly connected to internet.</p>
<p><u><strong>Part 2: Setting up a hierarchical caching proxy server with squid</strong></u></p>
<p>The above setup works fine if a machine is directly connected to internet. But my machine itself is behind a proxy, so setting up a proxy on my machine is of no use unless the proxy on my machine uses the institute proxy for connecting to internet. So, here we jump into squid.conf again and this time we have to really do some brain storming. If you are a newbie to Linux and don&#8217;t know how to make a system work when nothing seems to help, you will probably be better off by using institute&#8217;s proxy.</p>
<p>Here is the scenario.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">1. Your browser sends a content request to proxy on your machine.
2. Check: <span style="color: #000000; font-weight: bold;">if</span> a cache HIT from institute proxy cache <span style="color: #7a0874; font-weight: bold;">&#40;</span>HIT means content was found <span style="color: #000000; font-weight: bold;">in</span> cache<span style="color: #7a0874; font-weight: bold;">&#41;</span>
	2a. Check: <span style="color: #000000; font-weight: bold;">if</span> content is older than the original upstream content
		2aa. Fetch content from upstream and serve the client
	2b. <span style="color: #000000; font-weight: bold;">else</span>
		2ba. Serve the content from the cache
3. Check: <span style="color: #000000; font-weight: bold;">if</span> cache HIT from proxy on your machine
	3a. Check: <span style="color: #000000; font-weight: bold;">if</span> content is older than the original upstream content
		3aa. Fetch content from upstream and serve the client
	3b. <span style="color: #000000; font-weight: bold;">else</span>
		3ba. Serve the content from the cache
4. Cache MISS from both the proxies
	4a. Fetch the content from upstream and serve the client</pre></td></tr></table></div>

<p>The above method of operation is very basic and is my understanding of squid. It may not be the exact squid behavior.</p>
<p>Now, lets see the configurations needed for setting up the hierarchical caching proxy server with squid.</p>
<p><u><strong>Assumptions</strong></u></p>
<p>I assume that we already have squid setup at institute&#8217;s proxy whether in caching mode or not. The best way to add/edit the following lines in your squid.conf is to search for particular parameter and then edit the value to set as given.</p>
<p>I also assume that you have simple proxy server setup on your machine and now we want to make it act as child proxy of the institute&#8217;s proxy.</p>
<p><u><strong>Configuration</strong></u></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Your local machine will act as a sibling proxy</span>
cache_peer 172.17.8.175 sibling <span style="color: #000000;">3128</span> <span style="color: #000000;">3130</span> no-query <span style="color: #007800;">weight</span>=<span style="color: #000000;">10</span>
<span style="color: #666666; font-style: italic;"># The institute's proxy server will act as a parent proxy</span>
<span style="color: #666666; font-style: italic;"># 'default' mean the last-resort</span>
cache_peer 192.168.36.204 parent <span style="color: #000000;">8080</span> <span style="color: #000000;">3130</span> no-query proxy-only no-digest default
<span style="color: #666666; font-style: italic;"># allow accessing peer cache for access list 'myip'</span>
cache_peer_access 172.17.8.175 allow myip
<span style="color: #666666; font-style: italic;"># Don't cache dynamic content</span>
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY
<span style="color: #666666; font-style: italic;"># Size of main memory to be used for caching</span>
cache_mem <span style="color: #000000;">200</span> MB
<span style="color: #666666; font-style: italic;"># max size of content to be stored in main memory</span>
maximum_object_size_in_memory <span style="color: #000000;">7000</span> KB
<span style="color: #666666; font-style: italic;"># policy for cache replacement if memory is full</span>
cache_replacement_policy heap LFUDA
<span style="color: #666666; font-style: italic;"># the directory to be used for storing cache on your hdd</span>
cache_dir aufs <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>spool<span style="color: #000000; font-weight: bold;">/</span>squid <span style="color: #000000;">200</span> <span style="color: #000000;">16</span> <span style="color: #000000;">256</span>
<span style="color: #666666; font-style: italic;"># max file descriptor open at a time .. 0(unlimited)</span>
max_open_disk_fds <span style="color: #000000;">0</span>
<span style="color: #666666; font-style: italic;"># min object size to cache on hdd</span>
minimum_object_size <span style="color: #000000;">0</span> KB
<span style="color: #666666; font-style: italic;"># max object size to cache on hdd</span>
maximum_object_size <span style="color: #000000;">16384</span> KB
<span style="color: #666666; font-style: italic;"># access log</span>
access_log <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>squid<span style="color: #000000; font-weight: bold;">/</span>access.log squid
refresh_pattern ^<span style="color: #c20cb9; font-weight: bold;">ftp</span>:           <span style="color: #000000;">1440</span>    <span style="color: #000000;">20</span><span style="color: #000000; font-weight: bold;">%</span>     <span style="color: #000000;">10080</span>
refresh_pattern ^gopher:        <span style="color: #000000;">1440</span>    <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span>      <span style="color: #000000;">1440</span>
refresh_pattern .               <span style="color: #000000;">0</span>       <span style="color: #000000;">20</span><span style="color: #000000; font-weight: bold;">%</span>     <span style="color: #000000;">4320</span>
store_avg_object_size <span style="color: #000000;">20</span> KB
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
refresh_stale_hit <span style="color: #000000;">5</span> seconds
acl SSL_ports port <span style="color: #000000;">443</span> <span style="color: #000000;">563</span> <span style="color: #000000;">1863</span> <span style="color: #000000;">5190</span> <span style="color: #000000;">5222</span> <span style="color: #000000;">5050</span> <span style="color: #000000;">6667</span>
<span style="color: #666666; font-style: italic;"># Allow AIM protocols</span>
acl AIM_ports port <span style="color: #000000;">5190</span> <span style="color: #000000;">9898</span> <span style="color: #000000;">6667</span>
acl AIM_domains dstdomain .oscar.aol.com .blue.aol.com .freenode.net
acl AIM_domains dstdomain .messaging.aol.com .aim.com
acl AIM_hosts dstdomain login.oscar.aol.com login.glogin.messaging.aol.com toc.oscar.aol.com irc.freenode.net
acl AIM_nets dst 64.12.0.0<span style="color: #000000; font-weight: bold;">/</span>255.255.0.0
acl AIM_methods method CONNECT
http_access allow AIM_methods AIM_ports AIM_nets
http_access allow AIM_methods AIM_ports AIM_hosts
http_access allow AIM_methods AIM_ports AIM_domains
<span style="color: #666666; font-style: italic;"># Allow Yahoo Messenger</span>
acl YIM_ports port <span style="color: #000000;">5050</span>
acl YIM_domains dstdomain .yahoo.com .yahoo.co.jp
acl YIM_hosts dstdomain scs.msg.yahoo.com cs.yahoo.co.jp
acl YIM_methods method CONNECT
http_access allow YIM_methods YIM_ports YIM_hosts
http_access allow YIM_methods YIM_ports YIM_domains
<span style="color: #666666; font-style: italic;"># Allow GTalk</span>
acl GTALK_ports port <span style="color: #000000;">5222</span> <span style="color: #000000;">5050</span>
acl GTALK_domains dstdomain .google.com
acl GTALK_hosts dstdomain talk.google.com
acl GTALK_methods method CONNECT
http_access allow GTALK_methods GTALK_ports GTALK_hosts
http_access allow GTALK_methods GTALK_ports GTALK_domains
<span style="color: #666666; font-style: italic;"># Allow MSN</span>
acl MSN_ports port <span style="color: #000000;">1863</span> <span style="color: #000000;">443</span> <span style="color: #000000;">1503</span>
acl MSN_domains dstdomain .microsoft.com .hotmail.com .live.com .msft.net .msn.com .passport.com
acl MSN_hosts dstdomain messenger.hotmail.com
acl MSN_nets dst 207.46.111.0<span style="color: #000000; font-weight: bold;">/</span>255.255.255.0
acl MSN_methods method CONNECT
http_access allow MSN_methods MSN_ports MSN_hosts
<span style="color: #666666; font-style: italic;"># Turn this off if hierarchical behavior is needed</span>
nonhierarchical_direct off
never_direct deny myip
hosts_file <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hosts
coredump_dir <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>spool<span style="color: #000000; font-weight: bold;">/</span>squid</pre></td></tr></table></div>

<p>That&#8217;s the minimal configuration you need for running squid in hierarchical way. Save the squid.conf file and start/restart/reload the squid service. Setup your browser to use your machine as proxy and while using it&#8217;ll cache all the static content. You should experience some reduction in average page load time.</p>
<p><u><strong>Advantages</strong></u></p>
<p>I am currently using squid in above configuration. And its turning out to be nice for me. I am browsing websites faster and saving a chunk of bandwidth for my institute.</p>
<p><u><strong>Disadvantages</strong></u></p>
<p>Introduction of another proxy server increases the latency for dynamic content.</p>
<p><u><strong>Notice</strong></u></p>
<p>The above configurations and views are a result of my understanding of squid. If you feel this may break your system or it may have adverse effects, don&#8217;t use them. At least don&#8217;t use these on a production system.</p>
<p><a href="http://gofedora.com/">Fedora Tutorials</a> and <a href="http://cachevideos.com/">Videocache</a> by <a href="http://saini.co.in/">Kulbir Saini</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gofedora.com/how-to-configure-hierarchicy-proxy-servers-squid/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How To: Configure Secure FTP Server (VSFTPD)</title>
		<link>http://gofedora.com/how-to-configure-secure-ftp-server-vsftpd/</link>
		<comments>http://gofedora.com/how-to-configure-secure-ftp-server-vsftpd/#comments</comments>
		<pubDate>Fri, 07 Sep 2007 19:53:48 +0000</pubDate>
		<dc:creator>Kulbir Saini</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[FTP Server]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Automount]]></category>
		<category><![CDATA[Secure FTP]]></category>
		<category><![CDATA[Upload]]></category>
		<category><![CDATA[VSFTPD]]></category>

		<guid isPermaLink="false">http://172.17.8.64/gofedora/?p=227</guid>
		<description><![CDATA[This post is totally dedicated to vsftpd configuration with uploads enabled. vsftpd stands for Very Secure FTP Daemon. It is shipped with almost all the latest Red Hat based OS. vsftpd for rpm based Linux distros can be downloaded from here. Also, one can install vsftpd by issuing &#8216;yum install vsftpd&#8217; or &#8216;apt-get install vsftpd&#8217; [...]<p><a href="http://gofedora.com/">Fedora Tutorials</a> and <a href="http://cachevideos.com/">Videocache</a> by <a href="http://saini.co.in/">Kulbir Saini</a>.</p>
]]></description>
			<content:encoded><![CDATA[<p></p><p>This post is totally dedicated to vsftpd configuration with uploads enabled. vsftpd stands for Very Secure FTP Daemon. It is shipped with almost all the latest Red Hat based OS. vsftpd for rpm based Linux distros can be downloaded from <a href="http://fr.rpmfind.net/linux/rpm2html/search.php?query=vsftpd&amp;submit=Search+..." target="_blank">here</a>. Also, one can install vsftpd by issuing &#8216;yum install vsftpd&#8217; or &#8216;apt-get install vsftpd&#8217; command. After installing vsftpd, you just need to start the vsftpd service.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bordeaux saini<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ service vsftpd start <span style="color: #7a0874; font-weight: bold;">&#91;</span>Enter<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>And you are done. Your computer is now a FTP server. You can browse your ftp server by pointing your favourite browser to ftp://localhost/ or ftp://127.0.0.1/ or ftp://&lt;IP_ADDRESS_OF_YOUR_MACHINE&gt; .</p>
<p>If you see access denied or some error related to access. Issue &#8216;iptables &#8211;flush&#8217; and &#8217;setenforce 0&#8242; commands.</p>
<p>By default the files and directories in /var/ftp/ directory will be shown at ftp://localhost/ .  Now, there are two ways to share your files on ftp.</p>
<p>1. Copy/move files that you want to share to /var/ftp/ directory.</p>
<p>2. Mount directories you want to share to /var/ftp/SharedDirName. Suppose you want to share /home/saini/Movies/ folder on your ftp, then follow the following steps:</p>
<h4><strong>Step 1</strong></h4>
<p>Login as root.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>saini<span style="color: #000000; font-weight: bold;">@</span>bordeaux saini<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">su</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Enter<span style="color: #7a0874; font-weight: bold;">&#93;</span>
Enter Password <span style="color: #000000; font-weight: bold;">for</span> root.</pre></td></tr></table></div>

<h4><strong>Step 2</strong></h4>
<p>Go to /var/ftp/ and create the directory that you want to share.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bordeaux saini<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Enter<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bordeaux <span style="color: #c20cb9; font-weight: bold;">ftp</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> SharedMovies <span style="color: #7a0874; font-weight: bold;">&#91;</span>Enter<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></td></tr></table></div>

<h4><strong>Step 3</strong></h4>
<p>Bind the original directory to SharedMovies.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bordeaux <span style="color: #c20cb9; font-weight: bold;">ftp</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">--bind</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>saini<span style="color: #000000; font-weight: bold;">/</span>Movies<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>SharedMovies<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Enter<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>If you browse your ftp now, you&#8217;ll see SharedMovies folder as well.  You can remove default pub directory if you don&#8217;t like it.</p>
<p>The current ftp server will be a very basic one and will allow only downloads. Below we will see how to configure it so that others are allowed to upload files/directories to your server.</p>
<h4><strong>Step 1</strong></h4>
<p>Create a directory say &#8216;Upload&#8217;.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bordeaux saini<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> Upload <span style="color: #7a0874; font-weight: bold;">&#91;</span>Enter<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Note that this Upload directory can be anywhere either in your home directory or in /var/ftp/ or even on some other partitions.</p>
<h4><strong>Step 2</strong></h4>
<p>Change the ownership of Upload to ftp and change the permissions to 777.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bordeaux saini<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #c20cb9; font-weight: bold;">ftp</span>:<span style="color: #c20cb9; font-weight: bold;">ftp</span> Upload <span style="color: #7a0874; font-weight: bold;">&#91;</span>Enter<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bordeaux saini<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">777</span> Upload <span style="color: #7a0874; font-weight: bold;">&#91;</span>Enter<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></td></tr></table></div>

<h4><strong>Step 3</strong></h4>
<p>If you created Upload at any place other than /var/ftp/ , then bind it to a dir in /var/ftp/ .</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bordeaux saini<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>Uploads <span style="color: #7a0874; font-weight: bold;">&#91;</span>Enter<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bordeaux saini<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">--bind</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>saini<span style="color: #000000; font-weight: bold;">/</span>Upload<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>Uploads<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Enter<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></td></tr></table></div>

<h4><strong>Step 4</strong></h4>
<p>Configure vsftpd.conf . The default configuration files for vsftpd lives in /etc/vsftpd/ . vsftpd.conf is configuration file for vsftpd.<br />
Open /etc/vsftpd/vsftpd.conf in any editor and add/uncomment the following lines :</p>
<p>Lines to be added or uncomments in /etc/vsftpd/vsftpd.conf</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">anonymous_enable</span>=YES
<span style="color: #007800;">write_enable</span>=YES
<span style="color: #007800;">write_enable</span>=YES
<span style="color: #007800;">anon_upload_enable</span>=YES
<span style="color: #007800;">anon_mkdir_write_enable</span>=YES
<span style="color: #007800;">anon_other_write_enable</span>=YES
<span style="color: #007800;">dirmessage_enable</span>=YES
<span style="color: #007800;">dirlist_enable</span>=YES
<span style="color: #007800;">no_anon_password</span>=YES
<span style="color: #007800;">file_open_mode</span>=0777
<span style="color: #007800;">guest_enable</span>=YES</pre></td></tr></table></div>

<p>Save vsftpd.conf file and restart the vsftpd service with the command &#8217;service vsftpd restart&#8217;. Now anyone can upload files to your ftp server, but only to Upload folder.</p>
<p>There are certain more configurations which are related to restricting bandwidth, upload/download speed, connections etc.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">max_per_ip</span>=<span style="color: #000000;">2</span> <span style="color: #666666; font-style: italic;"># Max no. of allowed connections per IP Address.</span>
<span style="color: #007800;">max_clients</span>=<span style="color: #000000;">3</span> <span style="color: #666666; font-style: italic;"># Max no. of different IP Addressed which are allowed to connect.</span>
<span style="color: #007800;">anon_max_rate</span>=<span style="color: #000000;">1097152</span> <span style="color: #666666; font-style: italic;"># Max bytes/sec a user can upload/download to/from your ftp server.</span>
<span style="color: #007800;">banner_file</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vsftpd<span style="color: #000000; font-weight: bold;">/</span>ftp_banner <span style="color: #666666; font-style: italic;"># The file containing the welcome message to be displayed to the clients.</span></pre></td></tr></table></div>

<p>For more configuration options, refer man pages for vsftpd.conf and vsftpd.</p>
<p>Note :</p>
<ul>
<li> Whenever you restart your computer, you have to bind the directories everytime, so that they are shown on the ftp server. To skip binding every time, write everything (all commands for binding) in a <a href="http://gofedora.com/wp-content/uploads/linux/mount.sh" target="_blank">mount.sh</a> file and run it whenever you  restart your computer.</li>
<li>You can view my vsftpd.conf file <a href="http://gofedora.com/wp-content/uploads/linux/vsftpd.conf" target="_blank">here</a>.</li>
<li>Sometime, uploaded files doesn&#8217;t have 777 permissions. You can run this <a href="http://gofedora.com/wp-content/uploads/linux/chown.sh" target="_blank">shell script</a> in background forever.</li>
</ul>
<p>PS0 : Absence of compat-libstdc++-33(libstdc++.so.5) is breaking a large no. of applications in Fedora 7. Here&#8217;s a solution <a href="http://gofedora.com/archives/2007/08/22/bug-strange-libstdcso5-problem-fedora-7/">anyway</a>.</p>
<p><a href="http://gofedora.com/">Fedora Tutorials</a> and <a href="http://cachevideos.com/">Videocache</a> by <a href="http://saini.co.in/">Kulbir Saini</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gofedora.com/how-to-configure-secure-ftp-server-vsftpd/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

