<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-28683368</id><updated>2008-05-05T23:07:53.590-07:00</updated><title type='text'>Coded zone</title><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default?start-index=26&amp;max-results=25'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml'/><author><name>Rajesh</name></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>43</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-28683368.post-5860058032879598621</id><published>2007-07-23T12:51:00.001-07:00</published><updated>2007-07-23T12:57:07.206-07:00</updated><title type='text'>Free webhosting</title><content type='html'>&lt;p&gt;Free and paid webhosting started, as an e-commerce website.&lt;/p&gt; &lt;p&gt;&lt;a href="http://sales.rajesh.com.np"&gt;http://sales.rajesh.com.np&lt;/a&gt;, Its getting positive feedbacks. &lt;/p&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2007/07/free-webhosting.html' title='Free webhosting'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=5860058032879598621' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/5860058032879598621'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/5860058032879598621'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-2843346605081121809</id><published>2007-07-16T06:14:00.001-07:00</published><updated>2007-07-16T06:46:51.115-07:00</updated><title type='text'>VI find and replace</title><content type='html'>&lt;p&gt;Introduction: This tutorial is meant for VI text editor, mainly for linux, generally used in Console [my black Screen]&lt;/p&gt; &lt;p&gt;Tutorial Reference:&lt;br&gt;&lt;a href="http://www.linux.ie/tutorials/vi2.html"&gt;Linux.ie&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;Search&lt;/b&gt; (Wraped around at end of file): &lt;br&gt;&amp;nbsp; Search STRING forward :&amp;nbsp;&amp;nbsp; / STRING.&lt;br&gt;&amp;nbsp; Search STRING backward:&amp;nbsp;&amp;nbsp; ? STRING.&lt;br&gt;&amp;nbsp; Repeat search:&amp;nbsp;&amp;nbsp; n&lt;br&gt;&amp;nbsp; Repeat search in opposite direction:&amp;nbsp; N&amp;nbsp; (SHIFT-n)&lt;br&gt; &lt;p&gt;&lt;strong&gt;Find and Replace&lt;br&gt;&lt;/strong&gt;First occurrence on current line: :s/OLD/NEW &lt;br&gt;Globally (all) on current line: :s/OLD/NEW/g&lt;/p&gt; &lt;p&gt;How did this happen?&lt;/p&gt; &lt;p&gt;Actually IPs changed from 203.91.136.234 to 116.90.239.10.&lt;br&gt;I had access to only vi editor and then, I need to replace the former with the latter. Later I&amp;nbsp;found this :&lt;/p&gt; &lt;p&gt;:s/203.91.136.234/116.90.239.10/g &lt;p&gt;This just replaced 203.91.136.234 to 116.90.239.10 and the operator g was meant for global, same as in Perl. &lt;p&gt;Doing this, that is invoking the command in vi command prompt&amp;nbsp;solved all my problem. But every time I had to press "&amp;nbsp;n " for finding 203.91.136.234. Then invoking &lt;strong&gt;:s/203.91.136.234/116.90.239.10/g&lt;/strong&gt; this solved them.&lt;/p&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2007/07/vi-find-and-replace.html' title='VI find and replace'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=2843346605081121809' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/2843346605081121809'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/2843346605081121809'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-2427382640091528949</id><published>2007-07-16T06:13:00.001-07:00</published><updated>2007-07-16T06:13:21.719-07:00</updated><title type='text'>Mysql creating new users and assigning permissions</title><content type='html'>&lt;p&gt;Recently I tried to create a database to install mambo.&lt;/p&gt; &lt;p&gt;mysql&amp;gt; use forum_mambo&lt;br&gt;Database changed&lt;br&gt;mysql&amp;gt; GRANT ALL PRIVILEGES ON forum_mambo to forum_mambo@localhost identified by 'forum_mambo';&lt;br&gt;Query OK, 0 rows affected (0.11 sec) &lt;/p&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2007/07/mysql-creating-new-users-and-assigning.html' title='Mysql creating new users and assigning permissions'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=2427382640091528949' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/2427382640091528949'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/2427382640091528949'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-5126953941649538220</id><published>2007-07-12T13:42:00.001-07:00</published><updated>2007-07-12T13:51:54.535-07:00</updated><title type='text'>Google Google Google..</title><content type='html'>&lt;p&gt;Here is something.. Googling in Google for how much I Googled in Google.com returned this . lol. This shows that I google much time during the nights from 9-4 @morning. Normally I sleep at 5,6,7,8 and I am @college at 9,10,11,12. &lt;/p&gt; &lt;p&gt;Surfing starts either at 3 or at 5 (College closes at 4) &lt;/p&gt; &lt;p&gt;7 and 8 is the Dinner time and so.. relatively less stats indicates that too. &lt;/p&gt; &lt;p&gt;I am more active at weekends Fri, Sat and Sundays hmm..&amp;nbsp; &lt;br&gt;and umm I don't use much at the start of the semesters like @Feb, March, &amp;nbsp;Aug, Sep and Oct . Okay cool&lt;/p&gt; &lt;p&gt;Google Trends created this Graph for me.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a title="search trends" href="http://www.flickr.com/photos/9841171@N04/790446269/"&gt;&lt;img alt="search trends" src="http://static.flickr.com/1329/790446269_403ef94d58.jpg" border="0"&gt;&lt;/a&gt;&lt;/p&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2007/07/google-google-google.html' title='Google Google Google..'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=5126953941649538220' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/5126953941649538220'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/5126953941649538220'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-7373875688767978381</id><published>2007-07-11T11:43:00.001-07:00</published><updated>2007-07-11T14:16:59.024-07:00</updated><title type='text'>The world of Black Screen</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;This is a sample remote system we are going to investigate..&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/1nmapku.edu.np.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="180" alt="1 nmap ku.edu.np" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/1nmapku.edu.np_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Then I started playing inside..&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/2diglocalhost.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="180" alt="2 dig  localhost" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/2diglocalhost_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Later I made sure if the DNS server is working or not.. by using Dig command&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/3diglocalhostport53.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="180" alt="3 dig localhost port 53" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/3diglocalhostport53_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Now I stopped the Name server: "service named stop"&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/4servicenamedstop.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="49" alt="4 service named stop" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/4servicenamedstop_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Dig localhost, to ensure which name server is working . Since our name server is stopped just a second ago, It might be another parent server that would reply by the dig. Here was the case that 202.52.242.65 replied at port 53. [This follows the precedence&amp;nbsp;from /etc/resolv.conf]&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/5diglocalhostport53afternamedshutdown_3.jpg" atomicselection="true"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="151" alt="5 dig localhost port 53 after named shutdown" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/5diglocalhostport53afternamedshutdown_thumb_3.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Below is the famous "Cannot Find server" lol &amp;nbsp;.. because the name server is down&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/6cannotfindserver_3.jpg" atomicselection="true"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="138" alt="6 cannot find server" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/6cannotfindserver_thumb_3.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The files resolv.conf contains the information about which servers to contact. It is usually found at /etc/resolv.conf .&lt;/p&gt; &lt;p&gt;I have here two of the name servers listed. If one fails it contacts the another. However most of the queries will be fetched from the first server.&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/6resolvdotconf.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="110" alt="6 resolv dot conf" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/6resolvdotconf_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Now since our local DNS (Domain Name Server) is down. Lets try to find the ip of hotmail.com by invoking : dig hotmail.com&lt;/p&gt; &lt;p&gt;This will return obviously the ip of hotmail.com as well as the ip of the Server which did the job for us. Most probably here will be 202.52.242.65 to do this for us , because we have kept its name at the second place. The one in the first place is 202.52.242.110, which is our local ip, and its DNS (Domain Name Server) is down now.&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/7dighotmail.com.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="168" alt="7 dig hotmail.com" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/7dighotmail.com_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Now lets start our name server. Service named start.&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/7servicenamedstart.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="25" alt="7 service named start" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/7servicenamedstart_thumb.jpg" width="248" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The Error logs, or any logs are printed inside the /var/log/messages at the last portion. You may use tail function, or cat to print the latest log messages about the starting of the name server. Usually during starting name servers.. when there are errors .. I have found no error log is printed at the console, rather errors are printed at the log files. So Its better to find these stuffs there.. Remember /var/log/messages&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/8varlogmessagesafternamedstart.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="94" alt="8 var log messages -- after named start" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/8varlogmessagesafternamedstart_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Here it goes .. Now our DNS is running and, there is at least one server who will reply to our query for the domain. Remember last cannot find server. This time.. it won't say&amp;nbsp; so.. Rather it worked.. See my domain is working now..&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/9rapa.rajesh.com.npsuccess.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="127" alt="9 rapa.rajesh.com.np success" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/9rapa.rajesh.com.npsuccess_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Okay what is there in the files of name servers? These files are situated inside the folder /var/named/ .&amp;nbsp; Actually name server is configured by a configuration file /etc/named.conf, in which the directory /var/named is defined. I too have used the same configuration. Hence my files reside at /var/named. Inside that file are other files, within which, we can define different zones, and different subdomains.. like I have used a domain here kucc.ku.edu.np and defined different subdomains within this domain. So simple create any file and define subdomains. like A records,&amp;nbsp;the www subdomain of &amp;nbsp;kucc.ku.edu.np is defined inside kucc.ku.edu.np as : &lt;br&gt;www&amp;nbsp;IN A 202.52.242.110.&lt;br&gt;Which means that,&amp;nbsp;the ip of the subdomain "www.kucc.ku.edu.np"&amp;nbsp; is 202.52.242.110.&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/10varnamedfilelist.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="10 var named file list" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/10varnamedfilelist_thumb.jpg" width="203" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Okay well we talked about named.conf Here is the screenshot of /var/named/named.conf&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/11etcnamed.conf.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="11 etc named.conf" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/11etcnamed.conf_thumb.jpg" width="162" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Now lets check it out what the DNS analyzers say, like DNSSTUFF.com has something to say about us.. whether working or not..&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/12dnsstuff.com.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="104" alt="12 dnsstuff.com" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/12dnsstuff.com_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Okay just click the lookup button and there you go: the details of dns related stuff.&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/13resolveddnstuff.com.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="111" alt="13 resolved dnstuff.com" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/13resolveddnstuff.com_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;/var/named/named.ca&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/14named.ca.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="183" alt="14 named.ca" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/14named.ca_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;/var/named/kucc.ku.edu.np&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/15namedkucc.ku.edu.np.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="232" alt="15 named - kucc.ku.edu.np" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/15namedkucc.ku.edu.np_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Below is the history of whatever we did until now..&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/17historyuptonow.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="17 history upto now" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/17historyuptonow_thumb.jpg" width="97" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Now lets start towards mail servers. Lets perform nmap scan to see which ports are open for us to watch. If mail servers are on, smtp port 25,and pop3 port 111 must be open.&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/18mailserverscan.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="18 mail server scan" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/18mailserverscan_thumb.jpg" width="221" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Now lets check by telnetting the ports. telnet at port 25 and telnet at port 110.&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/20telnetkucc.ku.edu.np25and110.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="202" alt="20 telnet kucc.ku.edu.np 25 and 110" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/20telnetkucc.ku.edu.np25and110_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Okay our mail server is running.. Lets login&lt;br&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/21webmaillogin.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="21 webmail login" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/21webmaillogin_thumb.jpg" width="228" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;and after logging we get mails inside it:&lt;br&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/22loggedinsidemail.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="163" alt="22 logged inside mail" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/22loggedinsidemail_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;One benefit of having a mail server is that, the system mails all the attacks and logs to the mail server, so that we can check them periodically. Not that you have to go to /var/log/message to check them all the time .. The logs are sent to the mail box as shown above. In traditional way, we had to check the attacks manually like below:&lt;/p&gt; &lt;p&gt;&lt;a href="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/23dailyattackinsshlist.jpg" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="60" alt="23 daily attack in ssh list" src="http://ww.rajesh.com.np/uploaded_images/EnteringanewworldofBlackScreen_5A5/23dailyattackinsshlist_thumb.jpg" width="240" border="0"&gt;&lt;/a&gt;&lt;/p&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2007/07/entering-new-world-of-black-screen.html' title='The world of Black Screen'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=7373875688767978381' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/7373875688767978381'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/7373875688767978381'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-2644877054937332665</id><published>2007-07-09T09:44:00.001-07:00</published><updated>2007-07-09T09:49:34.932-07:00</updated><title type='text'>Windows Live writer for blogger</title><content type='html'>&lt;p&gt;Windows Live writer is Cute and nice for blogger.com and you can use it with other accounts. windows live spaces, WordPress, or other blogging sites. This one is from windows&amp;nbsp;live writer. Wow excellent !! This works and is great. I love this stuff. Yeah. &lt;/p&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2007/07/windows-live-writer-for-blogger.html' title='Windows Live writer for blogger'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=2644877054937332665' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/2644877054937332665'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/2644877054937332665'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-3215206126983710598</id><published>2007-07-06T19:47:00.000-07:00</published><updated>2007-07-06T19:54:37.280-07:00</updated><title type='text'>Photograph for Pulitzer 1995</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://ww.rajesh.com.np/uploaded_images/image5-736233.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://ww.rajesh.com.np/uploaded_images/image5-736227.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;    &lt;br /&gt;     I hope this picture will always serve as a reminder to us that how&lt;br /&gt;fortunate we are and that we must never ever take things for granted.&lt;br /&gt;&lt;br /&gt;     We  must  all  realise  our  social  responsibilities.</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2007/07/photograph-for-pulitzer-1995.html' title='Photograph for Pulitzer 1995'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=3215206126983710598' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/3215206126983710598'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/3215206126983710598'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-5775125221201744494</id><published>2007-07-06T19:40:00.000-07:00</published><updated>2007-07-06T19:42:18.365-07:00</updated><title type='text'>Difference between Focusing on Problems and Focusing on   Solutions</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Case 1&lt;/span&gt;     When NASA began the launch of astronauts into space, they found out that &lt;br /&gt;the pens wouldn't work at zero gravity (ink won't flow down to the writing &lt;br /&gt;surface). To solve this problem, it took them one decade and $12 million. &lt;br /&gt;They developed a pen that worked at zero gravity, upside down, underwater, &lt;br /&gt;in practically any surface including crystal and in a temperature range &lt;br /&gt;from below freezing to over 300 degrees C. &lt;br /&gt;&lt;br /&gt;And what did the Russians do...?? They used a pencil. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Case 2 &lt;/span&gt;    One of the most memorable case studies on Japanese management was the case &lt;br /&gt;of the empty soapbox, which happened in one of Japan's biggest cosmetics &lt;br /&gt;companies. The company received a complaint that a consumer had bought a &lt;br /&gt;soapbox that was empty. Immediately the authorities isolated the problem &lt;br /&gt;to the assembly! line, which transported all the packaged boxes of soap &lt;br /&gt;to the delivery department. For some reason, one soapbox went through the &lt;br /&gt;assembly line empty. Management asked its engineers to solve the problem. &lt;br /&gt;Post-haste, the engineers worked hard to devise an X-ray machine with &lt;br /&gt;high-resolution monitors manned by two people to watch all the soapboxes &lt;br /&gt;that passed through the line to make sure they were not empty. No doubt, &lt;br /&gt;they worked hard and they worked fast but they spent a whoopee amount to &lt;br /&gt;do so. &lt;br /&gt;&lt;br /&gt;But when a rank-and-file employee in a small company was posed with the &lt;br /&gt;same problem, he did not get into complications of X-rays, etc., but &lt;br /&gt;instead came out with another solution. He bought a strong industrial &lt;br /&gt;electric fan and pointed it at the assembly line. He switched the fan on, &lt;br /&gt;and as each soapbox passed the fan, it simply blew the empty boxes out of &lt;br /&gt;the line. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Moral&lt;/span&gt; : Always look for simple solutions. &lt;br /&gt;Devise the simplest possible solution that solves the problems &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Always Focus on solutions &amp; not on problems &lt;/span&gt;&lt;br /&gt;So at the end of the day the thing that really matters is HOW ONE LOOKS INTO &lt;br /&gt;THE PROBLEM, mere perceptions can solve the tough probs...</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2007/07/difference-between-focusing-on-problems.html' title='Difference between Focusing on Problems and Focusing on   Solutions'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=5775125221201744494' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/5775125221201744494'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/5775125221201744494'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-2530752195473248212</id><published>2007-01-04T09:56:00.000-08:00</published><updated>2007-07-09T14:51:08.439-07:00</updated><title type='text'>Eleven Commandments of hi5</title><content type='html'>&lt;p&gt;&lt;span style="font-family: comic sans ms,verdana"&gt;&lt;span style="font-family: comic sans ms"&gt;&lt;span style="font-weight: bold"&gt;ONE&lt;/span&gt;&lt;br&gt;If you’re ugly, stop acting like you don’t know it &amp;amp; stop using cute&lt;br&gt;nicknames. The captions under your picture that says “top model pose”,&lt;br&gt;“sexy”, “arnt i hot” doesn’t convince anyone.&lt;br&gt;&lt;br&gt;&lt;span style="font-weight: bold"&gt;TWO&lt;/span&gt;&lt;br&gt;To the people who have like over 1000 friends, are you serious? Nobody&lt;br&gt;in this universe can keep up with that many friends. You’re just&lt;br&gt;stupid. Go play in traffic.&lt;br&gt;&lt;br&gt;&lt;span style="font-weight: bold"&gt;THREE&lt;/span&gt;&lt;br&gt;If you’re real pretty, dont approve all friends request and bitching&lt;br&gt;later on how u hate getting stupid comments &amp;amp; messages. You’re the one&lt;br&gt;who approved them in the 1st place!! Be realistic on what u’re getting into!!&lt;br&gt;&lt;br&gt;&lt;span style="font-weight: bold"&gt;FOUR&lt;/span&gt;&lt;br&gt;Don’t ever post pictures and say “OMG, I’m so ugly” “OMG,I’m so fat” because if you were, you wouldn’t post them.&lt;br&gt;&lt;br&gt;&lt;span style="font-weight: bold"&gt;FIVE&lt;/span&gt;&lt;br&gt;Stop peeping others scrap book to see wot that guy or gal have conversed. Also stop being a Tomboy looking for hot chicks in others profiles.&lt;br&gt;(vice versa too)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family: comic sans ms,verdana"&gt;&lt;span style="font-family: comic sans ms"&gt;&lt;br&gt;&lt;span style="font-weight: bold"&gt;SIX&lt;/span&gt;&lt;br&gt;Writing tons of scraps a day, begging people to send a testimonial, etc.. ” IS PATHETIC &amp;amp; IMATURE. ” .PEOPLE WHO ACTUALLY CARE ABOUT YOU WILL SEND YOU TESTIMONIALS.. Pls dont junk others scrap book so to get your&lt;br&gt;scrap figures multiply!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family: comic sans ms,verdana"&gt;&lt;span style="font-family: comic sans ms"&gt;&lt;br&gt;&lt;span style="font-weight: bold"&gt;SEVEN&lt;/span&gt;&lt;br&gt;If all your pictures look the same, don’t post them all. Please put some variety in your pics. Nobody wants to see your face 10 different ways.&lt;br&gt;&lt;br&gt;&lt;span style="font-weight: bold"&gt;EIGHT&lt;/span&gt;&lt;br&gt;Who really cares if I/U don’t accept you/me as a friend? MOVE ON!!! &lt;br&gt;Don’t send me another request or message asking “what’s up with you not adding me?” I don’t want you as a friend; that’s what’s up!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family: comic sans ms,verdana"&gt;&lt;span style="font-family: comic sans ms"&gt;&lt;br&gt;&lt;span style="font-weight: bold"&gt;NINE&lt;/span&gt;&lt;br&gt;Little 6th graders, go somewhere else because nobody wants you here and than hi5, you have better things in dis world to get addicted!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family: comic sans ms,verdana"&gt;&lt;span style="font-family: comic sans ms"&gt;&lt;br&gt;&lt;span style="font-weight: bold"&gt;TEN&lt;/span&gt;&lt;br&gt;Nobody cares about threats over the internet. Don’t try to act hardcore with the keyboard. Fighting online is like racing in the special olympics; even if you win, you’re still retarded.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family: comic sans ms,verdana"&gt;&lt;span style="font-family: comic sans ms"&gt;&lt;span style="font-weight: bold"&gt;ELEVEN&lt;/span&gt;&lt;br&gt;If you get a scrap message and it says something like “repost this &lt;br&gt;within 100 seconds or a ghost will rape your dog tonight!!,” IT’S NOT &lt;br&gt;REAL!!QUIT BEING AN IDIOT!!!!!!!!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2007/01/eleven-commandments-of-hi5.html' title='Eleven Commandments of hi5'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=2530752195473248212' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/2530752195473248212'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/2530752195473248212'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-5474141441724400789</id><published>2007-01-03T04:57:00.000-08:00</published><updated>2007-01-03T06:00:55.700-08:00</updated><title type='text'>Oops 16bit assembly</title><content type='html'>&lt;span style="font-family:verdana;"&gt;I tried to mess with some executables. I have &lt;br /&gt;been using a Desktop manager and it is a trial version. So I tried to mess with their codes. And before &lt;br /&gt;I could do anything I needed Assembly language to be run in my computer. I wanted to run some hello world &lt;br /&gt;stuffs, those codes I had done previously, and which were familiar to me before &lt;br /&gt;I used windows XP service pack2 .&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;I used to&amp;nbsp; run those codes in win98 and winxp(sp1).&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:Comic Sans MS,verdana;"&gt;Now after 1-2 years , I can't run TASM . &lt;br /&gt;While I tried to compile and link using TLINK to&amp;nbsp; a &amp;quot;hello world&amp;quot; assembly &lt;br /&gt;program in Windows, it gives an error like :&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;"&lt;span style="font-family:courier new;"&gt;16 bit MS-DOS Subsystem&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;c:\windows\system\cmd.exe -tlink ara.obj&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;X#=0D,CS=01B7 IP=00000231. The NTVDM CPU has encountered an unhandled exception.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-family:courier new;"&gt;Choose 'close' to terminate the application&lt;/span&gt;."&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:Comic Sans MS,verdana;"&gt;&lt;br&gt;&lt;br /&gt;Then it gives a &amp;quot;&lt;u&gt;C&lt;/u&gt;lose&amp;quot; and &amp;quot;I&lt;u&gt;g&lt;/u&gt;nore&amp;quot; options over a dialog button. &lt;br /&gt;At both cases I can't link the obj file with the linker. This is a bullshit. &lt;br /&gt;Windows takes all the control over the Operating System and what am I . Nothing. &lt;br /&gt;A user who can't level up . Damn!!.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;font face="Comic Sans MS"&gt;I searched over the internet all around but everyone says&lt;/font&gt;&lt;span style="font-family:verdana;"&gt;: use 32 bit programming codes. and use TASM32 and TLINK32.&lt;br&gt;&lt;br /&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="font-family:Comic Sans MS,verdana;"&gt;Nah I don't wanna do that. I need TASM and TLINK cuzz I like playing with 16 bits. They are easier and give more control to me. 32 bits !! why 32 bits. If I am the programmer I need all the controls. Computers are for me , I am not for computers. Humans modify computers .. If computers start modifying humans thats unfair.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Comic Sans MS,verdana;"&gt;If I don't find a solution I have the solution, I will go back to windows98 and the service pack1 windows. Have the job done and return back. Thanks God I kept backup of all these.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family: 'Comic Sans MS',verdana"&gt;Sources that I was using :&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: Comic Sans MS,verdana;" href="http://www.cyberarmy.net/forum/dinahtut/messages/291338.html"&gt;Assembly Language for NewBies&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2007/01/oops-16bit-assembly.html' title='Oops 16bit assembly'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=5474141441724400789' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/5474141441724400789'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/5474141441724400789'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-2736933201752453250</id><published>2006-12-24T16:24:00.000-08:00</published><updated>2006-12-24T16:25:06.229-08:00</updated><title type='text'>modifications made</title><content type='html'>modifications made, added some links, removed blogger button and changed templates.</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/12/modifications-made.html' title='modifications made'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=2736933201752453250' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/2736933201752453250'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/2736933201752453250'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-527499164624313047</id><published>2006-11-15T02:35:00.000-08:00</published><updated>2006-12-24T16:14:52.698-08:00</updated><title type='text'>How to login to a remote server via ssh</title><content type='html'>Download SSH (A telnet client) SSH stands for Secure Shell Login. &lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger2/3176/3501/1600/download%20ssh.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger2/3176/3501/400/download%20ssh.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger2/3176/3501/1600/dww_ssh.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger2/3176/3501/400/dww_ssh.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;Select from a list of available download options &lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger2/3176/3501/1600/dww_rate.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger2/3176/3501/400/dww_rate.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;Save it to the Desktop as ssh.exe  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger2/3176/3501/1600/cut.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger2/3176/3501/400/cut.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now Cut the ssh client &lt;br /&gt;&lt;br /&gt;Now Go to windows -&gt; Run -&gt; Type a full stop (That is a "." ) and -&gt; press enter and then press "control V" &lt;a href="http://photos1.blogger.com/blogger2/3176/3501/1600/dot%20run.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger2/3176/3501/400/dot%20run.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The client will be saved in your default directory. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now Just type &lt;br /&gt;ssh username@domain-name.com &lt;br /&gt;A black screen appears and it will prompt to provide a password &lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger2/3176/3501/1600/clear.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger2/3176/3501/400/clear.jpg" border="0" alt="" /&gt;&lt;/a&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/11/how-to-login-to-remote-server-via-ssh.html' title='How to login to a remote server via ssh'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=527499164624313047' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/527499164624313047'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/527499164624313047'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-115083707370359875</id><published>2006-06-20T13:54:00.000-07:00</published><updated>2006-12-24T16:14:10.109-08:00</updated><title type='text'>Milliseconds in C</title><content type='html'>&lt;a href="http://www.thescripts.com/forum/thread212375.html"&gt;http://www.thescripts.com/forum/thread212375.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;clock_t t1 = clock(), t2;&lt;br /&gt;&lt;br /&gt;while ((t2 = clock()) == t1) ;&lt;br /&gt;&lt;br /&gt;printf("CLOCKS_PER_SEC: %.0f resolution: %f sec\n",&lt;br /&gt;&lt;br /&gt;(double)CLOCKS_PER_SEC, (t2 - t1) / (double)CLOCKS_PER_SEC);&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;fangorn:~/tmp 2299&amp;gt; gcc clockres.c&lt;br /&gt;&lt;br /&gt;fangorn:~/tmp 2300&amp;gt; ./a.out&lt;br /&gt;&lt;br /&gt;CLOCKS_PER_SEC: 1000000 resolution: 0.010000 sec&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As you can see, CLOCKS_PER_SEC is merely a conversion factor, it provides&lt;br /&gt;&lt;br /&gt;no indication WRT the resolution of the clock() function. The resolution&lt;br /&gt;&lt;br /&gt;can only be determined at run time, as shown above.</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/06/milliseconds-in-c.html' title='Milliseconds in C'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=115083707370359875' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/115083707370359875'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/115083707370359875'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-115083450594439541</id><published>2006-06-20T12:55:00.000-07:00</published><updated>2006-12-24T16:13:52.489-08:00</updated><title type='text'>milliseconds  of a program in c, time.h</title><content type='html'>&lt;a href="http://www.math.uic.edu/~jan/MCS275/lec41.html"&gt;http://www.math.uic.edu/~jan/MCS275/lec41.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Below is the listing of the main program (stored in &lt;tt&gt;mytimer.c &lt;/tt&gt;),&lt;br /&gt;that contains all routines in one file :&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;/* L-41 MCS 275 Fri 20 Apr 2001 : timing C programs */&lt;br /&gt;&lt;br /&gt;/* The program below compares the time for multiplying two floats&lt;br /&gt;   (single precision) with multiplying two doubles (double precision).&lt;br /&gt;   Because one multplication happens extremely fast (unnoticable),&lt;br /&gt;   we execute many multiplications.  We can test the correctness&lt;br /&gt;   of the timing by executing the program on the prompt like&lt;br /&gt;   prompt&gt; time ./a.out&lt;br /&gt;   The UNIX command time displays after a.out terminates the&lt;br /&gt;   user time (among other things). */&lt;br /&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;time.h&amp;gt;&lt;br /&gt;#define N 100000000&lt;br /&gt;&lt;br /&gt;typedef struct timedata timer;&lt;br /&gt;struct timedata&lt;br /&gt;{&lt;br /&gt;   clock_t  user_time;&lt;br /&gt;   time_t   real_time;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;void tstart ( timer *tmr );&lt;br /&gt;/* initializes the timer */&lt;br /&gt;&lt;br /&gt;void tstop ( timer *tmr );&lt;br /&gt;/* stops the timer */&lt;br /&gt;&lt;br /&gt;long usersec ( timer tmr );&lt;br /&gt;/* returns elapsed seconds user cpu time */&lt;br /&gt;&lt;br /&gt;long realsec ( timer tmr );&lt;br /&gt;/* returns elapsed seconds real time */&lt;br /&gt;&lt;br /&gt;long usermsc ( timer tmr );&lt;br /&gt;/* returns elapsed milliseconds user cpu time */&lt;br /&gt;&lt;br /&gt;long realmsc ( timer tmr );&lt;br /&gt;/* returns elapsed milliseconds real time */&lt;br /&gt;&lt;br /&gt;void tprint ( timer tmr );&lt;br /&gt;/* formatted print of user cpu time, seconds and milliseconds */&lt;br /&gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;   long i;&lt;br /&gt;   timer tmr,total;&lt;br /&gt;   float a, b = 3.3333, c = 5.5555;&lt;br /&gt;   double x, y = 3.3333, z = 5.5555;&lt;br /&gt;&lt;br /&gt;   tstart(&amp;total);&lt;br /&gt;   printf("\nTiming single precision float multiplication : \n");&lt;br /&gt;   tstart(&amp;tmr);&lt;br /&gt;   for (i = 0; i &lt; a =" b*c;" i =" 0;" x =" y*z;"&gt;user_time = clock();&lt;br /&gt;   tmr-&gt;real_time = time(NULL);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void tstop ( timer *tmr )&lt;br /&gt;{&lt;br /&gt;   tmr-&gt;user_time = clock() - tmr-&gt;user_time;&lt;br /&gt;   tmr-&gt;real_time = time(NULL) - tmr-&gt;real_time;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;long usersec ( timer tmr )&lt;br /&gt;{&lt;br /&gt;   return tmr.user_time/CLOCKS_PER_SEC;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;long realsec ( timer tmr )&lt;br /&gt;{&lt;br /&gt;   return tmr.real_time;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;long usermsc ( timer tmr )&lt;br /&gt;{&lt;br /&gt;   return (tmr.user_time*1000)/CLOCKS_PER_SEC;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;long realmsc ( timer tmr )&lt;br /&gt;{&lt;br /&gt;   return (tmr.real_time*1000);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void tprint ( timer tmr )&lt;br /&gt;{&lt;br /&gt;   long usec = usersec(tmr);&lt;br /&gt;   long umsc = usermsc(tmr);&lt;br /&gt;   long rsec = realsec(tmr);&lt;br /&gt;   long rmsc = realmsc(tmr);&lt;br /&gt;&lt;br /&gt;   printf("%s%2d%s%3d%s\n",&lt;br /&gt;          "Elapsed CPU user time : ", usec, " second(s) and ",&lt;br /&gt;           umsc - 1000*usec , " millisecond(s).");&lt;br /&gt;&lt;br /&gt;   printf("%s%2d%s%3d%s\n",&lt;br /&gt;          "Elapsed real time     : ", rsec, " second(s) and ",&lt;br /&gt;           rmsc - 1000*rsec , " millisecond(s).");&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If we put all the timing utilities in the library &lt;tt&gt;libtimer &lt;/tt&gt;,&lt;br /&gt;then our main program &lt;tt&gt;usetimer.c &lt;/tt&gt;looks like&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;/* L-41 MCS 275 Fri 20 Apr 2001 : timing C programs with library */&lt;br /&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include "libtimer.h"&lt;br /&gt;#define N 100000000&lt;br /&gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;   long i;&lt;br /&gt;   timer tmr,total;&lt;br /&gt;   float a, b = 3.3333, c = 5.5555;&lt;br /&gt;   double x, y = 3.3333, z = 5.5555;&lt;br /&gt;&lt;br /&gt;   tstart(&amp;total);&lt;br /&gt;   printf("\nTiming single precision float multiplication : \n");&lt;br /&gt;   tstart(&amp;tmr);&lt;br /&gt;   for (i = 0; i &lt; a =" b*c;" i =" 0;" x =" y*z;"&gt;&lt;br /&gt;&lt;br /&gt;Then &lt;tt&gt;libtimer.h &lt;/tt&gt;has to contain&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;/* L-41 MCS 275 Fri 20 Apr 2001 : creating a library for timing */&lt;br /&gt;&lt;br /&gt;#include &amp;lt;time.h&amp;gt;&lt;br /&gt;&lt;br /&gt;typedef struct timedata timer;&lt;br /&gt;struct timedata&lt;br /&gt;{&lt;br /&gt;   clock_t  user_time;&lt;br /&gt;   time_t   real_time;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;void tstart ( timer *tmr );&lt;br /&gt;/* initializes the timer */&lt;br /&gt;&lt;br /&gt;void tstop ( timer *tmr );&lt;br /&gt;/* stops the timer */&lt;br /&gt;&lt;br /&gt;long usersec ( timer tmr );&lt;br /&gt;/* returns elapsed seconds user cpu time */&lt;br /&gt;&lt;br /&gt;long realsec ( timer tmr );&lt;br /&gt;/* returns elapsed seconds real time */&lt;br /&gt;&lt;br /&gt;long usermsc ( timer tmr );&lt;br /&gt;/* returns elapsed milliseconds user cpu time */&lt;br /&gt;&lt;br /&gt;long realmsc ( timer tmr );&lt;br /&gt;/* returns elapsed milliseconds real time */&lt;br /&gt;&lt;br /&gt;void tprint ( timer tmr );&lt;br /&gt;/* formatted print of user cpu time, seconds and milliseconds */&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;and the file &lt;tt&gt;libtimer.c &lt;/tt&gt;has as content&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;/* L-41 MCS 275 Fri 20 Apr 2001 : timing library */&lt;br /&gt;&lt;br /&gt;/* If this file has the name libtimer.c, we can create the library&lt;br /&gt;   by typing after the prompt :&lt;br /&gt;     prompt&gt; gcc -c libtimer.c&lt;br /&gt;     prompt&gt; ar ruv libtimer.a libtimer&lt;br /&gt;   or with we place in makefile the following :&lt;br /&gt;&lt;br /&gt;libtimer: libtimer.c&lt;br /&gt; gcc -c libtimer.c&lt;br /&gt; ar ruv libtimer.a libtimer.o&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;time.h&amp;gt;&lt;br /&gt;#include "libtimer.h"&lt;br /&gt;&lt;br /&gt;void tstart ( timer *tmr )&lt;br /&gt;{&lt;br /&gt;   tmr-&gt;user_time = clock();&lt;br /&gt;   tmr-&gt;real_time = time(NULL);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void tstop ( timer *tmr )&lt;br /&gt;{&lt;br /&gt;   tmr-&gt;user_time = clock() - tmr-&gt;user_time;&lt;br /&gt;   tmr-&gt;real_time = time(NULL) - tmr-&gt;real_time;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;long usersec ( timer tmr )&lt;br /&gt;{&lt;br /&gt;   return tmr.user_time/CLOCKS_PER_SEC;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;long realsec ( timer tmr )&lt;br /&gt;{&lt;br /&gt;   return tmr.real_time;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;long usermsc ( timer tmr )&lt;br /&gt;{&lt;br /&gt;   return (tmr.user_time*1000)/CLOCKS_PER_SEC;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;long realmsc ( timer tmr )&lt;br /&gt;{&lt;br /&gt;   return (tmr.real_time*1000);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void tprint ( timer tmr )&lt;br /&gt;{&lt;br /&gt;   long usec = usersec(tmr);&lt;br /&gt;   long umsc = usermsc(tmr);&lt;br /&gt;   long rsec = realsec(tmr);&lt;br /&gt;   long rmsc = realmsc(tmr);&lt;br /&gt;&lt;br /&gt;   printf("%s%2d%s%3d%s\n",&lt;br /&gt;          "Elapsed CPU user time : ", usec, " second(s) and ",&lt;br /&gt;           umsc - 1000*usec , " millisecond(s).");&lt;br /&gt;&lt;br /&gt;   printf("%s%2d%s%3d%s\n",&lt;br /&gt;          "Elapsed real time     : ", rsec, " second(s) and ",&lt;br /&gt;           rmsc - 1000*rsec , " millisecond(s).");&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;To create the library and the executables, use the makefile below :&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;libtimer.a: libtimer.h libtimer.c&lt;br /&gt; gcc -c libtimer.c&lt;br /&gt; ar ruv libtimer.a libtimer.o&lt;br /&gt;&lt;br /&gt;mytimer: mytimer.c&lt;br /&gt; gcc -o mytimer mytimer.c&lt;br /&gt;&lt;br /&gt;usetimer: usetimer.c libtimer.a&lt;br /&gt; gcc -o usetimer usetimer.c libtimer.a&lt;br /&gt;&lt;br /&gt;clean:&lt;br /&gt; /bin/rm -f -r *o libtimer.a mytimer usetimer&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/pre&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/06/milliseconds-of-program-in-c-timeh.html' title='milliseconds  of a program in c, time.h'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=115083450594439541' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/115083450594439541'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/115083450594439541'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-114986862273299241</id><published>2006-06-09T08:54:00.000-07:00</published><updated>2006-12-24T16:13:26.590-08:00</updated><title type='text'>program for insertion sort</title><content type='html'>from &lt;a href="http://www.cs.ucsc.edu/~pohl/CBDCourse/hw/kklenk_5.c"&gt;http://www.cs.ucsc.edu/~pohl/CBDCourse/hw/kklenk_5.c&lt;/a&gt;&lt;br /&gt;&lt;pre&gt;/**********************************************************/&lt;br /&gt;/*                                                        */&lt;br /&gt;/*  Author:       Kevin Klenk                             */&lt;br /&gt;/*  Date:         May 25, 1998                            */&lt;br /&gt;/*  Class:        CMPS012A - Spring 1998                  */&lt;br /&gt;/*  Professor:    Ira Pohl                                */&lt;br /&gt;/*  Description:  This program sorts randomly-filled      */&lt;br /&gt;/*                arrays of four sizes (10, 100, 1000 and */&lt;br /&gt;/*                10000) using insertion sort and then    */&lt;br /&gt;/*                does several binary lookups on those    */&lt;br /&gt;/*                arrays.  Originally, the program was    */&lt;br /&gt;/*                also supposed to print timing           */&lt;br /&gt;/*                information, but the clock() function   */&lt;br /&gt;/*                in time.h proved to be too unreliable.  */&lt;br /&gt;/*                                                        */&lt;br /&gt;/**********************************************************/&lt;br /&gt;&lt;br /&gt;/* Required libraries */&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;time.h&amp;gt;&lt;br /&gt;#include &amp;lt;assert.h&amp;gt;&lt;br /&gt;&lt;br /&gt;/* Constants */&lt;br /&gt;#define CLOCKS_PER_SEC 1000000&lt;br /&gt;#define MAXSIZE 10000&lt;br /&gt;#define RANGE 100&lt;br /&gt;#define NUMLOOKUPSTOPRINT 20&lt;br /&gt;#define NUMLOOKUPS 100&lt;br /&gt;&lt;br /&gt;/* Function Prototypes */&lt;br /&gt;void swap(int *a, int *b);&lt;br /&gt;int GetRandNum();&lt;br /&gt;void FillArray(int array[], int size);&lt;br /&gt;void PrintArray(int array[], int size);&lt;br /&gt;void Swap(int *a, int *b);&lt;br /&gt;void InsertionSort(int data[], int size);&lt;br /&gt;int BinaryLookup(int data[], int size, int key, int* position);&lt;br /&gt;&lt;br /&gt;/* Returns a random integer from 0 to RANGE - 1. */&lt;br /&gt;int GetRandNum()&lt;br /&gt;{&lt;br /&gt;   return (rand() % RANGE);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* Fills an array of size integers with random values. */&lt;br /&gt;void FillArray(int array[], int size)&lt;br /&gt;{&lt;br /&gt;  int i;&lt;br /&gt;&lt;br /&gt;  srand(time(NULL));&lt;br /&gt;  for(i = 0; i &amp;lt; size; i++)&lt;br /&gt;    array[i] = GetRandNum();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* Prints an array of size integers to stdout. */&lt;br /&gt;void PrintArray(int array[], int size)&lt;br /&gt;{&lt;br /&gt;   int i;&lt;br /&gt;&lt;br /&gt;   printf("\t");&lt;br /&gt;   for (i = 0; i &amp;lt; size; i++)&lt;br /&gt;      printf("%5d", array[i]);&lt;br /&gt;   printf("\n");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* Swaps two integers. */&lt;br /&gt;void Swap(int *a, int *b)&lt;br /&gt;{&lt;br /&gt;   int tmp = *a;&lt;br /&gt;&lt;br /&gt;   *a = *b;&lt;br /&gt;   *b = tmp;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* Sorts an array of size integers in increasing order using */&lt;br /&gt;/*  the insertion sort algorithm.                            */&lt;br /&gt;void InsertionSort(int data[], int size)&lt;br /&gt;{&lt;br /&gt;   int i, k;&lt;br /&gt;&lt;br /&gt;   for(i = 0; i &amp;lt; size - 1; ++i)&lt;br /&gt;   {&lt;br /&gt;      for(k = i + 1; k &amp;gt; 0; --k)&lt;br /&gt;      {&lt;br /&gt;         if(data[k] &amp;lt; data[k-1])&lt;br /&gt;            Swap(&amp;amp;data[k], &amp;data[k-1]);&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* Looks for an integer, "key", in an array of size integers */&lt;br /&gt;/*  and sets the integer pointed to by position to the index */&lt;br /&gt;/*  which was last checked by the function.  Returns 0 if    */&lt;br /&gt;/*  "key" is not found; returns 1, otherwise.  "position"    */&lt;br /&gt;/*  points to an integer storing the index at which "key" is */&lt;br /&gt;/*  found if it IS in fact found.  Otherwise, the integer    */&lt;br /&gt;/*  pointed to by "position" will contain an index close     */&lt;br /&gt;/*  to the index where "key" would have been found if it     */&lt;br /&gt;/*  were in the array.                                       */&lt;br /&gt;int BinaryLookup(int data[], int size, int key, int* position)&lt;br /&gt;{&lt;br /&gt;   int leftIndex = 0;&lt;br /&gt;   int rightIndex = size - 1;&lt;br /&gt;&lt;br /&gt;   *position = (leftIndex + rightIndex)/2;&lt;br /&gt;&lt;br /&gt;   while ((leftIndex &amp;lt;= rightIndex) &amp;amp;&amp; (key != data[*position]))&lt;br /&gt;   {&lt;br /&gt;      if (key &amp;lt; data[*position])&lt;br /&gt;      {&lt;br /&gt;         leftIndex = leftIndex;&lt;br /&gt;         rightIndex = *position - 1;&lt;br /&gt;         *position = (leftIndex + rightIndex)/2;&lt;br /&gt;      }&lt;br /&gt;      else if (key &amp;gt; data[*position])&lt;br /&gt;      {&lt;br /&gt;         leftIndex = *position + 1;&lt;br /&gt;         rightIndex = rightIndex;&lt;br /&gt;         *position = (leftIndex + rightIndex)/2;&lt;br /&gt;      }&lt;br /&gt;      else&lt;br /&gt;      {&lt;br /&gt;         /* This will never occur because it is prevented by the loop */&lt;br /&gt;         /*  condition.                                               */&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   if (leftIndex &amp;gt; rightIndex)&lt;br /&gt;      return 0;&lt;br /&gt;   else&lt;br /&gt;      return 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* Main */&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;   int currSize, i, r, found, position, numLookups;&lt;br /&gt;   int data[MAXSIZE];&lt;br /&gt;   long before, after;&lt;br /&gt;&lt;br /&gt;   for (currSize = 10; currSize &amp;lt;= MAXSIZE; currSize *= 10)&lt;br /&gt;   {&lt;br /&gt;      printf("\nRUNNING WITH %d ELEMENTS \n\n", currSize);&lt;br /&gt;&lt;br /&gt;      FillArray(data, currSize);&lt;br /&gt;&lt;br /&gt;      if (currSize == 10)&lt;br /&gt;      {&lt;br /&gt;         printf("  Before sorting array is:\n");&lt;br /&gt;         PrintArray(data, currSize);&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;/*      before = clock(); */&lt;br /&gt;      printf("  Sorting the array:\n");&lt;br /&gt;      InsertionSort(data, currSize);&lt;br /&gt;/*&lt;br /&gt;      after = clock();&lt;br /&gt;      printf("\n     Sorting takes %lf seconds. \n\n",&lt;br /&gt;       ((double)(after - before))/CLOCKS_PER_SEC);&lt;br /&gt;*/&lt;br /&gt;      if (currSize == 10)&lt;br /&gt;      {&lt;br /&gt;         printf("  After sorting array is:\n");&lt;br /&gt;         PrintArray(data, currSize);&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;/*      before = clock(); */&lt;br /&gt;&lt;br /&gt;      if (currSize == 10)&lt;br /&gt;         numLookups = NUMLOOKUPSTOPRINT;&lt;br /&gt;      else&lt;br /&gt;         numLookups = NUMLOOKUPS;&lt;br /&gt;      printf("  Doing %d binary lookups:\n", numLookups);&lt;br /&gt;&lt;br /&gt;      for (i = 0; i &amp;lt; numLookups; i++)&lt;br /&gt;      {&lt;br /&gt;         r = GetRandNum();&lt;br /&gt;         found = BinaryLookup(data, currSize, r, &amp;position);&lt;br /&gt;         if (currSize == 10) {&lt;br /&gt;            if (found)&lt;br /&gt;               printf("    element = %2d found at index = %d\n", r, position);&lt;br /&gt;            else&lt;br /&gt;               printf("    element = %2d not found; would be near index = %d\n",&lt;br /&gt;                r, position);&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;/*&lt;br /&gt;      after = clock();&lt;br /&gt;      printf("\n     Doing %d lookups takes %lf seconds. \n\n", NUMLOOKUPS,&lt;br /&gt;       ((double)(after - before))/CLOCKS_PER_SEC);&lt;br /&gt;*/&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/06/program-for-insertion-sort.html' title='program for insertion sort'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=114986862273299241' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114986862273299241'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114986862273299241'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-114937480949172667</id><published>2006-06-03T15:46:00.000-07:00</published><updated>2006-12-24T16:12:56.228-08:00</updated><title type='text'>Cron - Program Scheduler</title><content type='html'>&lt;a href="http://servers.digitaldaze.com/extensions/cron/"&gt;Cron - Program Scheduler&lt;/a&gt;: "Some examples of complete cron table entries are show below, implementing the vnukelog command as an example.&lt;br /&gt;# Any output generated by the cron entries below is sent to the e-mail&lt;br /&gt;# address assigned to the MAILTO environment variable.&lt;br /&gt;MAILTO='webmaster@mycompany.com'&lt;br /&gt;&lt;br /&gt;# Execute the 'vnukelog' command at 1:15 (15 1) AM every day.&lt;br /&gt;15 1 * * * /usr/local/bin/vnukelog&lt;br /&gt;&lt;br /&gt;# Execute the 'vnukelog' command at 11:40 PM (40 23) on the first day (1)&lt;br /&gt;# of each month.&lt;br /&gt;40 23 1 * */usr/local/bin/vnukelog&lt;br /&gt;&lt;br /&gt;# Execute the 'vnukelog' command every 10 minutes for for the first&lt;br /&gt;# half-hour (0-30/10) of the 9:00 AM and 5:00 PM hours (9,17) on&lt;br /&gt;# Monday-Friday (1-5).&lt;br /&gt;0-30/10 9,17 * * 1-5/usr/local/bin/vnukelog&lt;br /&gt;&lt;br /&gt;# Execute the 'vnukelog' command at 4:00 AM, 8:00 AM, 12:00 noon, 4:00 PM,&lt;br /&gt;# and 8:00 PM (0 */4) on each Sunday (sun) every January (jan).&lt;br /&gt;0 */4 * jan sun/usr/local/bin/vnukelog&lt;br /&gt;&lt;br /&gt;# Execute the 'vnukelog' command at 4:30 AM (30 4) on the first, fifteenth&lt;br /&gt;# (1,15), and each Friday (fri) of every month.&lt;br /&gt;30 4 1,15 * fri/usr/local/bin/vnukelog&lt;br /&gt;&lt;br /&gt;# Execute the 'vnukelog' command at 12:00 midnight (0 0) on August 19 (8)&lt;br /&gt;# (aug).&lt;br /&gt;0 0 19 8 */usr/local/bin/vnukelog&lt;br /&gt;0 0 19 aug */usr/local/bin/vnukelog"</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/06/cron-program-scheduler.html' title='Cron - Program Scheduler'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=114937480949172667' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114937480949172667'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114937480949172667'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-114923667030531391</id><published>2006-06-02T01:12:00.000-07:00</published><updated>2006-12-24T16:12:34.404-08:00</updated><title type='text'>How i can refine my search?  search history !! and success historyGoogle Search</title><content type='html'>&lt;div&gt;&lt;br /&gt; &lt;a href="http://www.google.com/search?hl=en&amp;amp;amp;amp;amp;amp;amp;lr=&amp;q=%22one+user%22%2Bmasquerade+iptables"&gt;&lt;br /&gt; &amp;quot;one user&amp;quot;+masquerade iptables - &lt;font size="2"&gt;Google Search:&lt;/a&gt; &lt;br&gt;&lt;br /&gt; Guarddogiptables 1.2.6a - Is anyone using Guarddog with this version of &lt;br /&gt; iptables? ... This means no Guarddog and NAT/IP masquerade on older kernel &lt;br /&gt; 2.2 systems. ... &lt;/font&gt;&lt;br /&gt; &lt;p&gt;&lt;font size="2"&gt;&lt;br&gt;&lt;br /&gt; &lt;/font&gt;&lt;a href="http://www.simonzone.com/software/guarddog/"&gt;&lt;br /&gt; www.simonzone.com/software/guarddog/&lt;/a&gt; - 75k - Cached - Similar pages &lt;br&gt;&lt;br /&gt; iptables and firewall - LinuxQuestions.orgiptables and firewall Linux - &lt;br /&gt; Security. ... how to set firewall to allow only one user (or several users) &lt;br /&gt; from behind the masquerade use p2p programs ...&lt;a href="http://www.linuxquestions.org/"&gt;www.linuxquestions.org/&lt;/a&gt; &lt;br /&gt; questions/showthread.php?t=369895 - 57k - Cached - Similar pages&amp;quot; &lt;br&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; search key words:: &lt;br&gt;&lt;br /&gt; &lt;a href="http://www.google.com/search?hl=en&amp;lr=&amp;q=%22one+user%22%2Bmasquerade+iptables"&gt;&lt;br /&gt; http://www.google.com/search?hl=en&amp;amp;lr=&amp;amp;q=%22one+user%22%2Bmasquerade+iptables&lt;/a&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; &amp;quot;one user&amp;quot;+masquerade iptables &lt;br&gt;&lt;br /&gt; found out what I needed &lt;br&gt;&lt;br /&gt; &lt;a class="l" onmousedown="return clk(this.href,'','','res','2','')" href="http://www.linuxquestions.org/questions/showthread.php?t=369895"&gt;&lt;br /&gt; iptables and firewall - LinuxQuestions.org&lt;/a&gt; &lt;br&gt;&lt;br /&gt; iptables and firewall Linux - Security. ... how to set firewall to allow &lt;br /&gt; only one &lt;br&gt;&lt;br /&gt; user (or several users) from behind the masquerade use p2p programs ... &lt;br&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; &lt;a href="http://www.google.com/search?hl=en&amp;lr=&amp;q=%22one+user%22%2Bmasquerade"&gt;&lt;br /&gt; http://www.google.com/search?hl=en&amp;amp;lr=&amp;amp;q=%22one+user%22%2Bmasquerade&lt;/a&gt; &lt;br&gt;&lt;br /&gt; &amp;quot;one user&amp;quot;+masquerade &lt;br&gt;&lt;br /&gt; top 5 results for google: did not satisfy my query &lt;br&gt;&lt;br /&gt; [PPT]&lt;br /&gt; &lt;a class="l" onmousedown="return clk('http://www1.cs.columbia.edu/~kewang/paper/One%20Class%20Training%20for%20Masquerade%20Detection1.ppt','','','res','1','')" href="http://www1.cs.columbia.edu/~kewang/paper/One%20Class%20Training%20for%20Masquerade%20Detection1.ppt"&gt;&lt;br /&gt; One Class Training for Masquerade Detection&lt;/a&gt; &lt;br&gt;&lt;br /&gt; [PDF]&lt;br /&gt; &lt;a class="l" onmousedown="return clk(this.href,'','','res','2','')" href="http://www1.cs.columbia.edu/ids/publications/DMSEC-camera.PDF"&gt;&lt;br /&gt; One-Class Training for Masquerade Detection&lt;/a&gt; &lt;br&gt;&lt;br /&gt; &lt;a class="l" onmousedown="return clk(this.href,'','','res','3','')" href="http://www.schonlau.net/intrusion.html"&gt;&lt;br /&gt; Statistical Methods for Computer Intrusion Detection&lt;/a&gt; &lt;br&gt;&lt;br /&gt; &lt;a class="l" onmousedown="return clk(this.href,'','','res','4','')" href="http://www.itoc.usma.edu/Workshop/2006/Program/Accepted/73.html"&gt;&lt;br /&gt; IAWorkshop 2006 - Profiling Users in GUI Based Systems for ...&lt;/a&gt; &lt;br&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; What I searched before: &lt;br&gt;&lt;br /&gt; &lt;a href="http://www.google.com/search?hl=en&amp;lr=&amp;q=%22masquerade+one+user%22&amp;btnG=Search"&gt;&lt;br /&gt; http://www.google.com/search?hl=en&amp;amp;lr=&amp;amp;q=%22masquerade+one+user%22&amp;amp;btnG=Search&lt;/a&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; &amp;quot;masquerade one user&amp;quot; &lt;br&gt;&lt;br /&gt; Your search - &amp;quot;masquerade one user&amp;quot; - did not match any documents. &lt;br&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; &lt;a href="http://groups.google.com/groups/search?hl=en&amp;q=%22masquerade+one+user%22"&gt;&lt;br /&gt; http://groups.google.com/groups/search?hl=en&amp;amp;q=%22masquerade+one+user%22&lt;/a&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; &amp;quot;masquerade one user&amp;quot; &lt;br&gt;&lt;br /&gt; Searched all groups &lt;br&gt;&lt;br /&gt; Your search - &amp;quot;masquerade one user&amp;quot; - did not match any documents &lt;br&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; &lt;a href="http://groups.google.com/group/comp.os.linux.networking/browse_thread/thread/3f153ac992873c71/450e5cfefed89aad?lnk=st&amp;q=iptables+tutorial&amp;rnum=1&amp;hl=en#450e5cfefed89aad"&gt;&lt;br /&gt; http://groups.google.com/group/comp.os.linux.networking/browse_thread/thread/3f153ac992873c71/450e5cfefed89aad?lnk=st&amp;amp;q=iptables+tutorial&amp;amp;rnum=1&amp;amp;hl=en#450e5cfefed89aad&lt;/a&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; keywords: iptables tutorial &lt;br&gt;&lt;br /&gt; got : Hello, &lt;br&gt;&lt;br /&gt; I was just taking a look over the iptables tutorial again (&lt;a target="_blank" href="http://www.netfilter.org/documentation/tutorials/blueflux/iptables-"&gt;http://www.netfilter.org/documentation/tutorials/blueflux/iptables-&lt;/a&gt; &lt;br /&gt; tutorial.html) and i noticed .... &lt;br&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; &lt;a href="http://groups.google.com/groups?hl=en&amp;lr=&amp;rls=GGLG,GGLG:2006-18,GGLG:en&amp;q=iptables%20tutorial&amp;sa=N&amp;tab=wg"&gt;&lt;br /&gt; http://groups.google.com/groups?hl=en&amp;amp;lr=&amp;amp;rls=GGLG,GGLG:2006-18,GGLG:en&amp;amp;q=iptables%20tutorial&amp;amp;sa=N&amp;amp;tab=wg&lt;/a&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; keywords:iptables tutorial &lt;br&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; &lt;a href="http://groups.google.com/group/comp.os.linux.networking/browse_thread/thread/3f153ac992873c71/450e5cfefed89aad?lnk=st&amp;q=iptables+tutorial&amp;rnum=1&amp;hl=en#450e5cfefed89aad"&gt;&lt;br /&gt; iptables tutorial - nat&lt;/a&gt; Hello, I was just taking a look over the &lt;br /&gt; iptables tutorial again &lt;br /&gt; (http://www.netfilter.org/documentation/tutorials/blueflux/iptables- &lt;br /&gt; tutorial.html) and i ...&lt;br /&gt; &lt;a class="gl" href="http://groups.google.com/group/comp.os.linux.networking?lnk=sg&amp;hl=en"&gt;&lt;br /&gt; comp.os.linux.networking&lt;/a&gt; &lt;br&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; keywords by order: &lt;br&gt;&lt;br /&gt; &lt;a href="http://www.google.com/search?sourceid=navclient&amp;ie=UTF-8&amp;rls=GGLG,GGLG:2006-18,GGLG:en&amp;q=iptables+help"&gt;&lt;br /&gt; http://www.google.com/search?sourceid=navclient&amp;amp;ie=UTF-8&amp;amp;rls=GGLG,GGLG:2006-18,GGLG:en&amp;amp;q=iptables+help&lt;/a&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; keywords: iptables help &lt;br&gt;&lt;br /&gt; &lt;a href="http://www.gege.org/iptables/doc/faq.html#id2716868"&gt;&lt;br /&gt; http://www.gege.org/iptables/doc/faq.html#id2716868&lt;/a&gt; &lt;br&gt;&lt;br /&gt; &lt;a href="http://www.google.com/search?hl=en&amp;lr=&amp;rls=GGLG%2CGGLG%3A2006-18%2CGGLG%3Aen&amp;q=iptables+tutorial"&gt;&lt;br /&gt; http://www.google.com/search?hl=en&amp;amp;lr=&amp;amp;rls=GGLG%2CGGLG%3A2006-18%2CGGLG%3Aen&amp;amp;q=iptables+tutorial&lt;/a&gt; &lt;br /&gt; keywords: iptables tutorial &lt;br&gt;&lt;br /&gt; &lt;a href="http://groups.google.com/groups?hl=en&amp;lr=&amp;rls=GGLG,GGLG:2006-18,GGLG:en&amp;q=iptables%20tutorial&amp;sa=N&amp;tab=wg"&gt;&lt;br /&gt; http://groups.google.com/groups?hl=en&amp;amp;lr=&amp;amp;rls=GGLG,GGLG:2006-18,GGLG:en&amp;amp;q=iptables%20tutorial&amp;amp;sa=N&amp;amp;tab=wg&lt;/a&gt; &lt;br /&gt; Groups.google.com , keywords: iptables tutorial &lt;br&gt;&lt;br /&gt; &lt;a href="http://groups.google.com/group/comp.os.linux.networking/browse_thread/thread/3f153ac992873c71/450e5cfefed89aad?lnk=st&amp;q=iptables+tutorial&amp;rnum=1&amp;hl=en#450e5cfefed89aad"&gt;&lt;br /&gt; http://groups.google.com/group/comp.os.linux.networking/browse_thread/thread/3f153ac992873c71/450e5cfefed89aad?lnk=st&amp;amp;q=iptables+tutorial&amp;amp;rnum=1&amp;amp;hl=en#450e5cfefed89aad&lt;/a&gt; &lt;br /&gt; keywords: iptables tutorial &lt;br&gt;&lt;br /&gt; &lt;a href="http://groups.google.com/groups/search?hl=en&amp;q=%22masquerade+one+user%22"&gt;&lt;br /&gt; http://groups.google.com/groups/search?hl=en&amp;amp;q=%22masquerade+one+user%22&lt;/a&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; keywords: &amp;quot;masquerade one user&amp;quot; &lt;br&gt;&lt;br /&gt; Your search - &amp;quot;masquerade one user&amp;quot; - did not match any documents. &lt;br&gt;&lt;br /&gt; &amp;quot;masquerade one user&amp;quot; &lt;br&gt;&lt;br /&gt; &lt;a href="http://www.google.com/search?hl=en&amp;lr=&amp;q=%22masquerade+one+user%22&amp;btnG=Search"&gt;&lt;br /&gt; http://www.google.com/search?hl=en&amp;amp;lr=&amp;amp;q=%22masquerade+one+user%22&amp;amp;btnG=Search&lt;/a&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt; &lt;a href="http://www.google.com/search?hl=en&amp;lr=&amp;q=%22one+user%22%2Bone%2Buser"&gt;&lt;br /&gt; http://www.google.com/search?hl=en&amp;amp;lr=&amp;amp;q=%22one+user%22%2Bone%2Buser&lt;/a&gt; &lt;br&gt;&lt;br /&gt; &lt;a href="http://www.google.com/search?hl=en&amp;lr=&amp;q=%22one+user%22%2Bmasquerade"&gt;&lt;br /&gt; http://www.google.com/search?hl=en&amp;amp;lr=&amp;amp;q=%22one+user%22%2Bmasquerade&lt;/a&gt; &lt;br&gt;&lt;br /&gt; &lt;a href="http://www.google.com/search?hl=en&amp;lr=&amp;q=%22one+user%22%2Bmasquerade+iptables"&gt;&lt;br /&gt; http://www.google.com/search?hl=en&amp;amp;lr=&amp;amp;q=%22one+user%22%2Bmasquerade+iptables&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/06/how-i-can-refine-my-search-search.html' title='How i can refine my search?  search history !! and success historyGoogle Search'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=114923667030531391' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114923667030531391'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114923667030531391'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-114923576995548631</id><published>2006-06-02T01:04:00.000-07:00</published><updated>2006-12-24T16:12:05.681-08:00</updated><title type='text'>Linux 2.4 Packet Filtering HOWTO: Using iptables</title><content type='html'>&lt;a href="http://www.netfilter.org/documentation/HOWTO//packet-filtering-HOWTO-7.html"&gt;Linux 2.4 Packet Filtering HOWTO: Using iptables&lt;/a&gt;: "Creating a New Chain&lt;br /&gt;Let's create a new chain. Because I am such an imaginative fellow, I'll call it test. We use the `-N' or `--new-chain' options:&lt;br /&gt;# iptables -N test&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;It's that simple. Now you can put rules in it as detailed above.&lt;br /&gt;Deleting a Chain&lt;br /&gt;Deleting a chain is simple as well, using the `-X' or `--delete-chain' options. Why `-X'? Well, all the good letters were taken.&lt;br /&gt;# iptables -X test&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;There are a couple of restrictions to deleting chains: they must be empty (see Flushing a Chain below) and they must not be the target of any rule. You can't delete any of the three built-in chains.&lt;br /&gt;If you don't specify a chain, then all user-defined chains will be deleted, if possible.&lt;br /&gt;Flushing a Chain&lt;br /&gt;There is a simple way of emptying all rules out of a chain, using the `-F' (or `--flush') commands.&lt;br /&gt;# iptables -F FORWARD&lt;br /&gt;#"&lt;br /&gt;&lt;br /&gt;Resetting (Zeroing) Counters&lt;br /&gt;It is useful to be able to reset the counters. This can be done with the `-Z' (or `--zero') option.&lt;br /&gt;Consider the following:&lt;br /&gt;# iptables -L FORWARD&lt;br /&gt;# iptables -Z FORWARD&lt;br /&gt;#&lt;br /&gt;&lt;a name="policy"&gt;&lt;/a&gt;Setting Policy&lt;br /&gt;The policy can be either ACCEPT or DROP, for example:&lt;br /&gt;# iptables -P FORWARD DROP&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.netfilter.org/documentation/HOWTO//packet-filtering-HOWTO.html"&gt;Linux 2.4 Packet Filtering HOWTO&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So What's A Packet Filter?&lt;br /&gt;3.1 Why Would I Want to Packet Filter?&lt;br /&gt;3.2 How Do I Packet Filter Under Linux?&lt;br /&gt;&lt;br /&gt;4. Who the hell are you, and why are you playing with my kernel?&lt;br /&gt;&lt;br /&gt;5. Rusty's Really Quick Guide To Packet Filtering&lt;br /&gt;&lt;br /&gt;6. How Packets Traverse The Filters&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.netfilter.org/documentation/index.html"&gt;Netfilter FAQ (Frequently Asked Questions)&lt;br /&gt;&lt;/a&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/06/linux-24-packet-filtering-howto-using.html' title='Linux 2.4 Packet Filtering HOWTO: Using iptables'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=114923576995548631' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114923576995548631'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114923576995548631'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-114923544243195706</id><published>2006-06-02T01:03:00.000-07:00</published><updated>2006-12-24T16:11:38.923-08:00</updated><title type='text'>Linux 2.4 Packet Filtering HOWTO: Mixing NAT and Packet Filtering</title><content type='html'>&lt;a href="http://www.netfilter.org/documentation/HOWTO//packet-filtering-HOWTO-9.html"&gt;Linux 2.4 Packet Filtering HOWTO: Mixing NAT and Packet Filtering&lt;/a&gt;: "9. Mixing NAT and Packet Filtering&lt;br /&gt;It's common to want to do Network Address Translation (see the NAT HOWTO) and packet filtering. The good news is that they mix extremely well.&lt;br /&gt;You design your packet filtering completely ignoring any NAT you are doing. The sources and destinations seen by the packet filter will be the `real' sources and destinations. For example, if you are doing DNAT to send any connections to 1.2.3.4 port 80 through to 10.1.1.1 port 8080, the packet filter would see packets going to 10.1.1.1 port 8080 (the real destination), not 1.2.3.4 port 80. Similarly, you can ignore masquerading: packets will seem to come from their real internal IP addresses (say 10.1.1.1), and replies will seem to go back there.&lt;br /&gt;You can use the `state' match extension without making the packet filter do any extra work, since NAT requires connection tracking anyway. To enhance the simple masquerading example in the NAT HOWTO to disallow any new connections from coming in the ppp0 interface, you would do this:&lt;br /&gt;# Masquerade out ppp0&lt;br /&gt;iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE&lt;br /&gt;&lt;br /&gt;# Disallow NEW and INVALID incoming or forwarded packets from ppp0.&lt;br /&gt;iptables -A INPUT -i ppp0 -m state --state NEW,INVALID -j DROP&lt;br /&gt;iptables -A FORWARD -i ppp0 -m state --state NEW,INVALID -j DROP&lt;br /&gt;&lt;br /&gt;# Turn on IP forwarding&lt;br /&gt;echo 1 &gt; /proc/sys/net/ipv4/ip_forward"</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/06/linux-24-packet-filtering-howto-mixing.html' title='Linux 2.4 Packet Filtering HOWTO: Mixing NAT and Packet Filtering'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=114923544243195706' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114923544243195706'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114923544243195706'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-114911784690848509</id><published>2006-05-31T16:19:00.000-07:00</published><updated>2006-12-24T16:11:32.408-08:00</updated><title type='text'>Masquerade with a bit more security</title><content type='html'>&lt;a href="http://www.tldp.org/HOWTO/IP-Masquerade-HOWTO/stronger-firewall-examples.html"&gt;&lt;br /&gt;Stronger firewall rulesets to run after initial testing of Masquerade&lt;/a&gt;&lt;br /&gt;&lt;pre&gt;#!/bin/sh&lt;br /&gt;#&lt;br /&gt;# rc.firewall-iptables-stronger&lt;br /&gt;#&lt;br /&gt;FWVER=0.88s&lt;br /&gt;&lt;br /&gt;#          An example of a stronger IPTABLES firewall with IP Masquerade&lt;br /&gt;#          support for 2.4.x kernels.&lt;br /&gt;#&lt;br /&gt;# Log:&lt;br /&gt;#&lt;br /&gt;#   0.88s - Updated the commands for dynamically addresses machines and&lt;br /&gt;#           to point to an expanded FAQ section for more information&lt;br /&gt;#&lt;br /&gt;#   0.87s - Removed the unused drop-and-logit chain as it was only later&lt;br /&gt;#           being deleted anyway&lt;br /&gt;#   0.86s - Fixed a typo that had a preceeding ; instead of a #&lt;br /&gt;#   0.85s - renamed from rc.firewall-2.4-stronger to rc.firewall-iptables-&lt;br /&gt;#           stronger to reflect this script works for all IPTABLES enabled&lt;br /&gt;#           platforms including 2.6.x kernels&lt;br /&gt;#         - fixed an incorrect /24 netmask for the INTIP variable&lt;br /&gt;#         - removed the unneeded SED variable&lt;br /&gt;#   0.84s - Changed the defaults from 192.168.1.0 to 192.168.0.x to align&lt;br /&gt;#           with the rest of the IPMASQ howto&lt;br /&gt;#   0.83s - Added additional comments to make PORTFW configs more obvious&lt;br /&gt;#   0.82s - Added a special ICMP filter to work around a Netfilter security&lt;br /&gt;#           issue&lt;br /&gt;#         - renamed the drop-and-log-it rule to reject-and-log-it&lt;br /&gt;#   0.81s - Added an additional comment in the INPUT section for NOT&lt;br /&gt;#           allowing all traffic in, but only select traffic&lt;br /&gt;#   0.80s - Added a DISABLED ip_nat_irc kernel module section, changed the&lt;br /&gt;#           default of the ip_conntrack_irc to NOT load by default, and&lt;br /&gt;#           added additional kernel module comments&lt;br /&gt;#   0.79s - ruleset now uses modprobe instead of insmod&lt;br /&gt;#   0.78s - REJECT is not a legal policy yet; back to DROP&lt;br /&gt;#   0.77s - Changed the default block behavior to REJECT not DROP&lt;br /&gt;#   0.76s - Added a comment about the OPTIONAL WWW ruleset and a comment&lt;br /&gt;#           where to put optional PORTFW commands&lt;br /&gt;#   0.75s - Added clarification that PPPoE users need to use&lt;br /&gt;#           "ppp0" instead of "eth0" for their external interface&lt;br /&gt;#   0.74s - Changed the EXTIP command to work on NON-English distros&lt;br /&gt;#   0.73s - Added comments in the output section that DHCPd is optional&lt;br /&gt;#           and changed the default settings to disabled&lt;br /&gt;#   0.72s - Changed the filter from the INTNET to the INTIP to be&lt;br /&gt;#           stateful; moved the command VARs to the top and made the&lt;br /&gt;#           rest of the script to use them&lt;br /&gt;#   0.70s - Added a disabled examples for allowing internal DHCP&lt;br /&gt;#           and external WWW access to the server&lt;br /&gt;#   0.63s - Added support for the IRC module&lt;br /&gt;#   0.62s - Initial version based upon the basic 2.4.x rc.firewall&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;echo -e "\nLoading rc.firewall-iptables-STRONGER - version $FWVER..\n"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# The location of various iptables and other shell programs&lt;br /&gt;#&lt;br /&gt;#   If your Linux distribution came with a copy of iptables, most&lt;br /&gt;#   likely it is located in /sbin.  If you manually compiled&lt;br /&gt;#   iptables, the default location is in /usr/local/sbin&lt;br /&gt;#&lt;br /&gt;# ** Please use the "whereis iptables" command to figure out&lt;br /&gt;# ** where your copy is and change the path below to reflect&lt;br /&gt;# ** your setup&lt;br /&gt;#&lt;br /&gt;#IPTABLES=/sbin/iptables&lt;br /&gt;IPTABLES=/usr/local/sbin/iptables&lt;br /&gt;#&lt;br /&gt;LSMOD=/sbin/lsmod&lt;br /&gt;DEPMOD=/sbin/depmod&lt;br /&gt;MODPROBE=/sbin/modprobe&lt;br /&gt;GREP=/bin/grep&lt;br /&gt;AWK=/bin/awk&lt;br /&gt;IFCONFIG=/sbin/ifconfig&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#Setting the EXTERNAL and INTERNAL interfaces for the network&lt;br /&gt;#&lt;br /&gt;#  Each IP Masquerade network needs to have at least one&lt;br /&gt;#  external and one internal network.  The external network&lt;br /&gt;#  is where the natting will occur and the internal network&lt;br /&gt;#  should preferably be addressed with a RFC1918 private address&lt;br /&gt;#  scheme.&lt;br /&gt;#&lt;br /&gt;#  For this example, "eth0" is external and "eth1" is internal"&lt;br /&gt;#&lt;br /&gt;#  NOTE:  If this doesnt EXACTLY fit your configuration, you must&lt;br /&gt;#         change the EXTIF or INTIF variables above. For example:&lt;br /&gt;#&lt;br /&gt;#            If you are a PPPoE or analog modem user:&lt;br /&gt;#&lt;br /&gt;#               EXTIF="ppp0"&lt;br /&gt;#&lt;br /&gt;EXTIF="eth0"&lt;br /&gt;INTIF="eth1"&lt;br /&gt;echo "  External Interface:  $EXTIF"&lt;br /&gt;echo "  Internal Interface:  $INTIF"&lt;br /&gt;echo "  ---"&lt;br /&gt;&lt;br /&gt;# Specify your Static IP address here or let the script take care of it&lt;br /&gt;# for you.&lt;br /&gt;#&lt;br /&gt;#   If you prefer to use STATIC addresses in your firewalls, un-# out the&lt;br /&gt;#   static example below and # out the dynamic line.  If you don't care,&lt;br /&gt;#   just leave this section alone.&lt;br /&gt;#&lt;br /&gt;#   If you have a DYNAMIC IP address, the ruleset already takes care of&lt;br /&gt;#   this for you.  Please note that the different single and double quote&lt;br /&gt;#   characters and the script MATTER.&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;#   PPP and DHCP (Cablemodem and DSL ) users:&lt;br /&gt;#   -----------------------------------------&lt;br /&gt;#   PPP: If you get your TCP/IP address via DHCP, **you will need ** to&lt;br /&gt;#   enable the #   #ed out command below underneath the PPP section AND&lt;br /&gt;#   replace the word "eth0" with the name of your EXTERNAL Internet&lt;br /&gt;#   connection (ppp0, ippp0, etc) on the lines for "ppp-ip" and "extip".&lt;br /&gt;#&lt;br /&gt;#   DHCP and PPP users:  The remote DHCP or PPP server can and will change&lt;br /&gt;#   IP addresses on you over time.  To deal with this, users should configure&lt;br /&gt;#   their DHCP or PPP client to re-run the rc.firewall-* ruleset everytime&lt;br /&gt;#   the IP address is changed.  Please see the "masq-and-dyn-addr" FAQ entry&lt;br /&gt;#   in the IPMASQ howto for full details on how to do this.&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;# Determine the external IP automatically:&lt;br /&gt;# ----------------------------------------&lt;br /&gt;#&lt;br /&gt;#  The following line will determine your external IP address.  This&lt;br /&gt;#  line is somewhat complex and confusing but it will also work for&lt;br /&gt;#  all NON-English Linux distributions:&lt;br /&gt;#&lt;br /&gt;EXTIP="`$IFCONFIG $EXTIF | $AWK /$EXTIF/'{next}//{split($0,a,":");split(a[2],a," ");print a[1];exit}'`"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# For users who wish to use STATIC IP addresses:&lt;br /&gt;#&lt;br /&gt;#  # out the EXTIP line above and un-# out the EXTIP line below&lt;br /&gt;#&lt;br /&gt;#EXTIP="your.static.PPP.address"&lt;br /&gt;echo "  External IP: $EXTIP"&lt;br /&gt;echo "  ---"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Assign the internal TCP/IP network and IP address&lt;br /&gt;INTNET="192.168.0.0/24"&lt;br /&gt;INTIP="192.168.0.1/32"&lt;br /&gt;echo "  Internal Network: $INTNET"&lt;br /&gt;echo "  Internal IP:      $INTIP"&lt;br /&gt;echo "  ---"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Setting a few other local variables&lt;br /&gt;#&lt;br /&gt;UNIVERSE="0.0.0.0/0"&lt;br /&gt;&lt;br /&gt;#======================================================================&lt;br /&gt;#== No editing beyond this line is required for initial MASQ testing ==&lt;br /&gt;&lt;br /&gt;# Need to verify that all modules have all required dependencies&lt;br /&gt;#&lt;br /&gt;echo "  - Verifying that all kernel modules are ok"&lt;br /&gt;$DEPMOD -a&lt;br /&gt;&lt;br /&gt;echo -en "    Loading kernel modules: "&lt;br /&gt;&lt;br /&gt;# With the new IPTABLES code, the core MASQ functionality is now either&lt;br /&gt;# modular or compiled into the kernel.  This HOWTO shows ALL IPTABLES&lt;br /&gt;# options as MODULES.  If your kernel is compiled correctly, there is&lt;br /&gt;# NO need to load the kernel modules manually.&lt;br /&gt;#&lt;br /&gt;#  NOTE: The following items are listed ONLY for informational reasons.&lt;br /&gt;#        There is no reason to manual load these modules unless your&lt;br /&gt;#        kernel is either mis-configured or you intentionally disabled&lt;br /&gt;#        the kernel module autoloader.&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;# Upon the commands of starting up IP Masq on the server, the&lt;br /&gt;# following kernel modules will be automatically loaded:&lt;br /&gt;#&lt;br /&gt;# NOTE:  Only load the IP MASQ modules you need.  All current IP MASQ&lt;br /&gt;#        modules are shown below but are commented out from loading.&lt;br /&gt;# ===============================================================&lt;br /&gt;&lt;br /&gt;#Load the main body of the IPTABLES module - "ip_tables"&lt;br /&gt;#  - Loaded automatically when the "iptables" command is invoked&lt;br /&gt;#&lt;br /&gt;#  - Loaded manually to clean up kernel auto-loading timing issues&lt;br /&gt;#&lt;br /&gt;echo -en "ip_tables, "&lt;br /&gt;#&lt;br /&gt;#Verify the module isn't loaded.  If it is, skip it&lt;br /&gt;#&lt;br /&gt;if [ -z "` $LSMOD | $GREP ip_tables | $AWK {'print $1'} `" ]; then&lt;br /&gt;$MODPROBE ip_tables&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#Load the IPTABLES filtering module - "iptable_filter"&lt;br /&gt;#&lt;br /&gt;#  - Loaded automatically when filter policies are activated&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#Load the stateful connection tracking framework - "ip_conntrack"&lt;br /&gt;#&lt;br /&gt;# The conntrack  module in itself does nothing without other specific&lt;br /&gt;# conntrack modules being loaded afterwards such as the "ip_conntrack_ftp"&lt;br /&gt;# module&lt;br /&gt;#&lt;br /&gt;#  - This module is loaded automatically when MASQ functionality is&lt;br /&gt;#    enabled&lt;br /&gt;#&lt;br /&gt;#  - Loaded manually to clean up kernel auto-loading timing issues&lt;br /&gt;#&lt;br /&gt;echo -en "ip_conntrack, "&lt;br /&gt;#&lt;br /&gt;#Verify the module isn't loaded.  If it is, skip it&lt;br /&gt;#&lt;br /&gt;if [ -z "` $LSMOD | $GREP ip_conntrack | $AWK {'print $1'} `" ]; then&lt;br /&gt;$MODPROBE ip_conntrack&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#Load the FTP tracking mechanism for full FTP tracking&lt;br /&gt;#&lt;br /&gt;# Enabled by default -- insert a "#" on the next line to deactivate&lt;br /&gt;#&lt;br /&gt;echo -e "ip_conntrack_ftp, "&lt;br /&gt;#&lt;br /&gt;#Verify the module isn't loaded.  If it is, skip it&lt;br /&gt;#&lt;br /&gt;if [ -z "` $LSMOD | $GREP ip_conntrack_ftp | $AWK {'print $1'} `" ]; then&lt;br /&gt;$MODPROBE ip_conntrack_ftp&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#Load the IRC tracking mechanism for full IRC tracking&lt;br /&gt;#&lt;br /&gt;# Disabled by default -- insert a "#" on the next few lines to activate&lt;br /&gt;#&lt;br /&gt;# echo -en "                             ip_conntrack_irc, "&lt;br /&gt;#&lt;br /&gt;#Verify the module isn't loaded.  If it is, skip it&lt;br /&gt;#&lt;br /&gt;# if [ -z "` $LSMOD | $GREP ip_conntrack_irc | $AWK {'print $1'} `" ]; then&lt;br /&gt;#    $MODPROBE ip_conntrack_irc&lt;br /&gt;# fi&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#Load the general IPTABLES NAT code - "iptable_nat"&lt;br /&gt;#  - Loaded automatically when MASQ functionality is turned on&lt;br /&gt;#&lt;br /&gt;#  - Loaded manually to clean up kernel auto-loading timing issues&lt;br /&gt;#&lt;br /&gt;echo -en "iptable_nat, "&lt;br /&gt;#&lt;br /&gt;#Verify the module isn't loaded.  If it is, skip it&lt;br /&gt;#&lt;br /&gt;if [ -z "` $LSMOD | $GREP iptable_nat | $AWK {'print $1'} `" ]; then&lt;br /&gt;$MODPROBE iptable_nat&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#Loads the FTP NAT functionality into the core IPTABLES code&lt;br /&gt;# Required to support non-PASV FTP.&lt;br /&gt;#&lt;br /&gt;# Enabled by default -- insert a "#" on the next line to deactivate&lt;br /&gt;#&lt;br /&gt;echo -e "ip_nat_ftp"&lt;br /&gt;#&lt;br /&gt;#Verify the module isn't loaded.  If it is, skip it&lt;br /&gt;#&lt;br /&gt;if [ -z "` $LSMOD | $GREP ip_nat_ftp | $AWK {'print $1'} `" ]; then&lt;br /&gt;$MODPROBE ip_nat_ftp&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#Loads the IRC NAT functionality (for DCC) into the core IPTABLES code&lt;br /&gt;#&lt;br /&gt;# DISABLED by default -- delete the "#" on the next few lines to activate&lt;br /&gt;#&lt;br /&gt;# echo -e "ip_nat_irc"&lt;br /&gt;#&lt;br /&gt;#Verify the module isn't loaded.  If it is, skip it&lt;br /&gt;#&lt;br /&gt;# if [ -z "` $LSMOD | $GREP ip_nat_irc | $AWK {'print $1'} `" ]; then&lt;br /&gt;#    $MODPROBE ip_nat_irc&lt;br /&gt;# fi&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;echo "  ---"&lt;br /&gt;&lt;br /&gt;# Just to be complete, here is a partial list of some of the other&lt;br /&gt;# IPTABLES kernel modules and their function.  Please note that most&lt;br /&gt;# of these modules (the ipt ones) are automatically loaded by the&lt;br /&gt;# master kernel module for proper operation and don't need to be&lt;br /&gt;# manually loaded.&lt;br /&gt;# --------------------------------------------------------------------&lt;br /&gt;#&lt;br /&gt;#    ip_nat_snmp_basic - this module allows for proper NATing of some&lt;br /&gt;#                        SNMP traffic&lt;br /&gt;#&lt;br /&gt;#    iptable_mangle    - this target allows for packets to be&lt;br /&gt;#                        manipulated for things like the TCPMSS&lt;br /&gt;#                        option, etc.&lt;br /&gt;#&lt;br /&gt;# --&lt;br /&gt;#&lt;br /&gt;#    ipt_mark       - this target marks a given packet for future action.&lt;br /&gt;#                     This automatically loads the ipt_MARK module&lt;br /&gt;#&lt;br /&gt;#    ipt_tcpmss     - this target allows to manipulate the TCP MSS&lt;br /&gt;#                     option for braindead remote firewalls.&lt;br /&gt;#                     This automatically loads the ipt_TCPMSS module&lt;br /&gt;#&lt;br /&gt;#    ipt_limit      - this target allows for packets to be limited to&lt;br /&gt;#                     to many hits per sec/min/hr&lt;br /&gt;#&lt;br /&gt;#    ipt_multiport  - this match allows for targets within a range&lt;br /&gt;#                     of port numbers vs. listing each port individually&lt;br /&gt;#&lt;br /&gt;#    ipt_state      - this match allows to catch packets with various&lt;br /&gt;#                     IP and TCP flags set/unset&lt;br /&gt;#&lt;br /&gt;#    ipt_unclean    - this match allows to catch packets that have invalid&lt;br /&gt;#                     IP/TCP flags set&lt;br /&gt;#&lt;br /&gt;#    iptable_filter - this module allows for packets to be DROPped,&lt;br /&gt;#                     REJECTed, or LOGged.  This module automatically&lt;br /&gt;#                     loads the following modules:&lt;br /&gt;#&lt;br /&gt;#                     ipt_LOG - this target allows for packets to be&lt;br /&gt;#                               logged&lt;br /&gt;#&lt;br /&gt;#                     ipt_REJECT - this target DROPs the packet and returns&lt;br /&gt;#                                  a configurable ICMP packet back to the&lt;br /&gt;#                                  sender.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#CRITICAL:  Enable IP forwarding since it is disabled by default since&lt;br /&gt;#&lt;br /&gt;#           Redhat Users:  you may try changing the options in&lt;br /&gt;#                          /etc/sysconfig/network from:&lt;br /&gt;#&lt;br /&gt;#                       FORWARD_IPV4=false&lt;br /&gt;#                             to&lt;br /&gt;#                       FORWARD_IPV4=true&lt;br /&gt;#&lt;br /&gt;echo "  Enabling forwarding.."&lt;br /&gt;echo "1" &gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Dynamic IP users:&lt;br /&gt;#&lt;br /&gt;#   If you get your IP address dynamically from SLIP, PPP, or DHCP,&lt;br /&gt;#   enable the following option.  This enables dynamic-address hacking&lt;br /&gt;#   which makes the life with Diald and similar programs much easier.&lt;br /&gt;#&lt;br /&gt;echo "  Enabling DynamicAddr.."&lt;br /&gt;echo "1" &gt; /proc/sys/net/ipv4/ip_dynaddr&lt;br /&gt;&lt;br /&gt;echo "  ---"&lt;br /&gt;&lt;br /&gt;#############################################################################&lt;br /&gt;#&lt;br /&gt;# Enable Stronger IP forwarding and Masquerading&lt;br /&gt;#&lt;br /&gt;#  NOTE:  In IPTABLES speak, IP Masquerading is a form of SourceNAT or SNAT.&lt;br /&gt;#&lt;br /&gt;#  NOTE #2:  The following is an example for an internal LAN address in the&lt;br /&gt;#            192.168.0.x network with a 255.255.255.0 or a "24" bit subnet&lt;br /&gt;#            mask connecting to the Internet on external interface "eth0".&lt;br /&gt;#            This example will MASQ internal traffic out to the Internet&lt;br /&gt;#            but not allow non-initiated traffic into your internal network.&lt;br /&gt;#&lt;br /&gt;#        &lt;br /&gt;#         ** Please change the above network numbers, subnet mask, and your&lt;br /&gt;#     &lt;br /&gt;&lt;br /&gt;#Clearing any previous configuration&lt;br /&gt;#&lt;br /&gt;#  Unless specified, the defaults for INPUT, OUTPUT, and FORWARD to DROP&lt;br /&gt;#&lt;br /&gt;#    You CANNOT change this to REJECT as it isn't a vaild policy setting.&lt;br /&gt;#    If you want REJECT, you must explictly REJECT at the end of a giving&lt;br /&gt;#    INPUT, OUTPUT, or FORWARD chain&lt;br /&gt;#&lt;br /&gt;echo "  Clearing any existing rules and setting default policy to DROP.."&lt;br /&gt;$IPTABLES -P INPUT DROP&lt;br /&gt;$IPTABLES -F INPUT&lt;br /&gt;$IPTABLES -P OUTPUT DROP&lt;br /&gt;$IPTABLES -F OUTPUT&lt;br /&gt;$IPTABLES -P FORWARD DROP&lt;br /&gt;$IPTABLES -F FORWARD&lt;br /&gt;$IPTABLES -F -t nat&lt;br /&gt;&lt;br /&gt;#Not needed and it will only load the unneeded kernel module&lt;br /&gt;#&lt;br /&gt;#$IPTABLES -F -t mangle&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Delete all User-specified chains&lt;br /&gt;$IPTABLES -X&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Reset all IPTABLES counters&lt;br /&gt;$IPTABLES -Z&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#Configuring specific CHAINS for later use in the ruleset&lt;br /&gt;#&lt;br /&gt;#  NOTE:  Some users prefer to have their firewall silently&lt;br /&gt;#         "DROP" packets while others prefer to use "REJECT"&lt;br /&gt;#         to send ICMP error messages back to the remote&lt;br /&gt;#         machine.  The default is "REJECT" but feel free to&lt;br /&gt;#         change this below.&lt;br /&gt;#&lt;br /&gt;# NOTE: Without the --log-level set to "info", every single&lt;br /&gt;#       firewall hit will goto ALL vtys.  This is a very big&lt;br /&gt;#       pain.&lt;br /&gt;#&lt;br /&gt;echo "  Creating a DROP chain.."&lt;br /&gt;$IPTABLES -N reject-and-log-it&lt;br /&gt;$IPTABLES -A reject-and-log-it -j LOG --log-level info&lt;br /&gt;$IPTABLES -A reject-and-log-it -j REJECT&lt;br /&gt;&lt;br /&gt;echo -e "\n   - Loading INPUT rulesets"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;# INPUT: Incoming traffic from various interfaces.  All rulesets are&lt;br /&gt;#        already flushed and set to a default policy of DROP.&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;# loopback interfaces are valid.&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A INPUT -i lo -s $UNIVERSE -d $UNIVERSE -j ACCEPT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# local interface, local machines, going anywhere is valid&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A INPUT -i $INTIF -s $INTNET -d $UNIVERSE -j ACCEPT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# remote interface, claiming to be local machines, IP spoofing, get lost&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A INPUT -i $EXTIF -s $INTNET -d $UNIVERSE -j reject-and-log-it&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# external interface, from any source, for ICMP traffic is valid&lt;br /&gt;#&lt;br /&gt;#  If you would like your machine to "ping" from the Internet,&lt;br /&gt;#  enable this next line&lt;br /&gt;#&lt;br /&gt;#$IPTABLES -A INPUT -i $EXTIF -p ICMP -s $UNIVERSE -d $EXTIP -j ACCEPT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# remote interface, any source, going to the MASQ servers IP address is valid&lt;br /&gt;#&lt;br /&gt;#  ENABLE this line if you want ALL Internet traffic to connect to your&lt;br /&gt;#  the various servers running on the MASQ server.  This includes&lt;br /&gt;#  web servers, ssh servers, dns servers, etc.&lt;br /&gt;#&lt;br /&gt;#  I DON'T recommend you enable this rule.  Instead, only enable specific&lt;br /&gt;#  access to select server ports under the "OPTIONAL INPUT Section".&lt;br /&gt;#  An example of enabling HTTP (WWW) has been given below:&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;#$IPTABLES -A INPUT -i $EXTIF -s $UNIVERSE -d $EXTIP -j ACCEPT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Allow any related traffic coming back to the MASQ server in.&lt;br /&gt;#&lt;br /&gt;#  STATEFULLY TRACKED&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A INPUT -i $EXTIF -s $UNIVERSE -d $EXTIP -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# ----- Begin OPTIONAL INPUT Section -----&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;# DHCPd - Enable the following lines if you run an INTERNAL DHCPd server&lt;br /&gt;#&lt;br /&gt;#$IPTABLES -A INPUT -i $INTIF -p tcp --sport 68 --dport 67 -j ACCEPT&lt;br /&gt;#$IPTABLES -A INPUT -i $INTIF -p udp --sport 68 --dport 67 -j ACCEPT&lt;br /&gt;&lt;br /&gt;# HTTPd - Enable the following lines if you run an EXTERNAL WWW server&lt;br /&gt;#&lt;br /&gt;#    NOTE:  This is NOT needed for simply enabling PORTFW.  This is ONLY&lt;br /&gt;#           for users that plan on running Apache on the MASQ server itself&lt;br /&gt;#&lt;br /&gt;#echo -e "      - Allowing EXTERNAL access to the WWW server"&lt;br /&gt;#$IPTABLES -A INPUT -i $EXTIF -m state --state NEW,ESTABLISHED,RELATED # -p tcp -s $UNIVERSE -d $EXTIP --dport 80 -j ACCEPT&lt;br /&gt;&lt;br /&gt;#&lt;br /&gt;# ----- End OPTIONAL INPUT Section -----&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Catch all rule, all other incoming is denied and logged.&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A INPUT -s $UNIVERSE -d $UNIVERSE -j reject-and-log-it&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# ---------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;echo -e "   - Loading OUTPUT rulesets"&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;# OUTPUT: Outgoing traffic from various interfaces.  All rulesets are&lt;br /&gt;#         already flushed and set to a default policy of DROP.&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;# Workaround bug in netfilter&lt;br /&gt;# See http://www.netfilter.org/security/2002-04-02-icmp-dnat.html&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A OUTPUT -m state -p icmp --state INVALID -j DROP&lt;br /&gt;&lt;br /&gt;# loopback interface is valid.&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A OUTPUT -o lo -s $UNIVERSE -d $UNIVERSE -j ACCEPT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# local interfaces, any source going to local net is valid&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A OUTPUT -o $INTIF -s $EXTIP -d $INTNET -j ACCEPT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# local interface, MASQ server source going to the local net is valid&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A OUTPUT -o $INTIF -s $INTIP -d $INTNET -j ACCEPT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# outgoing to local net on remote interface, stuffed routing, deny&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A OUTPUT -o $EXTIF -s $UNIVERSE -d $INTNET -j reject-and-log-it&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# anything else outgoing on remote interface is valid&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A OUTPUT -o $EXTIF -s $EXTIP -d $UNIVERSE -j ACCEPT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# ----- Begin OPTIONAL OUTPUT Section -----&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;# DHCPd - Enable the following lines if you run an INTERNAL DHCPd server&lt;br /&gt;#         - Remove BOTH #s all the #s if you need this functionality.&lt;br /&gt;#&lt;br /&gt;#$IPTABLES -A OUTPUT -o $INTIF -p tcp -s $INTIP --sport 67 # -d 255.255.255.255 --dport 68 -j ACCEPT&lt;br /&gt;#$IPTABLES -A OUTPUT -o $INTIF -p udp -s $INTIP --sport 67 # -d 255.255.255.255 --dport 68 -j ACCEPT&lt;br /&gt;&lt;br /&gt;#&lt;br /&gt;# ----- End OPTIONAL OUTPUT Section -----&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Catch all rule, all other outgoing is denied and logged.&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A OUTPUT -s $UNIVERSE -d $UNIVERSE -j reject-and-log-it&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;echo -e "   - Loading FORWARD rulesets"&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;# FORWARD: Enable Forwarding and thus IPMASQ&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;# ----- Begin OPTIONAL FORWARD Section -----&lt;br /&gt;#&lt;br /&gt;#  Put PORTFW commands here&lt;br /&gt;#&lt;br /&gt;# ----- End OPTIONAL FORWARD Section -----&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;echo "     - FWD: Allow all connections OUT and only existing/related IN"&lt;br /&gt;$IPTABLES -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;$IPTABLES -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT&lt;br /&gt;&lt;br /&gt;# Catch all rule, all other forwarding is denied and logged.&lt;br /&gt;#&lt;br /&gt;$IPTABLES -A FORWARD -j reject-and-log-it&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;echo "     - NAT: Enabling SNAT (MASQUERADE) functionality on $EXTIF"&lt;br /&gt;#&lt;br /&gt;#More liberal form&lt;br /&gt;#$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE&lt;br /&gt;#&lt;br /&gt;#Stricter form&lt;br /&gt;$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j SNAT --to $EXTIP&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;echo -e "\nrc.firewall-iptables-stronger $FWVER done.\n"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;##3 Done&lt;br /&gt;######----------------------------------------------------------------------------&lt;br /&gt;[root@kucc mast]# vi strong_mast.sh&lt;br /&gt;[root@kucc mast]# iptables -L&lt;br /&gt;Chain INPUT (policy ACCEPT)&lt;br /&gt;target     prot opt source               destination&lt;br /&gt;&lt;br /&gt;Chain FORWARD (policy DROP)&lt;br /&gt;target     prot opt source               destination&lt;br /&gt;&lt;br /&gt;Chain OUTPUT (policy ACCEPT)&lt;br /&gt;target     prot opt source               destination&lt;br /&gt;[root@kucc mast]# sh strong_mast.sh&lt;br /&gt;&lt;br /&gt;Loading rc.firewall-iptables-STRONGER - version 0.88s..&lt;br /&gt;&lt;br /&gt; External Interface:  eth0&lt;br /&gt; Internal Interface:  eth1&lt;br /&gt; ---&lt;br /&gt; External IP: 202.52.242.55&lt;br /&gt; ---&lt;br /&gt; Internal Network: 192.168.0.0/24&lt;br /&gt; Internal IP:      192.168.0.1/32&lt;br /&gt; ---&lt;br /&gt; - Verifying that all kernel modules are ok&lt;br /&gt;   Loading kernel modules: ip_tables, ip_conntrack, ip_conntrack_ftp,&lt;br /&gt;iptable_nat, ip_nat_ftp&lt;br /&gt; ---&lt;br /&gt; Enabling forwarding..&lt;br /&gt; Enabling DynamicAddr..&lt;br /&gt; ---&lt;br /&gt; Clearing any existing rules and setting default policy to DROP..&lt;br /&gt; Creating a DROP chain..&lt;br /&gt;&lt;br /&gt;  - Loading INPUT rulesets&lt;br /&gt;  - Loading OUTPUT rulesets&lt;br /&gt;  - Loading FORWARD rulesets&lt;br /&gt;    - FWD: Allow all connections OUT and only existing/related IN&lt;br /&gt;    - NAT: Enabling SNAT (MASQUERADE) functionality on eth0&lt;br /&gt;&lt;br /&gt;rc.firewall-iptables-stronger 0.88s done.&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/05/masquerade-with-bit-more-security.html' title='Masquerade with a bit more security'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=114911784690848509' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114911784690848509'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114911784690848509'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-114909944478764025</id><published>2006-05-31T11:15:00.000-07:00</published><updated>2006-12-24T16:10:59.188-08:00</updated><title type='text'>Ip masquerading script for iptables</title><content type='html'>&lt;pre&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;#&lt;br /&gt;# rc.firewall-iptables&lt;br /&gt;FWVER=0.76&lt;br /&gt;#&lt;br /&gt;# Initial SIMPLE IP Masquerade test for 2.6 / 2.4 kernels&lt;br /&gt;# using IPTABLES.&lt;br /&gt;#&lt;br /&gt;# Once IP Masquerading has been tested, with this simple&lt;br /&gt;# ruleset, it is highly recommended to use a stronger&lt;br /&gt;# IPTABLES ruleset either given later in this HOWTO or&lt;br /&gt;# from another reputable resource.&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;# Log:&lt;br /&gt;# 0.76 - Added comments on why the default policy is ACCEPT&lt;br /&gt;# 0.75 - Added more kernel modules to the comments section&lt;br /&gt;# 0.74 - the ruleset now uses modprobe vs. insmod&lt;br /&gt;# 0.73 - REJECT is not a legal policy yet; back to DROP&lt;br /&gt;# 0.72 - Changed the default block behavior to REJECT not DROP&lt;br /&gt;# 0.71 - Added clarification that PPPoE users need to use&lt;br /&gt;# "ppp0" instead of "eth0" for their external interface&lt;br /&gt;# 0.70 - Added commented option for IRC nat module&lt;br /&gt;# - Added additional use of environment variables&lt;br /&gt;# - Added additional formatting&lt;br /&gt;# 0.63 - Added support for the IRC IPTABLES module&lt;br /&gt;# 0.62 - Fixed a typo on the MASQ enable line that used eth0&lt;br /&gt;# instead of $EXTIF&lt;br /&gt;# 0.61 - Changed the firewall to use variables for the internal&lt;br /&gt;# and external interfaces.&lt;br /&gt;# 0.60 - 0.50 had a mistake where the ruleset had a rule to DROP&lt;br /&gt;# all forwarded packets but it didn't have a rule to ACCEPT&lt;br /&gt;# any packets to be forwarded either&lt;br /&gt;# - Load the ip_nat_ftp and ip_conntrack_ftp modules by default&lt;br /&gt;# 0.50 - Initial draft&lt;br /&gt;#&lt;br /&gt;echo -e "\n\nLoading simple rc.firewall-iptables version $FWVER..\n"&lt;br /&gt;&lt;br /&gt;# The location of the iptables and kernel module programs&lt;br /&gt;#&lt;br /&gt;# If your Linux distribution came with a copy of iptables,&lt;br /&gt;# most likely all the programs will be located in /sbin. If&lt;br /&gt;# you manually compiled iptables, the default location will&lt;br /&gt;# be in /usr/local/sbin&lt;br /&gt;#&lt;br /&gt;# ** Please use the "whereis iptables" command to figure out&lt;br /&gt;# ** where your copy is and change the path below to reflect&lt;br /&gt;# ** your setup&lt;br /&gt;#&lt;br /&gt;#IPTABLES=/sbin/iptables&lt;br /&gt;IPTABLES=/sbin/iptables&lt;br /&gt;DEPMOD=/sbin/depmod&lt;br /&gt;MODPROBE=/sbin/modprobe&lt;br /&gt;&lt;br /&gt;#Setting the EXTERNAL and INTERNAL interfaces for the network&lt;br /&gt;#&lt;br /&gt;# Each IP Masquerade network needs to have at least one&lt;br /&gt;# external and one internal network. The external network&lt;br /&gt;# is where the natting will occur and the internal network&lt;br /&gt;# should preferably be addressed with a RFC1918 private address&lt;br /&gt;# scheme.&lt;br /&gt;#&lt;br /&gt;# For this example, "eth0" is external and "eth1" is internal"&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;# NOTE: If this doesnt EXACTLY fit your configuration, you must&lt;br /&gt;# change the EXTIF or INTIF variables above. For example:&lt;br /&gt;#&lt;br /&gt;# If you are a PPPoE or analog modem user:&lt;br /&gt;#&lt;br /&gt;# EXTIF="ppp0"&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;EXTIF="eth0"&lt;br /&gt;INTIF="eth1"&lt;br /&gt;echo " External Interface: $EXTIF"&lt;br /&gt;echo " Internal Interface: $INTIF"&lt;br /&gt;&lt;br /&gt;#======================================================================&lt;br /&gt;#== No editing beyond this line is required for initial MASQ testing ==&lt;br /&gt;&lt;br /&gt;echo -en " loading modules: "&lt;br /&gt;# Need to verify that all modules have all required dependencies&lt;br /&gt;#&lt;br /&gt;echo " - Verifying that all kernel modules are ok"&lt;br /&gt;$DEPMOD -a&lt;br /&gt;# With the new IPTABLES code, the core MASQ functionality is now either&lt;br /&gt;# modular or compiled into the kernel. This HOWTO shows ALL IPTABLES&lt;br /&gt;# options as MODULES. If your kernel is compiled correctly, there is&lt;br /&gt;# NO need to load the kernel modules manually.&lt;br /&gt;#&lt;br /&gt;# NOTE: The following items are listed ONLY for informational reasons.&lt;br /&gt;# There is no reason to manual load these modules unless your&lt;br /&gt;# kernel is either mis-configured or you intentionally disabled&lt;br /&gt;# the kernel module autoloader.&lt;br /&gt;#&lt;br /&gt;# Upon the commands of starting up IP Masq on the server, the&lt;br /&gt;# following kernel modules will be automatically loaded:&lt;br /&gt;#&lt;br /&gt;# NOTE: Only load the IP MASQ modules you need. All current IP MASQ&lt;br /&gt;# modules are shown below but are commented out from loading.&lt;br /&gt;# ===============================================================&lt;br /&gt;echo "----------------------------------------------------------------------"&lt;br /&gt;#Load the main body of the IPTABLES module - "iptable"&lt;br /&gt;# - Loaded automatically when the "iptables" command is invoked&lt;br /&gt;#&lt;br /&gt;# - Loaded manually to clean up kernel auto-loading timing issues&lt;br /&gt;#&lt;br /&gt;echo -en "ip_tables, "&lt;br /&gt;$MODPROBE ip_tables&lt;br /&gt;&lt;br /&gt;#Load the IPTABLES filtering module - "iptable_filter"&lt;br /&gt;# - Loaded automatically when filter policies are activated&lt;br /&gt;&lt;br /&gt;#Load the stateful connection tracking framework - "ip_conntrack"&lt;br /&gt;#&lt;br /&gt;# The conntrack module in itself does nothing without other specific&lt;br /&gt;# conntrack modules being loaded afterwards such as the "ip_conntrack_ftp"&lt;br /&gt;# module&lt;br /&gt;#&lt;br /&gt;# - This module is loaded automatically when MASQ functionality is&lt;br /&gt;# enabled&lt;br /&gt;#&lt;br /&gt;# - Loaded manually to clean up kernel auto-loading timing issues&lt;br /&gt;#&lt;br /&gt;echo -en "ip_conntrack, "&lt;br /&gt;$MODPROBE ip_conntrack&lt;br /&gt;&lt;br /&gt;#Load the FTP tracking mechanism for full FTP tracking&lt;br /&gt;#&lt;br /&gt;# Enabled by default -- insert a "#" on the next line to deactivate&lt;br /&gt;#&lt;br /&gt;echo -en "ip_conntrack_ftp, "&lt;br /&gt;$MODPROBE ip_conntrack_ftp&lt;br /&gt;&lt;br /&gt;#Load the IRC tracking mechanism for full IRC tracking&lt;br /&gt;#&lt;br /&gt;# Enabled by default -- insert a "#" on the next line to deactivate&lt;br /&gt;#&lt;br /&gt;echo -en "ip_conntrack_irc, "&lt;br /&gt;$MODPROBE ip_conntrack_irc&lt;br /&gt;&lt;br /&gt;#Load the general IPTABLES NAT code - "iptable_nat"&lt;br /&gt;# - Loaded automatically when MASQ functionality is turned on&lt;br /&gt;#&lt;br /&gt;# - Loaded manually to clean up kernel auto-loading timing issues&lt;br /&gt;#&lt;br /&gt;echo -en "iptable_nat, "&lt;br /&gt;$MODPROBE iptable_nat&lt;br /&gt;&lt;br /&gt;#Loads the FTP NAT functionality into the core IPTABLES code&lt;br /&gt;# Required to support non-PASV FTP.&lt;br /&gt;#&lt;br /&gt;# Enabled by default -- insert a "#" on the next line to deactivate&lt;br /&gt;#&lt;br /&gt;echo -en "ip_nat_ftp, "&lt;br /&gt;$MODPROBE ip_nat_ftp&lt;br /&gt;&lt;br /&gt;#Loads the IRC NAT functionality into the core IPTABLES code&lt;br /&gt;# Required to support NAT of IRC DCC requests&lt;br /&gt;#&lt;br /&gt;# Disabled by default -- remove the "#" on the next line to activate&lt;br /&gt;#&lt;br /&gt;#echo -e "ip_nat_irc"&lt;br /&gt;#$MODPROBE ip_nat_irc&lt;br /&gt;echo "----------------------------------------------------------------------"&lt;br /&gt;# Just to be complete, here is a partial list of some of the other&lt;br /&gt;# IPTABLES kernel modules and their function. Please note that most&lt;br /&gt;# of these modules (the ipt ones) are automatically loaded by the&lt;br /&gt;# master kernel module for proper operation and don't need to be&lt;br /&gt;# manually loaded.&lt;br /&gt;# --------------------------------------------------------------------&lt;br /&gt;#&lt;br /&gt;# ip_nat_snmp_basic - this module allows for proper NATing of some&lt;br /&gt;# SNMP traffic&lt;br /&gt;#&lt;br /&gt;# iptable_mangle - this target allows for packets to be&lt;br /&gt;# manipulated for things like the TCPMSS&lt;br /&gt;# option, etc.&lt;br /&gt;#&lt;br /&gt;# --&lt;br /&gt;#&lt;br /&gt;# ipt_mark - this target marks a given packet for future action.&lt;br /&gt;# This automatically loads the ipt_MARK module&lt;br /&gt;#&lt;br /&gt;# ipt_tcpmss - this target allows to manipulate the TCP MSS&lt;br /&gt;# option for braindead remote firewalls.&lt;br /&gt;# This automatically loads the ipt_TCPMSS module&lt;br /&gt;#&lt;br /&gt;# ipt_limit - this target allows for packets to be limited to&lt;br /&gt;# to many hits per sec/min/hr&lt;br /&gt;#&lt;br /&gt;# ipt_multiport - this match allows for targets within a range&lt;br /&gt;# of port numbers vs. listing each port individually&lt;br /&gt;#&lt;br /&gt;# ipt_state - this match allows to catch packets with various&lt;br /&gt;# IP and TCP flags set/unset&lt;br /&gt;#&lt;br /&gt;# ipt_unclean - this match allows to catch packets that have invalid&lt;br /&gt;# IP/TCP flags set&lt;br /&gt;#&lt;br /&gt;# iptable_filter - this module allows for packets to be DROPped,&lt;br /&gt;# REJECTed, or LOGged. This module automatically&lt;br /&gt;# loads the following modules:&lt;br /&gt;#&lt;br /&gt;# ipt_LOG - this target allows for packets to be&lt;br /&gt;# logged&lt;br /&gt;#&lt;br /&gt;# ipt_REJECT - this target DROPs the packet and returns&lt;br /&gt;# a configurable ICMP packet back to the&lt;br /&gt;# sender.&lt;br /&gt;#&lt;br /&gt;echo -e " Done loading modules.\n"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#CRITICAL: Enable IP forwarding since it is disabled by default since&lt;br /&gt;#&lt;br /&gt;# Redhat Users: you may try changing the options in&lt;br /&gt;# /etc/sysconfig/network from:&lt;br /&gt;#&lt;br /&gt;# FORWARD_IPV4=false&lt;br /&gt;# to&lt;br /&gt;# FORWARD_IPV4=true&lt;br /&gt;#&lt;br /&gt;echo " Enabling forwarding.."&lt;br /&gt;echo "1" &gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;&lt;br /&gt;# Dynamic IP users:&lt;br /&gt;#&lt;br /&gt;# If you get your IP address dynamically from SLIP, PPP, or DHCP,&lt;br /&gt;# enable this following option. This enables dynamic-address hacking&lt;br /&gt;# which makes the life with Diald and similar programs much easier.&lt;br /&gt;#&lt;br /&gt;echo " Enabling DynamicAddr.."&lt;br /&gt;echo "1" &gt; /proc/sys/net/ipv4/ip_dynaddr&lt;br /&gt;&lt;br /&gt;# Enable simple IP forwarding and Masquerading&lt;br /&gt;#&lt;br /&gt;# NOTE: In IPTABLES speak, IP Masquerading is a form of SourceNAT or SNAT.&lt;br /&gt;#&lt;br /&gt;# NOTE #2: The following is an example for an internal LAN address in the&lt;br /&gt;# 192.168.0.x network with a 255.255.255.0 or a "24" bit subnet mask&lt;br /&gt;# connecting to the Internet on external interface "eth0". This&lt;br /&gt;# example will MASQ internal traffic out to the Internet but not&lt;br /&gt;# allow non-initiated traffic into your internal network.&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;# ** Please change the above network numbers, subnet mask, and your&lt;br /&gt;# *** Internet connection interface name to match your setup&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;#Clearing any previous configuration&lt;br /&gt;#&lt;br /&gt;# Unless specified, the defaults for INPUT and OUTPUT is ACCEPT&lt;br /&gt;# The default for FORWARD is DROP (REJECT is not a valid policy)&lt;br /&gt;#&lt;br /&gt;# Isn't ACCEPT insecure? To some degree, YES, but this is our testing&lt;br /&gt;# phase. Once we know that IPMASQ is working well, I recommend you run&lt;br /&gt;# the rc.firewall-*-stronger rulesets which set the defaults to DROP but&lt;br /&gt;# also include the critical additional rulesets to still let you connect to&lt;br /&gt;# the IPMASQ server, etc.&lt;br /&gt;#&lt;br /&gt;echo " Clearing any existing rules and setting default policy.."&lt;br /&gt;$IPTABLES -P INPUT ACCEPT&lt;br /&gt;$IPTABLES -F INPUT&lt;br /&gt;$IPTABLES -P OUTPUT ACCEPT&lt;br /&gt;$IPTABLES -F OUTPUT&lt;br /&gt;$IPTABLES -P FORWARD DROP&lt;br /&gt;$IPTABLES -F FORWARD&lt;br /&gt;$IPTABLES -t nat -F&lt;br /&gt;echo " FWD: Allow all connections OUT and only existing and related ones IN"&lt;br /&gt;$IPTABLES -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;$IPTABLES -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT&lt;br /&gt;$IPTABLES -A FORWARD -j LOG&lt;br /&gt;echo " Enabling SNAT (MASQUERADE) functionality on $EXTIF"&lt;br /&gt;$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE&lt;br /&gt;echo -e "\nrc.firewall-iptables v$FWVER done.\n"&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/05/ip-masquerading-script-for-iptables.html' title='Ip masquerading script for iptables'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=114909944478764025' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114909944478764025'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114909944478764025'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-114909245874426748</id><published>2006-05-31T09:20:00.000-07:00</published><updated>2006-12-24T16:10:18.241-08:00</updated><title type='text'>Linux Tutorial - Linux Network Administration</title><content type='html'>&lt;a href="http://yolinux.com/TUTORIALS/LinuxTutorialNetworking.html#SUBNETS"&gt;Linux Tutorial - Linux Network Administration&lt;/a&gt;: "ICMP: ICMP is the network protocol used by the ping and traceroute commands. ICMP redirect packets are sent from the router to the host to inform the host of a better route. To enable ICMP redirect, add the following line to /etc/sysctl.conf : net.ipv4.conf.all.accept_redirects = 1 Add the following to the file: /etc/rc.d/rc.local for f in /proc/sys/net/ipv4/conf/*/accept_redirects do echo 1 &gt; $f done"</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/05/linux-tutorial-linux-network.html' title='Linux Tutorial - Linux Network Administration'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=114909245874426748' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114909245874426748'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114909245874426748'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-114901255664267807</id><published>2006-05-30T11:09:00.000-07:00</published><updated>2006-12-24T16:09:58.433-08:00</updated><title type='text'>SQUID Frequently Asked Questions: Interception Caching/Proxying</title><content type='html'>&lt;div&gt;&lt;a href="http://www.squid-cache.org/Doc/FAQ/FAQ-17.html"&gt;SQUID Frequently  Asked Questions: Interception Caching/Proxying&lt;/a&gt;: "http_port 8080&lt;br /&gt;httpd_accel_host virtual&lt;br /&gt;httpd_accel_port 80&lt;br /&gt;httpd_accel_with_proxy  on&lt;br /&gt;httpd_accel_uses_host_header on"&lt;br /&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8080&lt;br /&gt;iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 443 -j REDIRECT --to-port&lt;br /&gt;8080&lt;br /&gt;iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 563 -j REDIRECT --to-port&lt;br /&gt;8080&lt;br /&gt;#httpd_accel_host virtual&lt;br /&gt;#httpd_accel_port 80&lt;br /&gt;#httpd_accel_with_proxy on&lt;br /&gt;#httpd_accel_uses_host_header on&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://ww.rajesh.com.np/2006/05/squid-frequently-asked-questions.html' title='SQUID Frequently Asked Questions: Interception Caching/Proxying'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28683368&amp;postID=114901255664267807' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://ww.rajesh.com.np/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114901255664267807'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28683368/posts/default/114901255664267807'/><author><name>Rajesh</name></author></entry><entry><id>tag:blogger.com,1999:blog-28683368.post-114900241097128522</id><published>2006-05-30T08:15:00.000-07:00</published><updated>2006-12-24T16:09:21.337-08:00</updated><title type='text'>Using Linux iptables or ipchains to set up an internet gateway / firewall / routerfor home or office.</title><content type='html'>&lt;a href="http://yolinux.com/TUTORIALS/LinuxTutorialIptablesNetworkGateway.html"&gt;Using Linux iptables or ipchains to set up an internet gateway / firewall / routerfor home or office.&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;h3&gt;iptables&lt;br /&gt;&lt;table cellspacing="1" cellpadding="4" width="100%" bgcolor="#000000" border="0"&gt;&lt;br /&gt;&lt;tbody&gt;&lt;tr bgcolor="#c0c0c0"&gt;&lt;td&gt;&lt;br /&gt;&lt;pre&gt;   # Delete and flush. Default table is "filter". Others like "nat" must be explicitly stated.&lt;br /&gt;   iptables --flush            &lt;b&gt;&lt;i&gt;- Flush all the rules in filter and nat tables&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;   iptables --table nat --flush&lt;br /&gt;   iptables --delete-chain     &lt;b&gt;&lt;i&gt;- Delete all chains that are not in default filter and nat table&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;   iptables --table nat --delete-chain&lt;br /&gt;&lt;br /&gt;   # Set up IP FORWARDing and Masquerading&lt;br /&gt;   iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE&lt;br /&gt;   iptables --append FORWARD --in-interface eth1 -j ACCEPT&lt;br /&gt;&lt;br /&gt;   echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward             &lt;b&gt;&lt;i&gt;