<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>- [ t o i c . o r g ] -</title>
	
	<link>http://toic.org</link>
	<description>Think shell</description>
	<lastBuildDate>Fri, 07 May 2010 10:47:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TOIC-ORG" /><feedburner:info uri="toic-org" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>SSH port forwarding</title>
		<link>http://feedproxy.google.com/~r/TOIC-ORG/~3/_oPYRc7BPwY/</link>
		<comments>http://toic.org/2010/02/16/ssh-port-forwarding/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 13:44:42 +0000</pubDate>
		<dc:creator>Branko</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Power of shell]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://toic.org/?p=470</guid>
		<description><![CDATA[In one of my previous post I made a tutorial how to bypass corporate firewalls and gain access into your office computer. It work well if you are at your home and you need ssh access (or any other service) to your office computer. However if the situation is reversed, and you need to access [...]


Related posts:<ol><li><a href='http://toic.org/2009/01/18/reverse-ssh-port-forwarding/' rel='bookmark' title='Permanent Link: Bypassing corporate firewall with reverse ssh port forwarding'>Bypassing corporate firewall with reverse ssh port forwarding</a></li>
<li><a href='http://toic.org/2008/11/17/ssh-basics/' rel='bookmark' title='Permanent Link: SSH basics'>SSH basics</a></li>
<li><a href='http://toic.org/2008/12/09/migrating-to-new-web-hosting/' rel='bookmark' title='Permanent Link: Migrating to new web hosting'>Migrating to new web hosting</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/JsrT82-kGfWw7UT3G2htQeM6VZg/0/da"><img src="http://feedads.g.doubleclick.net/~a/JsrT82-kGfWw7UT3G2htQeM6VZg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/JsrT82-kGfWw7UT3G2htQeM6VZg/1/da"><img src="http://feedads.g.doubleclick.net/~a/JsrT82-kGfWw7UT3G2htQeM6VZg/1/di" border="0" ismap="true"></img></a></p><p>In one of my previous post I made a tutorial <a href="http://toic.org/2009/01/18/reverse-ssh-port-forwarding/">how to bypass corporate firewalls</a> and gain access into your office computer. It work well if you are at your home and you need ssh access (or any other service) to your office computer. However if the situation is reversed, and you need to access some outside service which your firewall is blocking then you would use this little tutorial with explanations. Although all this is covered in the ssh man pages, one always learn best by real life examples, so here I&#8217;ll try to cover few of them. So to better explain our first problem look at the picture below:</p>
<h2 id="problem1"><strong>The first problem</strong></h2>
<p><a href="http://images.toic.org/2010/02/Problem.png" rel="lightbox[470]"><img src="http://images.toic.org/2010/02/Problem.png" alt="Ssh port forwarding problem" title="Problem" width="461" height="88" class="aligncenter size-full wp-image-481" /></a></p>
<p><strong>We are located at office computer which is behind the very restrictive firewall and we want to get to the non-standard service running on the remote server.<br />
</strong><br />
So normally if I use for example Mysql Administrator to connect on my MySql database on a remote server, that communication would happen on port 3306, and for this to work Mysql Administrator must have appropriate rules set in our firewall to allow that traffic. <strong>But what if traffic on that port is blocked?</strong><br />
<span id="more-470"></span><br />
Here is where we come to <strong>ssh port forwarding</strong>. If we have ssh access on any outside computer we can route our traffic through the tunnel and gain access to the service via standard ports. <sup>( <a href="#solution1" >solution</a> )</sup></p>
<h2 id="problem2"><strong>The second problem</strong></h2>
<p>Ssh tunnel can be also used to establish connection from insecure networks to standard and non-standard services inside secured, firewalled network as shown in picture bellow: </p>
<p><img src="http://images.toic.org/2010/02/Problem2.png" alt="Another ssh port forwarding challenge" title="Problem2" width="462" height="86" class="aligncenter size-full wp-image-484" /></p>
<p>As you can see here, server is behind the firewall and all the standard ports on that server (like http, pop, imap&#8230;) are allowed, but the server is also running mysql service which is listening on port 3306, to connect to it server&#8217;s firewall should allow this incoming connection. <strong>But what if it doesn&#8217;t?</strong><br />
What if the network from which we are connecting is insecure and we wish to maintain our data private while communicating with our  trusted, firewalled network?<br />
Again we can solve this problem with ssh port forwarding. If we have clear and working ssh access on the server or any other machine in the firewalled network, we can route our traffic through that ssh connection <sup>( <a href="#solution2" >solution</a> )</sup>.</p>
<h2 id="solution1" ><strong>Solving the first problem</strong></h2>
<p><sup>( <a href="#problem1" >problem</a> )</sup><br />
So if our firewall is very restrictive (inbound and outbound), and you don&#8217;t have control over it you can use ssh port forwarding. Essential things you need are: allowed ssh traffic on your restrictive firewall, port 22 by default, a remote server to which you can connect via ssh, and preferably control over that remote server&#8217;s firewall. If even port 22 is blocked in your restrictive firewall you can setup your outside ssh server to listen on some other port that is allowed through your firewall, and than use -p switch in your ssh command to connect on your server. If you don&#8217;t really know anything about ssh, you can always read <a href="http://toic.org/2008/11/17/ssh-basics/">ssh basics</a> and than come back here.</p>
<p></p>
<p>So in our real example we want to connect to mysql service running on remote server and our firewall won&#8217;t allow it. We have ssh access on that server so we will use it to tunnel this traffic.</p>
<p><img src="http://images.toic.org/2010/02/solution1-1.png" alt="Connect throug ssh tunnel to mysql service" title="solution1-1" width="492" height="180" class="aligncenter size-full wp-image-517" /></p>
<p>To start up this tunnel this command will be used:</p>
<pre>ssh -L 3306:localhost:3306 username@server</pre>
<p>So this will actually open up a port 3306 on our local computer listening on loopback interface through established ssh connection on to  server&#8217;s port 3306. If we already have mysql server running on local machine then the port 3306 is already in use, so we need to use another port on our loopback interface, so the command would look like:</p>
<pre>ssh -L 3307:localhost:3306 username@server</pre>
<p>Then we use our service client, in this case Mysql administrator and instruct it to connect to <strong>127.0.0.1</strong> at our specified port.<br />
We can use the same command to tunnel any other port and or service this way. </p>
<h3> Extending this example </h3>
<p>We can also use this connection method to our remote server for routing traffic to some other servers. Of course our remote server must to be able to connect to that remote service.<br />
This is usually very popular to forward traffic to some online games running on non standard ports, EvE, Warcraft,  and any other game (this might produce additional lag on FPS games).</p>
<p><img src="http://images.toic.org/2010/02/solution1-2.png" alt="Connecting to remote gameserver via ssh tunnel" title="solution1-2" width="484" height="304" class="aligncenter size-full wp-image-519" /></p>
<p>As shown on picture, for example we have outside gaming server running at port 66732, and of course that port is blocked in our firewall. We can use our remote server with ssh connection to establish a ssh tunnel and then route that traffic to our local computer.</p>
<p>To do so we would use this command:</p>
<pre>ssh -L 66732:remote.gameserver:66732 username@our.server</pre>
<p>On our loopback interface (127.0.0.1), this will create a listening port 66732  which will be then forwarded to remote.gameserver&#8217;s port 66732 through our ssh connection on port 22.<br />
All you need to do is instruct your game client to connect on localhost. This can also be used in constructive purposes,  like using your remote shell server to route traffic this way to remote mysql server on which you don&#8217;t have ssh access but is available to your remote server via 3306 port.<br />
Bare in mind that your remote ssh server will have to be able to connect to remote.gameserver/mysql server on appropriate port, it your remote server have any outbound firewall rules filtering this traffic, this example will not work until you open that port.</p>
<p>As with <a href="http://toic.org/2009/01/18/reverse-ssh-port-forwarding/">reverse ssh port forwarding</a> we can make this connection available to other computers on our LAN by specifying listening interface while establishing the tunnel. I&#8217;ll go with remote gameserver example and enable our co-workers to connect via same ssh tunnel to remote gameserver without them needing to create their own tunnels.</p>
<p>If you have multiple network interfaces on your computer you will specify the one whit which you are connected to your co workers, but you can also enable it on all interfaces like this:</p>
<p><img src="http://images.toic.org/2010/02/solution1-3.png" alt="Sharing ssh tunnel" title="sharing-ssh-tunnel" width="510" height="420" class="aligncenter size-full wp-image-520" /></p>
<pre>ssh -L 0.0.0.0:66732:remote.gameserver:66732 username@our.server</pre>
<p>when you do netstat -ntl on your machine you will see it&#8217;s listening on 0.0.0.0:66732 port. Your co-workers can now connect to your&#8217;s office pc ip on that port and their connections will be also tunneled via this established ssh connection. Bare in mind that the remote.gameserver will see all the connections comming from our.server so if the remote.gameserver have any per ip connection count limit this will obviously be a problem.</p>
<p></p>
<h2 id="solution2">Solving the second problem</h2>
<p><sup>( <a href="#problem2" >problem</a> )</sup></p>
<p>How is this problem different form the first one. In essence it&#8217;s not, only differences is that our firewall is permitting the non standard traffic, or we don&#8217;t even have a firewall to worry about, but the server&#8217;s firewalled network is very restrictive and its blocking our non standard ports. Ssh tunnel commands used in this example will be the same. However I can use this example for demonstrating why ssh tunnel can be useful for.</p>
<p>Say we don&#8217;t have the firewall and port limitations, but  we are temporary on insecure network and server is on secured/trusted network. If we were to use any of the old plain test services like ftp, pop3, imap, synergy, etc&#8230; malicious hosts/users can sniff out that traffic and find out any usernames and passwords sent via plain text. Even the contents of the connection. So here&#8217;s were ssh tunnel steps in again.</p>
<p>We can start an ssh tunnel from our insecure network to our secured server&#8217;s network and tunnel any plain text/insecure traffic through it. By default ssh tunnel binds its self to loopback interface on our computer, which malicious network user doesn&#8217;t have the access to, and as the ssh is encrypted, all the traffic passing through this tunnel will be plain gibberish to any malicious user sniffing our traffic on this insecure network.</p>
<p>Just like in one of the previous posts (<a href="http://toic.org/2009/02/01/secure-synergy-setup/">secure synergy setup</a>) we will use this tunnel to secure our traffic from eavesdropping. Ftp actually has sftp (ftp over ssh) so if you already have ssh you will want to use that instead of tunneling ftp traffic, but if for any reason you are not able to use it then this should work as well.</p>
<p>I&#8217;ll take my example on pop3:</p>
<p><img src="http://images.toic.org/2010/02/Problem2-1.png" alt="Securing pop3 through ssh tunnel" title="Problem2-1" width="472" height="156" class="aligncenter size-full wp-image-522" /></p>
<p>We establish ssh connection to secured remote server and tunnel the port 110 on our loopback interface to server&#8217;s 110 through established ssh session.<br />
Then we connect with our mail client to localhost and preform plain text pop3 authentication through secure ssh tunnel.</p>
<pre>ssh -L 110:localhost:110 user@secure.server</pre>
<p>If you don&#8217;t have the access to the mail server&#8217;s ssh then you can use another ssh host on secured network to route traffic with this:</p>
<pre>ssh -L 110:mailserver:110 user@secure.server</pre>
<h2>Few useful tips</h2>
<p>As mentioned few times before, perhaps the firewall will not allow standard ssh ports through, or your ssh server is running on different port in which case you should use <strong>-p</strong> switch with ssh. For example your ssh server is running on port 2210 then to forward pop3 traffic you would use:</p>
<pre>ssh -p 2210 -L 110:mailserver:110 user@secure.server</pre>
<p>You can also speed things up by using <a href="http://toic.org/2008/11/17/ssh-basics/#ssh-keys">ssh-keys</a> and <a href="http://toic.org/2008/11/17/ssh-basics/#ssh-agent">ssh-agent</a></p>
<p>And of course if you wish to use your ssh connection only for port forwarding an wish to put it into background you would use:</p>
<pre>ssh -N -f -L 110:mailserver.110 user@secure.server</pre>
<p>And from here it&#8217;s all combinations of above used commands. </p>
<p>Have fun!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=SSH+port+forwarding+-+http://bit.ly/cPwcxI&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://toic.org/2010/02/16/ssh-port-forwarding/&amp;t=SSH+port+forwarding" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://toic.org/2010/02/16/ssh-port-forwarding/&amp;title=SSH+port+forwarding" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=SSH+port+forwarding&amp;link=http://toic.org/2010/02/16/ssh-port-forwarding/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://toic.org/2010/02/16/ssh-port-forwarding/&amp;title=SSH+port+forwarding" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://toic.org/2010/02/16/ssh-port-forwarding/&amp;title=SSH+port+forwarding&amp;summary=In%20one%20of%20my%20previous%20post%20I%20made%20a%20tutorial%20how%20to%20bypass%20corporate%20firewalls%20and%20gain%20access%20into%20your%20office%20computer.%20It%20work%20well%20if%20you%20are%20at%20your%20home%20and%20you%20need%20ssh%20access%20%28or%20any%20other%20service%29%20to%20your%20office%20computer.%20However%20if%20the%20situation%20is%20reversed%2C%20and%20you%20need%20to%20access%20some%20out&amp;source=- [ t o i c . o r g ] -" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://toic.org/2010/02/16/ssh-port-forwarding/&amp;title=SSH+port+forwarding" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://toic.org/2010/02/16/ssh-port-forwarding/&amp;title=SSH+port+forwarding" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=SSH+port+forwarding&amp;body=Link: http://toic.org/2010/02/16/ssh-port-forwarding/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A In%20one%20of%20my%20previous%20post%20I%20made%20a%20tutorial%20how%20to%20bypass%20corporate%20firewalls%20and%20gain%20access%20into%20your%20office%20computer.%20It%20work%20well%20if%20you%20are%20at%20your%20home%20and%20you%20need%20ssh%20access%20%28or%20any%20other%20service%29%20to%20your%20office%20computer.%20However%20if%20the%20situation%20is%20reversed%2C%20and%20you%20need%20to%20access%20some%20out" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://toic.org/2010/02/16/ssh-port-forwarding/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://toic.org/2010/02/16/ssh-port-forwarding/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://toic.org/2010/02/16/ssh-port-forwarding/&amp;title=SSH+port+forwarding&amp;srcUrl=http://toic.org/2010/02/16/ssh-port-forwarding/&amp;srcTitle=SSH+port+forwarding&amp;snippet=In%20one%20of%20my%20previous%20post%20I%20made%20a%20tutorial%20how%20to%20bypass%20corporate%20firewalls%20and%20gain%20access%20into%20your%20office%20computer.%20It%20work%20well%20if%20you%20are%20at%20your%20home%20and%20you%20need%20ssh%20access%20%28or%20any%20other%20service%29%20to%20your%20office%20computer.%20However%20if%20the%20situation%20is%20reversed%2C%20and%20you%20need%20to%20access%20some%20out" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-kaevur">
			<a href="http://kaevur.com/submit.php?url=http://toic.org/2010/02/16/ssh-port-forwarding/" rel="nofollow" class="external" title="Share this on Kaevur">Share this on Kaevur</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://toic.org/2009/01/18/reverse-ssh-port-forwarding/' rel='bookmark' title='Permanent Link: Bypassing corporate firewall with reverse ssh port forwarding'>Bypassing corporate firewall with reverse ssh port forwarding</a></li>
<li><a href='http://toic.org/2008/11/17/ssh-basics/' rel='bookmark' title='Permanent Link: SSH basics'>SSH basics</a></li>
<li><a href='http://toic.org/2008/12/09/migrating-to-new-web-hosting/' rel='bookmark' title='Permanent Link: Migrating to new web hosting'>Migrating to new web hosting</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/TOIC-ORG/~4/_oPYRc7BPwY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://toic.org/2010/02/16/ssh-port-forwarding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://toic.org/2010/02/16/ssh-port-forwarding/</feedburner:origLink></item>
		<item>
		<title>Opensolaris server with COMSTAR and zfs</title>
		<link>http://feedproxy.google.com/~r/TOIC-ORG/~3/0vzTFIm2jiQ/</link>
		<comments>http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 17:26:19 +0000</pubDate>
		<dc:creator>Branko</dc:creator>
				<category><![CDATA[Opensolaris]]></category>
		<category><![CDATA[Storage]]></category>
		<category><![CDATA[comstar]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[iscsi]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[zfs]]></category>

		<guid isPermaLink="false">http://toic.org/?p=397</guid>
		<description><![CDATA[I&#8217;ve being playing around with Sun&#8217;s Opensolaris for a while and I&#8217;m quite pleased with it to say at least. Opensolaris 2009.06 comes with few nifty features and software like dtrace, zfs, COMSTAR, etc. I tried it a while ago as a desktop system, and was quite presently surprised with ZFS and its snapshots so [...]


Related posts:<ol><li><a href='http://toic.org/2009/10/21/howto-create-rsync-server/' rel='bookmark' title='Permanent Link: Howto create rsync server'>Howto create rsync server</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/ByAyn3Gwq5Yui7bscqVaWXCnVPo/0/da"><img src="http://feedads.g.doubleclick.net/~a/ByAyn3Gwq5Yui7bscqVaWXCnVPo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ByAyn3Gwq5Yui7bscqVaWXCnVPo/1/da"><img src="http://feedads.g.doubleclick.net/~a/ByAyn3Gwq5Yui7bscqVaWXCnVPo/1/di" border="0" ismap="true"></img></a></p><p>I&#8217;ve being playing around with Sun&#8217;s Opensolaris for a while and I&#8217;m quite pleased with it to say at least.<br />
Opensolaris 2009.06 comes with few nifty features and software like dtrace, zfs, COMSTAR, etc.</p>
<p>I tried it a while ago as a desktop system, and was quite presently surprised with <strong>ZFS</strong> and its snapshots so I played little more with it. I do plan to make another post on this subject alone but mine main intent of this post will be to help you setup an <strong>Opensolaris server</strong>, without GUI who will use its, I would say best quality, zfs and other set of tools like <strong>COMSTAR</strong> to provide scalable, high performance, low budget, storage server.</p>
<p>Since I intend to use this post for future reference in some setups I will try to keep it straightforward and just explain basic setup for get the non gui Opensolaris up &#038; running with <strong>COMSTAR</strong> and additional <strong>zfs pool</strong> with single simple <strong>iSCSI</strong> target.</p>
<p>I will be using a Opensolaris 2009.06 (you can download LiveCD image from <a href="http://hub.opensolaris.org/bin/view/Main/downloads">this link</a>), a simple low budget hardware with three sata hard drives.</p>
<p><span id="more-397"></span></p>
<h2> Installing Opensolaris </h2>
<p>After you downloaded Opensolaris iso image burn it to a CD and boot your computer with it.<br />
When the cd boots you should get a screen like this:</p>
<p><center><a href="http://images.toic.org/2009/11/cd-grub.png" rel="lightbox[397]"><img src="http://images.toic.org/2009/11/cd-grub-300x225.png" alt="Opensolaris install cd grub" title="Opensolaris install cd grub" width="300" height="225" class="aligncenter size-medium wp-image-432" /></a></center><br />
&nbsp;<br />
just press enter and proceed to the next step at which you will chose keyboard layout and system language. </p>
<p><center><a href="http://images.toic.org/2009/11/lang-select.png" rel="lightbox[397]"><img src="http://images.toic.org/2009/11/lang-select-300x167.png" alt="Opensolaris install language selection" title="Opensolaris install language selection" width="300" height="167" class="aligncenter size-medium wp-image-435" /></a></center><br />
&nbsp;<br />
After that you should find yourself in gnome graphical environment just like with Ubuntu LiveCD installation. </p>
<p><center><a href="http://images.toic.org/2009/11/LiveCD-Desktop.png" rel="lightbox[397]"><img src="http://images.toic.org/2009/11/LiveCD-Desktop-300x214.png" alt="Opensolaris gnome desktop" title="Opensolaris gnome desktop" width="300" height="214" class="aligncenter size-medium wp-image-436" /></a></center><br />
&nbsp;<br />
&nbsp;</p>
<blockquote><p>If for some reason you end up with user/password prompt the default <strong>username</strong> is:<strong>jack</strong> and <strong>password</strong> is:<strong>opensolaris</strong></p></blockquote>
<p>Anyways, double-click on <strong>Install Opensolaris</strong> icon located on the Desktop. Setup wizard will show up which will guide you trough the setup process.</p>
<p>On the Disk selection step I will chose my smallest disk from 20Gb to be used as system disk, and leave those other two disks intact at the moment. Whole installation will take up about 3Gb of storage so the 20gb disk should be ok for now.</p>
<p><center><a href="http://images.toic.org/2009/11/Install-disk.png" rel="lightbox[397]"><img src="http://images.toic.org/2009/11/Install-disk-300x225.png" alt="Opensolaris disk selection at install" title="Opensolaris disk selection at install" width="300" height="225" class="aligncenter size-medium wp-image-433" /></a></center><br />
&nbsp;<br />
On the next two steps you will have to chose your time and locale settings, after which you will define a root password, create a new user and setup a host name for your box.</p>
<p><center><a href="http://images.toic.org/2009/11/Install-user.png" rel="lightbox[397]"><img src="http://images.toic.org/2009/11/Install-user-300x225.png" alt="Opensolaris user creation at installation" title="Opensolaris user creation at installation" width="300" height="225" class="aligncenter size-medium wp-image-434" /></a></center><br />
&nbsp;<br />
Clicking the next button will lead you to the installation review screen, if all of the parameters are correct click on the install button. At this moment you can see there is no way to deselect the gnome, but we will get rid of that in a while. </p>
<p>After the installation is done remove your installation CD and reboot the system. When system is booted you will find yourself in Gnome graphical environment. We won&#8217;t remove it just yet since we need to make our new opensolaris box available on the network. If you might have a dhcp server somewhere on the network opensolaris will pick up an IP address and configuration from it. I don&#8217;t usually use dhcp and I do prefer to use static IP addresses. So let&#8217;s get started with that first.</p>
<h2> Configuring static IP address</h2>
<p>Since I&#8217;m doing a local lab installation my Ip addresses are non Internet routable, replace them with IP addresses suitable for your needs. </p>
<p>Login to your desktop as normal user, open up your terminal and follow these steps:</p>
<pre>
su -
</pre>
<p>enter the root password when asked.</p>
<pre>
svcadm disable network/physical:nwam
svcadm enable network/physical:default
</pre>
<p>Now let&#8217;s find out our network interface names:</p>
<pre>
dladm show-phys
</pre>
<p><center><a href="http://images.toic.org/2009/11/opensolaris-network-list.png" rel="lightbox[397]"><img src="http://images.toic.org/2009/11/opensolaris-network-list-300x224.png" alt="Opensolaris network interface list" title="Opensolaris network interface list" width="300" height="224" class="aligncenter size-medium wp-image-441" /></a></center><br />
&nbsp;<br />
As you may see I have interface named <strong>e1000g0</strong> so the following set of commands would be (adjust your comands for your interface and ip addresses): </p>
<pre>
echo 192.168.2.200 > /etc/hostname.e1000g0
echo opensolaris > /etc/nodename
</pre>
<p>Next we need to edit the hosts file:</p>
<pre>
nano /etc/hosts
</pre>
<p>Make it look like this:</p>
<pre>
192.168.2.200 opensolaris opensolaris.local loghost
::1 localhost
127.0.0.1 localhost
</pre>
<p>now edit a netmasks file:</p>
<pre>
nano /etc/netmasks
</pre>
<p>and append the line</p>
<pre>
192.168.2.0 255.255.255.0
</pre>
<p>Now run this:</p>
<pre>ifconfig e1000g0 plumb
ifconfig e1000g0 192.168.2.200 netmask 255.255.255.0 up</pre>
<p>Now, if you would like to use a DNS for name resolving you must configure resolv.conf file</p>
<pre>
nano /etc/resolv.conf
</pre>
<p>it should look something like this:</p>
<pre>
domain localdomain.com
       nameserver 192.168.2.1
       nameserver 192.168.2.2
</pre>
<p>now run:</p>
<pre>
cp /etc/nsswitch.dns /etc/nsswitch.conf
</pre>
<p>All we need to do is configure a default route:</p>
<pre>
echo 192.168.2.1 >> /etc/defaultrouter
route add default 192.168.2.1
</pre>
<p>Now reboot your server and verify the changes are persistent.</p>
<h2>Removing unnecessary packages</h2>
<p>Your server should be available trough ssh so use it for further configuration.<br />
To remove gui from our opensolaris installation we will be using minimization script bundled with http://kenai.com/projects/isc/pages/OpenSolaris<br />
To do so we would need mercurial so let&#8217;s install it with:</p>
<pre>
pfexec pkg install SUNWmercurial
</pre>
<p>Next we will get the script with command:</p>
<pre>
hg clone ssh://anon@hg.opensolaris.org//hg/isc/src  isc
</pre>
<p>after script checkout run it with:</p>
<pre>
pfexec isc/opt/samples/minimization.ksh
</pre>
<p>Make sure you don&#8217;t execute this command from graphical interface since it will be removed. As the matter of fact script will remove all non essential packages and disable service not needed for running opensolaris as a server.</p>
<h2>Installing and configuring COMSTAR</h2>
<p>By now we should have a clean, fresh, and minimal opensolaris box, now it&#8217;s time to add some functionality to it.</p>
<p>To install it just enter:</p>
<pre>
pfexec pkg install storage-server
</pre>
<p>This will install all the required packages and services.<br />
First thing to do is enabling stmf service. By default the service is off, to enable it type:</p>
<pre>
pfexec svcadm enable stmf
</pre>
<p>now runing:</p>
<pre>
svcs stmf
</pre>
<p>should say the service is in maintenance mode. This is due to drivers not being loaded to kernel immediately after install, so we need to reboot the server in order to get this service running (still searching a way to circumvent the reboot process). </p>
<p>After reboot is complete verify that the service is running:</p>
<pre>
branko@opensolaris:~$ svcs stmf
STATE          STIME    FMRI
online         17:07:54 svc:/system/stmf:default
branko@opensolaris:~$ pfexec stmfadm list-state
Operational Status: online
Config Status     : initialized
</pre>
<h2> Configuring zfs pool </h2>
<p>Now for the rest of this post we will setup additional <strong>zfs pool</strong>, and configure one basic <strong>iscsi target</strong> on it.</p>
<p>Remember our two unused disks at the install?<br />
Well let&#8217;s make another zfs pool on them. If you don&#8217;t have additional disks, you can skip this step and configure iscsi target on already existing zfs pool.</p>
<p>Let&#8217;s find out which disk we are already using:</p>
<pre>
su -
zpool status
</pre>
<p>You should get something like:</p>
<pre>
  pool: rpool
 state: ONLINE
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        rpool       ONLINE       0     0     0
          c8t0d0s0  ONLINE       0     0     0

errors: No known data errors
</pre>
<p>Note the disk name already in use is <strong>c8t0d0s0</strong>. Now to find out what other disks are present on the system let&#8217;s use format command:</p>
<pre>format</pre>
<p>Now program will launch interactive shell and should display something like this:</p>
<pre>
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c8t0d0 <default cyl 2607 alt 2 hd 255 sec 63>
          /pci@0,0/pci1000,8000@14/sd@0,0
       1. c8t1d0 </default><default cyl 13052 alt 2 hd 255 sec 63>
          /pci@0,0/pci1000,8000@14/sd@1,0
       2. c8t2d0 </default><default cyl 13052 alt 2 hd 255 sec 63>
          /pci@0,0/pci1000,8000@14/sd@2,0
Specify disk (enter its number):
</default></pre>
<p>If your disk doesn&#8217;t show up try entering </p>
<pre>devfsadm</pre>
<p> prior to format command.</p>
<p>Hit the <strong>CTRL+C</strong> key combination since we actualy don&#8217;t want to format any disks.<br />
Now we found additional two disks by lables <strong>c8t1d0</strong> and <strong>c8t2d0</strong></p>
<p>To make new zfs pool with them we will enter following command:</p>
<pre>
zpool create data mirror c8t1d0 c8t2d0
</pre>
<p>where &#8220;<strong>data</strong>&#8221; is the name of the new pool, <strong>mirror</strong> is type and <strong>c8t1d0</strong> and <strong>c8t2d0</strong> are devices for this pool.</p>
<p>Let&#8217;s verify the pool existance:</p>
<pre>zpool list</pre>
<p>Should print out:</p>
<pre>NAME    SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
data   99.5G    76K  99.5G     0%  ONLINE  -
rpool  19.9G  4.43G  15.4G    22%  ONLINE  -</pre>
<p>or</p>
<pre>
# zpool status data
  pool: data
 state: ONLINE
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        data        ONLINE       0     0     0
          mirror    ONLINE       0     0     0
            c8t1d0  ONLINE       0     0     0
            c8t2d0  ONLINE       0     0     0

errors: No known data errors
</pre>
<p>And now we have a brand new zfs pool for storing iscsi targets.</p>
<h2>Creating iscsi target</h2>
<p>Let&#8217;s start with creating 10Gb zvol which we will export as iscsi target. We will use -s flag for sparse so we can thin provision our targets.</p>
<pre>
zfs create -s -V 10g data/iscsitarget
</pre>
<p>Now let&#8217;s see the volume:</p>
<pre># zfs list data/iscsitarget
NAME               USED  AVAIL  REFER  MOUNTPOINT
data/iscsitarget    16K  97.9G    16K  -</pre>
<p>Now, let&#8217;s create a logical unit using this volume:</p>
<pre>sbdadm create-lu /dev/zvol/rdsk/data/iscsitarget</pre>
<p>It will return: </p>
<pre>Created the following LU:

              GUID                    DATA SIZE           SOURCE
--------------------------------  -------------------  ----------------
600144f01cdf4f0000004af6f28b0001      10737352704      /dev/zvol/rdsk/data/iscsitarget
</pre>
<p>Verify the creation with:</p>
<pre>sbdadm list-lu</pre>
<p>To make a logical unit available to all hosts type:</p>
<pre>stmfadm add-view 600144f01cdf4f0000004af6f28b0001</pre>
<p>where <strong>600144f01cdf4f0000004af6f28b0001</strong> is your lu GUID</p>
<h3> Enabling iscsit service</h3>
<p>first we need to install SUNWiscsit</p>
<pre>pkg install SUNWiscsit</pre>
<p>Then check service states:</p>
<pre># svcs -a | grep -i iscsi
disabled       17:07:06 svc:/network/iscsi_initiator:default
disabled       18:07:47 svc:/network/iscsi/target:default
online         17:40:45 svc:/system/iscsitgt:default
</pre>
<p>Disable iscsitgt</p>
<pre>svcadm disable iscsitgt</pre>
<p>and enable the iscsi target service</p>
<pre>svcadm enable -r svc:/network/iscsi/target:default</pre>
<p>Make sure it&#8217;s started: </p>
<pre>svcs -a | grep iscsi</pre>
<p>if it ends up in maintenance mode, reboot your machine and check again.</p>
<p>If the output is something like:</p>
<pre>online  14:21:25 svc:/network/iscsi/target:default</pre>
<h3> Creating a target for discovery</h3>
<p>If the service is started create a target with:</p>
<pre>itadm create-target</pre>
<p>Verify target creation:</p>
<pre>itadm list-target</pre>
<p>and link iscsi devices to local system:</p>
<pre>devfsadm -i iscsi</pre>
<p>you should now see this logical volume on your iscsi initiators.</p>
<p>And that would be all for now. In some future posts I will describe more usage examples based on this setup.<br />
Until next time&#8230; </p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Opensolaris+server+with+COMSTAR+and+zfs+-+http://bit.ly/1YE6XE&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/&amp;t=Opensolaris+server+with+COMSTAR+and+zfs" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/&amp;title=Opensolaris+server+with+COMSTAR+and+zfs" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Opensolaris+server+with+COMSTAR+and+zfs&amp;link=http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/&amp;title=Opensolaris+server+with+COMSTAR+and+zfs" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/&amp;title=Opensolaris+server+with+COMSTAR+and+zfs&amp;summary=I%27ve%20being%20playing%20around%20with%20Sun%27s%20Opensolaris%20for%20a%20while%20and%20I%27m%20quite%20pleased%20with%20it%20to%20say%20at%20least.%0D%0AOpensolaris%202009.06%20comes%20with%20few%20nifty%20features%20and%20software%20like%20dtrace%2C%20zfs%2C%20COMSTAR%2C%20etc.%0D%0A%0D%0AI%20tried%20it%20a%20while%20ago%20as%20a%20desktop%20system%2C%20and%20was%20quite%20presently%20surprised%20with%20ZFS%20and%20it&amp;source=- [ t o i c . o r g ] -" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/&amp;title=Opensolaris+server+with+COMSTAR+and+zfs" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/&amp;title=Opensolaris+server+with+COMSTAR+and+zfs" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Opensolaris+server+with+COMSTAR+and+zfs&amp;body=Link: http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%27ve%20being%20playing%20around%20with%20Sun%27s%20Opensolaris%20for%20a%20while%20and%20I%27m%20quite%20pleased%20with%20it%20to%20say%20at%20least.%0D%0AOpensolaris%202009.06%20comes%20with%20few%20nifty%20features%20and%20software%20like%20dtrace%2C%20zfs%2C%20COMSTAR%2C%20etc.%0D%0A%0D%0AI%20tried%20it%20a%20while%20ago%20as%20a%20desktop%20system%2C%20and%20was%20quite%20presently%20surprised%20with%20ZFS%20and%20it" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/&amp;title=Opensolaris+server+with+COMSTAR+and+zfs&amp;srcUrl=http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/&amp;srcTitle=Opensolaris+server+with+COMSTAR+and+zfs&amp;snippet=I%27ve%20being%20playing%20around%20with%20Sun%27s%20Opensolaris%20for%20a%20while%20and%20I%27m%20quite%20pleased%20with%20it%20to%20say%20at%20least.%0D%0AOpensolaris%202009.06%20comes%20with%20few%20nifty%20features%20and%20software%20like%20dtrace%2C%20zfs%2C%20COMSTAR%2C%20etc.%0D%0A%0D%0AI%20tried%20it%20a%20while%20ago%20as%20a%20desktop%20system%2C%20and%20was%20quite%20presently%20surprised%20with%20ZFS%20and%20it" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-kaevur">
			<a href="http://kaevur.com/submit.php?url=http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/" rel="nofollow" class="external" title="Share this on Kaevur">Share this on Kaevur</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://toic.org/2009/10/21/howto-create-rsync-server/' rel='bookmark' title='Permanent Link: Howto create rsync server'>Howto create rsync server</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/TOIC-ORG/~4/0vzTFIm2jiQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/</feedburner:origLink></item>
		<item>
		<title>Dealing with memory limits</title>
		<link>http://feedproxy.google.com/~r/TOIC-ORG/~3/tcGZ9aaZts4/</link>
		<comments>http://toic.org/2009/10/27/dealing-with-memory-limits/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 13:19:15 +0000</pubDate>
		<dc:creator>Branko</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programing]]></category>
		<category><![CDATA[memory]]></category>

		<guid isPermaLink="false">http://toic.org/?p=411</guid>
		<description><![CDATA[So i decided to make a little different post than usual, a little more thoughts based than tutorial alike. I would like to take a brief overview of todays memory usage for various tasks and scripts. Since large part of my the day is involved in web servers and their management I will mainly focus [...]


Related posts:<ol><li><a href='http://toic.org/2008/12/09/migrating-to-new-web-hosting/' rel='bookmark' title='Permanent Link: Migrating to new web hosting'>Migrating to new web hosting</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/nd4iodyRZ-cXGfR6t8THXlt_LEU/0/da"><img src="http://feedads.g.doubleclick.net/~a/nd4iodyRZ-cXGfR6t8THXlt_LEU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/nd4iodyRZ-cXGfR6t8THXlt_LEU/1/da"><img src="http://feedads.g.doubleclick.net/~a/nd4iodyRZ-cXGfR6t8THXlt_LEU/1/di" border="0" ismap="true"></img></a></p><p><img title="memory usage" src="http://images.toic.org/2009/10/memory.png" alt="memory usage limits " width="508" height="55" /></p>
<p>So i decided to make a little different post than usual, a little more thoughts based than tutorial alike.<br />
I would like to take a brief overview of todays memory usage for various tasks and scripts. Since large part of my the day is involved in web servers and their management I will mainly focus on memory usage for web applications and scripts.</p>
<p>Not so long ago, having a server with 4Gb of  working memory was a luxury, today we have certain scripts consuming about 512Mb of memory while running. What changed?<br />
Internet boom, popularity of web 2.0 applications, ease of development, bunch of those learn programing in 21 days books and tutorials, that is what happened. In addition there is a whole bunch of people from “I want Internet” generation who still don&#8217;t quite grasp the difference between RAM and Disk memory, not to mention they don&#8217;t quite grasp the inner mechanics of computer systems.</p>
<blockquote><p>Sir&#8230; the white smoke got out of your metal box&#8230; you must refill it with white smoke to make it work again</p></blockquote>
<p>Well, like it or not those people like to call themselves web masters and web developers.</p>
<p><span id="more-411"></span></p>
<p>I&#8217;m not claiming to be an über-pro programmer or that I posses some super natural insight in programing, but I usually do like to use common sense when I&#8217;m involved in developing something.</p>
<p>Over the time I witnessed some pretty messed up code. Ranging from abstract syntax to heavily demented processing logic. Mainly in web development problems lie in those books teach yourself php in 3 hours. As it is covered in this <a href="http://norvig.com/21-days.html">fantastic article</a> learning some programing language takes time. You can&#8217;t just learn to program in few days. What you can do is learn some basic syntax and few useful functions. First problem I encountered trough passed few years with such developers is url_fopen. I covered those cons and pros of <a href="http://toic.org/2008/10/08/fetching-remote-content-with-curl/">curl vs fopen article</a>, but the point is learning PHP from 21 days book will never explain you this.</p>
<p>Same thing goes here with memory management and some script logic. Usually those books tend to have simplistic approach, and usually don&#8217;t bother much with script optimizations for heavy usage. Learning PHP in that way new programmers tend to write unoptimized code.</p>
<p>Few years back I had a “clash” with one of those newbie developers. He actually developed something on his local machine, tested it and released it into public. This even worked for some times while he was in some sort of marketing phase still advertising his new product. At some point his php script started to throw “memory exhausted” errors. After a short while he contacted me and said</p>
<blockquote><p>Hey&#8230; what is wrong with your web server? I still have a plenty of disk space available, why is he throwing this error? You must have miss-configured it!</p></blockquote>
<p>Doh! Well I&#8217;ll skip the part of explaining him the difference between memory and disk space, and few other arguments and get to the point what was wrong with the script.<br />
Script was tested in lab environment, populated with only basic entries and not so well tested with multiple users requesting multiple data, with extensive data growth over time. The script literary massacred the MySql server with some joins on tables without any indexes ranging in size from 40-50Mb in size an few millions of records. Needles to say almost all the data was put into php array for later processing thus exceeding the php memory limit.<br />
While there was less data and less users script worked since the array didn&#8217;t leave the configured memory limit.</p>
<p>Usually joins in mysql query can be avoided, and server will return the requested data faster. But the root cause of his problem reporting was this php memory limit. And the simple answer for this problem is partial data processing.</p>
<blockquote><p>Get some data from mysql -&gt; put it to variable -&gt; process it -&gt; free the memory -&gt; repeat the process until done</p></blockquote>
<p>With proper query you will give some slack to mysql server, you will lower the memory usage of the script and so on&#8230;.</p>
<p>Although this type of problem with “one man band” developers making some applications for themselves is a problem, a much larger problems are those kinds of developers hiding behind some big and widely spread open source web applications like Joomla, Drupal, phpBB etc and even some paid web applications.</p>
<p>Here we have a problem with people not yet involved with programming but they still own and make new sites based on some of those free open source applications. Applications are so widely used across huge amount of sites that they gained some kind of authority status saying we make good stuff.<br />
Problem here is since it is open source any developer (even those newbie ones) can contribute to the source. Not so much to the core of the application but as a plugin. Plugins are installed separately and usually involve some risk of bad developer practice.</p>
<p>One of such plugins that I will take for an example (nothing personal it&#8217;s just a fresh memory) is  jom_sef.<br />
While very useful for SEO optimizations of certain parts of site this plugin actually loads every time a visitor loads or reloads your site. This plugin also reads a bunch of records from his mysql table and puts it into some sort of array. Remember my newbie developer from before? This plugin generally works while there is a low count and volume of data that he needs to process. But at some point it stops, and users find themselves in weird situation.</p>
<p>First thing to do for them are to contact their host provider with the same question</p>
<blockquote><p>Hey, this thing worked all this time! What did you do to the server? Make it work.</p></blockquote>
<p>Some may bother explaining to the customer what just happened, and they will accept it for what it is. Some will just increase the memory limit until next time. And some will just fight the never ending battle with the customer. Customer will complain on the public forums, community or even the developer of the plugin itself will advise customer to change the company since it all works like a charm (yes but on low traffic, no data website).</p>
<p>Now regardless of the battle outcome, let us review this from the server side. Weather you have shared or dedicated server of your own you have to consider this problem from the server side.</p>
<p>Your dedicated server will have for example 4Gb of RAM. Let&#8217;s say that the mysql server is located on the same machine and it is using about 600Mb to 1Gb of memory depending of the usage. Let&#8217;s say we will take aprox. 300-400Mb of memory for basic system usage, and that much for mail system. That leaves us with aprox. 2Gb of memory for our webserver. So let&#8217;s enable the jom_sef and let us give it the 64Mb memory limit per php child. Since jom_sef will load each time visitor comes to our site and each time it will consume near 64Mb of memory that leaves us with 32 concurrent users.</p>
<p>Well what&#8217;s wrong here? Is it the server and it&#8217;s setup&#8230; or is it the script?</p>
<p>Fact is servers are getting bigger and bigger each day. It&#8217;s not so uncommon to find a +24Gb of RAM shared hosting servers which may tolerate your memory consumption until some point. But when you reach that limits shared hosting servers will usually cut you off. Increasing memory limits beyond that is a risk. Memory overallocation will most certainty bring your server into unusable state.</p>
<blockquote><p>Common sense is very uncommon.<br />
~Horace Greeley</p></blockquote>
<p>Common sense from one of those people, that believes “white smoke” is the power behind the computers, is that something is terribly wrong with the server. He is paying much more for his dedicated server than his colleague for his shared hosting, but his script is not working, server is “dying”!</p>
<blockquote><p>Well if you are a “white smoke” believer let me try it this way.<br />
You will pay a great deal of money for your Ferrari, but if you take it to the woods and chop some trees then hook up let&#8217;s say 32 of those trees onto the back of your Ferrari, will it move?</p></blockquote>
<p>On the other hand we have some great software and plugins like for example WordPress and wp-supercache where we can run entire system, mysql and our website in just a 512Mb of RAM for bunch of concurrent users since they will be served with pre-generated static pages.</p>
<p>So the conclusion I guess would be:</p>
<p>If you believe in “white smoke” please hear the advice from your sysadmin. If you on the other hand just finishing with your “Learn php in 21 days” book, please don&#8217;t jump into developing some public available software. Make as little damage as you can. Keep the planet green, reduce the number of servers needed for running the web.</p>
<p>Hope this helps someone to make some sense into some developers and users.<br />
And for all of you frustrated with the same things please leave the message after the beep!</p>
<p>&#8212; Beeeep &#8212;</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Dealing+with+memory+limits+-+http://bit.ly/uIWiN&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://toic.org/2009/10/27/dealing-with-memory-limits/&amp;t=Dealing+with+memory+limits" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://toic.org/2009/10/27/dealing-with-memory-limits/&amp;title=Dealing+with+memory+limits" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Dealing+with+memory+limits&amp;link=http://toic.org/2009/10/27/dealing-with-memory-limits/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://toic.org/2009/10/27/dealing-with-memory-limits/&amp;title=Dealing+with+memory+limits" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://toic.org/2009/10/27/dealing-with-memory-limits/&amp;title=Dealing+with+memory+limits&amp;summary=%0D%0A%0D%0ASo%20i%20decided%20to%20make%20a%20little%20different%20post%20than%20usual%2C%20a%20little%20more%20thoughts%20based%20than%20tutorial%20alike.%0D%0AI%20would%20like%20to%20take%20a%20brief%20overview%20of%20todays%20memory%20usage%20for%20various%20tasks%20and%20scripts.%20Since%20large%20part%20of%20my%20the%20day%20is%20involved%20in%20web%20servers%20and%20their%20management%20I%20will%20mainly%20foc&amp;source=- [ t o i c . o r g ] -" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://toic.org/2009/10/27/dealing-with-memory-limits/&amp;title=Dealing+with+memory+limits" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://toic.org/2009/10/27/dealing-with-memory-limits/&amp;title=Dealing+with+memory+limits" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Dealing+with+memory+limits&amp;body=Link: http://toic.org/2009/10/27/dealing-with-memory-limits/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A %0D%0A%0D%0ASo%20i%20decided%20to%20make%20a%20little%20different%20post%20than%20usual%2C%20a%20little%20more%20thoughts%20based%20than%20tutorial%20alike.%0D%0AI%20would%20like%20to%20take%20a%20brief%20overview%20of%20todays%20memory%20usage%20for%20various%20tasks%20and%20scripts.%20Since%20large%20part%20of%20my%20the%20day%20is%20involved%20in%20web%20servers%20and%20their%20management%20I%20will%20mainly%20foc" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://toic.org/2009/10/27/dealing-with-memory-limits/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://toic.org/2009/10/27/dealing-with-memory-limits/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://toic.org/2009/10/27/dealing-with-memory-limits/&amp;title=Dealing+with+memory+limits&amp;srcUrl=http://toic.org/2009/10/27/dealing-with-memory-limits/&amp;srcTitle=Dealing+with+memory+limits&amp;snippet=%0D%0A%0D%0ASo%20i%20decided%20to%20make%20a%20little%20different%20post%20than%20usual%2C%20a%20little%20more%20thoughts%20based%20than%20tutorial%20alike.%0D%0AI%20would%20like%20to%20take%20a%20brief%20overview%20of%20todays%20memory%20usage%20for%20various%20tasks%20and%20scripts.%20Since%20large%20part%20of%20my%20the%20day%20is%20involved%20in%20web%20servers%20and%20their%20management%20I%20will%20mainly%20foc" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-kaevur">
			<a href="http://kaevur.com/submit.php?url=http://toic.org/2009/10/27/dealing-with-memory-limits/" rel="nofollow" class="external" title="Share this on Kaevur">Share this on Kaevur</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://toic.org/2008/12/09/migrating-to-new-web-hosting/' rel='bookmark' title='Permanent Link: Migrating to new web hosting'>Migrating to new web hosting</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/TOIC-ORG/~4/tcGZ9aaZts4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://toic.org/2009/10/27/dealing-with-memory-limits/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://toic.org/2009/10/27/dealing-with-memory-limits/</feedburner:origLink></item>
		<item>
		<title>Howto create rsync server</title>
		<link>http://feedproxy.google.com/~r/TOIC-ORG/~3/o1SocuW7d-Q/</link>
		<comments>http://toic.org/2009/10/21/howto-create-rsync-server/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 12:09:49 +0000</pubDate>
		<dc:creator>Branko</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Storage]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://toic.org/?p=395</guid>
		<description><![CDATA[There are tons of reasons why would one want to create a rsync server. For example you wish to backup your data to a remote server but you don&#8217;t want to backup everything every time. rsync is an open source utility that provides fast incremental file transfer. rsync is freely available under the GNU General [...]


Related posts:<ol><li><a href='http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/' rel='bookmark' title='Permanent Link: Opensolaris server with COMSTAR and zfs'>Opensolaris server with COMSTAR and zfs</a></li>
<li><a href='http://toic.org/2008/11/17/ssh-basics/' rel='bookmark' title='Permanent Link: SSH basics'>SSH basics</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/tnFguMxZ8hj70D-irtDK2QwyyCc/0/da"><img src="http://feedads.g.doubleclick.net/~a/tnFguMxZ8hj70D-irtDK2QwyyCc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/tnFguMxZ8hj70D-irtDK2QwyyCc/1/da"><img src="http://feedads.g.doubleclick.net/~a/tnFguMxZ8hj70D-irtDK2QwyyCc/1/di" border="0" ismap="true"></img></a></p><p>There are tons of reasons why would one want to create a rsync server. For example you wish to backup your data to a remote server but you don&#8217;t want to backup everything every time. </p>
<blockquote><p>rsync is an open source utility that provides fast incremental file transfer. rsync is freely available under the GNU General Public License and is currently being maintained by Wayne Davison. </p></blockquote>
<p>As you can see rsync is ideal for this. You can use it within ssh protocol, rsh and rsync itself. Creating a rsync server will allow you to create easily accessible storage server, update server for your scripts, etc.</p>
<p>Anyway let&#8217;s get started on configuring rsync server which will serve as remote backup server.<br />
<span id="more-395"></span></p>
<p>Ok first make sure you have tcp and udp port 873 open in your firewall.<br />
Next install rsync on your machine (if you don&#8217;t have it yet), and xinetd as well.</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">yum install -y rsync xinetd</div></div>
<p>We will make rsync available trouh xinetd so you must enable it by editing its conf file</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nano /etc/xinetd.d/rsync</div></div>
<p>edit the line saying:</p>
<pre>disable = yes</pre>
<p>so it says:</p>
<pre>disable = no</pre>
<p>so the entire file should look something like this:</p>
<pre>
service rsync
{
       	disable = no
       	socket_type     = stream
       	wait            = no
       	user            = root
       	server          = /usr/bin/rsync
       	server_args     = --daemon
       	log_on_failure  += USERID
}
</pre>
<p>Next we want to create rsync client username and password</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nano /etc/rsyncd.secrets</div></div>
<p>and enter a username and password in format:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">username:password</div></div>
<p>yes it&#8217;s plain text.<br />
Let&#8217;s create a rsync server conf file:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;nano /etc/rsyncd.conf</div></div>
<p>now here enter:
<pre>
#maximum allowed connections
max connections = 10
#where to log
log file = /var/log/rsync.log
timeout = 300
</pre>
<p>Now to create a share using a password and being able to send files to rsync server we will add this to our /etc/rsyncd.conf:</p>
<pre>
[backup]
comment = Backup place for my office computers
path = /backup/
read only = false
list = yes
uid = backup
gid = backup
hosts allow = 192.168.0.0/24 # i want to limit the rsnyc server only to this group of hosts
secrets file = /etc/rsyncd.secrets
auth users = username #enter username specified in secrets file
</pre>
<p>Now what we have here is a rsync server module at path /backup which will allow only hosts within 192.168.0.0/24 network and users authenticated by username specified in secrets file.</p>
<p>To make sure this will be somewhat secure let&#8217;s change permissions on rsync config files</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">chown root.root /etc/rsyncd.*<br />
chmod 600 /etc/rsyncd.*</div></div>
<p>Restart the xinetd</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">service xinetd restart</div></div>
<p>and voila. </p>
<p>Let&#8217;s go test it out from one of our clietn hosts:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rsync rsync.server.com::<br />
<br />
backup &nbsp; &nbsp; &nbsp; &nbsp; Backup place for my office computers</div></div>
<p>So to actualy backup something onto this host we would use:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rsync -avz ./ username@rsync.server.com::backup</div></div>
<p>the command would ask us for a password specified in secrets file.<br />
After successful login rsync will start to transfer files to remote machine.<br />
Next time we start it it will only transfer the differences since last time.</p>
<p>If you would like to script this entering a password could be a problem. Luckily rsync offers a solution in password file.</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nano /home/branko/.rsync.pass</div></div>
<p>enter your password here and chmod this file to 600 so it&#8217;s only readable by you.<br />
start the rsync with following command:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rsync -avz --password-file=/home/branko/.rsync.passw ./ username@rsync.server.com::backup</div></div>
<p>Ofcourse this could be done in reverse.</p>
<p>To setup another share for download only we would create a read-only share without passwords.<br />
just append this to your /etc/rsyncd.conf file:</p>
<pre>
[update]
comment = update downloads
path = /home/branko/update
read only = true
list = yes
uid = branko
gid = branko
hosts allow = 192.168.0.0/24
</pre>
<p>Restart the xinetd</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">service xinetd restart</div></div>
<p>Now you may see there is no auth user or secrets password. So when we issue the rsync command on our server again:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;rsync rsync.server.com::</div></div>
<p>you will se another module available by the name update.</p>
<p>to rsync content from this module just use:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rsync -avz rsync.server.com::update ./</div></div>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Howto+create+rsync+server+-+http://bit.ly/4jPdUm&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://toic.org/2009/10/21/howto-create-rsync-server/&amp;t=Howto+create+rsync+server" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://toic.org/2009/10/21/howto-create-rsync-server/&amp;title=Howto+create+rsync+server" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Howto+create+rsync+server&amp;link=http://toic.org/2009/10/21/howto-create-rsync-server/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://toic.org/2009/10/21/howto-create-rsync-server/&amp;title=Howto+create+rsync+server" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://toic.org/2009/10/21/howto-create-rsync-server/&amp;title=Howto+create+rsync+server&amp;summary=There%20are%20tons%20of%20reasons%20why%20would%20one%20want%20to%20create%20a%20rsync%20server.%20For%20example%20you%20wish%20to%20backup%20your%20data%20to%20a%20remote%20server%20but%20you%20don%27t%20want%20to%20backup%20everything%20every%20time.%20%0D%0Arsync%20is%20an%20open%20source%20utility%20that%20provides%20fast%20incremental%20file%20transfer.%20rsync%20is%20freely%20available%20under%20the%20G&amp;source=- [ t o i c . o r g ] -" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://toic.org/2009/10/21/howto-create-rsync-server/&amp;title=Howto+create+rsync+server" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://toic.org/2009/10/21/howto-create-rsync-server/&amp;title=Howto+create+rsync+server" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Howto+create+rsync+server&amp;body=Link: http://toic.org/2009/10/21/howto-create-rsync-server/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A There%20are%20tons%20of%20reasons%20why%20would%20one%20want%20to%20create%20a%20rsync%20server.%20For%20example%20you%20wish%20to%20backup%20your%20data%20to%20a%20remote%20server%20but%20you%20don%27t%20want%20to%20backup%20everything%20every%20time.%20%0D%0Arsync%20is%20an%20open%20source%20utility%20that%20provides%20fast%20incremental%20file%20transfer.%20rsync%20is%20freely%20available%20under%20the%20G" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://toic.org/2009/10/21/howto-create-rsync-server/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://toic.org/2009/10/21/howto-create-rsync-server/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://toic.org/2009/10/21/howto-create-rsync-server/&amp;title=Howto+create+rsync+server&amp;srcUrl=http://toic.org/2009/10/21/howto-create-rsync-server/&amp;srcTitle=Howto+create+rsync+server&amp;snippet=There%20are%20tons%20of%20reasons%20why%20would%20one%20want%20to%20create%20a%20rsync%20server.%20For%20example%20you%20wish%20to%20backup%20your%20data%20to%20a%20remote%20server%20but%20you%20don%27t%20want%20to%20backup%20everything%20every%20time.%20%0D%0Arsync%20is%20an%20open%20source%20utility%20that%20provides%20fast%20incremental%20file%20transfer.%20rsync%20is%20freely%20available%20under%20the%20G" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-kaevur">
			<a href="http://kaevur.com/submit.php?url=http://toic.org/2009/10/21/howto-create-rsync-server/" rel="nofollow" class="external" title="Share this on Kaevur">Share this on Kaevur</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://toic.org/2009/11/08/opensolaris-server-with-comstar-and-zfs/' rel='bookmark' title='Permanent Link: Opensolaris server with COMSTAR and zfs'>Opensolaris server with COMSTAR and zfs</a></li>
<li><a href='http://toic.org/2008/11/17/ssh-basics/' rel='bookmark' title='Permanent Link: SSH basics'>SSH basics</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/TOIC-ORG/~4/o1SocuW7d-Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://toic.org/2009/10/21/howto-create-rsync-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://toic.org/2009/10/21/howto-create-rsync-server/</feedburner:origLink></item>
		<item>
		<title>Munin centralized monitoring on Centos</title>
		<link>http://feedproxy.google.com/~r/TOIC-ORG/~3/Aqv8rypbB3g/</link>
		<comments>http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 11:06:57 +0000</pubDate>
		<dc:creator>Branko</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://toic.org/?p=358</guid>
		<description><![CDATA[So recently I went nuts having to login onto each server to look at its munin graphs. While you have few servers it&#8217;s doable, but managing large farms and checking up on them while having to login into each is just pain in the ass. So what to do? Hey&#8230; let&#8217;s make a central munin [...]


No related posts.]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/-_cQ5RAp3YTm0POxkSVHmQqxwwk/0/da"><img src="http://feedads.g.doubleclick.net/~a/-_cQ5RAp3YTm0POxkSVHmQqxwwk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/-_cQ5RAp3YTm0POxkSVHmQqxwwk/1/da"><img src="http://feedads.g.doubleclick.net/~a/-_cQ5RAp3YTm0POxkSVHmQqxwwk/1/di" border="0" ismap="true"></img></a></p><p><img src="http://images.toic.org/2009/10/munin.png" alt="munin" title="munin" width="72" height="82" class="alignleft size-full wp-image-384" />So recently I went nuts having to login onto each server to look at its munin graphs. While you have few servers it&#8217;s doable, but managing large farms and checking up on them while having to login into each is just pain in the ass.<br />
So what to do?<br />
Hey&#8230; let&#8217;s make a central munin server, and let&#8217;s hold all the graphs there. That way we can review them all with just one user name and password, we can compare host performances, etc&#8230;<br />
To accomplish this we will need one server for centralized graphs (could be a low budget dedicated server or a small vps), apache installed on central munin server, munin-node installed on all other server we wish to monitor.<br />
<span id="more-358"></span></p>
</p>
<h2>Installing munin</h2>
</p>
<p>So this will be a minimal install for a central munin server. I&#8217;m using a small vps with minimal centos install.<br />
First let&#8217;s setup elrepo</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm</div></div>
<p>Now we need to install munin and munin-node (if you wish to monitor this host as well).</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">yum install -y munin munin-node</div></div>
<p>by default munin will put its html files into <strong>/var/www/html/munin</strong> folder<br />
If you wish to move that to another place, now is your time. For the sake of simplicity I&#8217;ll just leave it where it is.<br />
Of course we will need apache to access those munin html files, so if you don&#8217;t have apache installed do:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">yum install -y apache</div></div>
<p>now start the apache</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">service httpd start</div></div>
<p>If you left everything as it is munin html should be available at:</p>
<p>http://yourhostname.com/munin/</p>
<p>You may notice that there is nothing there yet, just wait until we configure all other hosts.<br />
start the munin-node on this host (if you installed it)</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">service munin-node start</div></div>
<p>Make sure your cron is runing</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">service crond status</div></div>
<p>and let&#8217;s go configure those other hosts.
</p>
<h2>Installing munin-node</h2>
</p>
<h3>Installing on cPanel</h3>
</p>
<p>Since lot&#8217;s of my servers to monitor are with cPanel installed there is an easy way to install munin.</p>
<p>Login to your <strong>whm</strong> go to: <strong>Manage plugins</strong>, now find <strong>Munin</strong>, click a check box, scroll down and click save.<br />
After the munin is installed it should appear in your <strong>whm</strong> at the bottom of the navigation.<br />
Go and check up if the munin is installed correctly.</p>
<p>Installing trough cPanel will install munin-node and munin, you can disable the munin graphing later if you like.</p>
<p>
</p>
<h3>Installing on non cPanel</h3>
<p>We can install munin on Centos trough Elrepo.<br />
first we will setup elrepo</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm</div></div>
<p>and then install a munin-node:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">yum install -y munin-node</div></div>
<p>voila&#8230; let&#8217;s configure nodes on remote servers now.</p>
<h2>Configuring munin-node on remote hosts</h2>
</p>
<p>For both cPanel and non-cPanel servers all we need to do is add allowed host in munin-node.conf</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nano /etc/munin/munin-node.conf</div></div>
<p>add at the end of the file:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">allow ^192\.168\.0\.20$</div></div>
<p>where 192.168.0.20 is the ip address of you central munin server.<br />
restart the munin-node:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">service munin-node restart</div></div>
<p>If you have firewall installed on that host (and I hope you do), allow the incoming tcp port 4949 for the ip of the central node.</p>
<p>In <a href="http://www.configserver.com/cp/csf.html">csf</a> add the following line:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">tcp:in:d=4949:s=192.168.0.20</div></div>
<p>to your /etc/csf/csf.allow file<br />
or just run:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iptables -A INPUT -p tcp -s 192.168.0.2 --dport 4949 -m state --state NEW,ESTABLISHED -j ACCEPT</div></div>
<p>Modify this to your firewall, and don&#8217;t forget to replace 192.168.0.20 with your munin server<br />
Now everything should be ready for data collection from central server
</p>
<h2>Configuring munin server</h2>
</p>
<p>All we need to do now is to configure the munin</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nano /etc/munin/munin.conf</div></div>
<p>If you didn&#8217;t change any locations of html files and munin datastore you realy don&#8217;t need to change that in the conf file.</p>
<p>What we are interested with are the host sections. You will notice there is configuration for our localhost<br />
You can change its name now, leave the address field as it is.</p>
<p>To add up a new host just add:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[myhost.mydomain.com]<br />
address 192.168.0.10<br />
use_host_name yes</div></div>
<p>change the 192.168.0.10 with the ip of the server you wish to monitor.<br />
you can now add as many host you like.<br />
Make sure that you have enabled outgoing connections on tcp port 4949 on your central munin server.<br />
After a while the first results should start to appear.
</p>
<h2>Configuring multi host display graphs</h2>
</p>
<p>The real benefit of having all the host graphs and data on one place is you can easily make multi host graphs and compare the loads on the servers. This could help you grasp a bigger picture of individual server workloads and give you an idea what to improve and how to load balance between the machines.</p>
<p>Here is one of the example graphs, showing apache request per second. If the machines were the same hardware configuration that would give indications that some of the machines have higher hit rate and we would need to rewrite our load balancing.</p>
<p><img class="aligncenter size-medium wp-image-371" title="side by side plugins" src="http://images.toic.org/2009/10/screenshot2-300x144.png" alt="side by side plugins" width="300" height="144" /></p>
<p>We could do the same thing with load graphs and see which servers have the spikes, and distribute the workload on some less loaded servers.</p>
<p><img class="aligncenter size-medium wp-image-372" title="load graph" src="http://images.toic.org/2009/10/load-graph-300x141.png" alt="load graph" width="300" height="141" /><br />
<strong><br />
So how do we configure this?</strong></p>
<p>First you need to find out rrd&#8217;s name of the data you wish to put on the graph.</p>
<p>for example apache accesses per second:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">cd /var/lib/munin/yourdomain.com</div></div>
<p><strong>ls -lh</strong> in the directory and you will find out what data is available to munin.<br />
in case of the apache accesses data we will have few files named:</p>
<blockquote><p>hostname.domainname.com-<span style="color: red;">apache_accesses-accesses80</span>-d.rrd<br />
hostname2.domainname.com-<span style="color: red;">apache_accesses-accesses80</span>-d.rrd</p></blockquote>
<p>what we are interested with are those fields (marked in red) after the domain name separated by dash.<br />
Ok let&#8217;s write a conf in munin.conf for this two hosts.</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;nano /etc/munin/munin.conf</div></div>
<p>Go under the host definitions in your conf file and add:</p>
<blockquote><p><strong>[domainname.com;Totals]<br />
<span style="color: green;">update no</span><br />
<span style="color: blue;">apacheaccess</span>.graph_title Apache access side by side<br />
<span style="color: blue;">apacheaccess</span>.graph_order hostname=hostname.domainname.com:<span style="color: red;">apache_accesses.accesses80</span> hostname1=hostname1.domainname.com.com:<span style="color: red;">apache_accesses.accesses80</span></strong></p></blockquote>
<p>Notice the red lines, they are the same as rrd filenames red parts we saw earlier, just replace dash with dot.<br />
Green text is to disable updates for this domain declaration since updates are already done at the host declaration in the conf file. Blue is the graph representation name, followed by title in the first line and data in second.</p>
<p>This way you can make all the side by side graphs for all the data munin collected in rrd files. After the changes wait for a next munin update and enjoy the graphs <img src='http://toic.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Munin+centralized+monitoring+on+Centos+-+http://bit.ly/kLt8k&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/&amp;t=Munin+centralized+monitoring+on+Centos" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/&amp;title=Munin+centralized+monitoring+on+Centos" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Munin+centralized+monitoring+on+Centos&amp;link=http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/&amp;title=Munin+centralized+monitoring+on+Centos" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/&amp;title=Munin+centralized+monitoring+on+Centos&amp;summary=So%20recently%20I%20went%20nuts%20having%20to%20login%20onto%20each%20server%20to%20look%20at%20its%20munin%20graphs.%20While%20you%20have%20few%20servers%20it%27s%20doable%2C%20but%20managing%20large%20farms%20and%20checking%20up%20on%20them%20while%20having%20to%20login%20into%20each%20is%20just%20pain%20in%20the%20ass.%0D%0ASo%20what%20to%20do%3F%0D%0AHey...%20let%27s%20make%20a%20central%20munin%20server%2C%20and%20let%27s&amp;source=- [ t o i c . o r g ] -" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/&amp;title=Munin+centralized+monitoring+on+Centos" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/&amp;title=Munin+centralized+monitoring+on+Centos" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Munin+centralized+monitoring+on+Centos&amp;body=Link: http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A So%20recently%20I%20went%20nuts%20having%20to%20login%20onto%20each%20server%20to%20look%20at%20its%20munin%20graphs.%20While%20you%20have%20few%20servers%20it%27s%20doable%2C%20but%20managing%20large%20farms%20and%20checking%20up%20on%20them%20while%20having%20to%20login%20into%20each%20is%20just%20pain%20in%20the%20ass.%0D%0ASo%20what%20to%20do%3F%0D%0AHey...%20let%27s%20make%20a%20central%20munin%20server%2C%20and%20let%27s" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/&amp;title=Munin+centralized+monitoring+on+Centos&amp;srcUrl=http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/&amp;srcTitle=Munin+centralized+monitoring+on+Centos&amp;snippet=So%20recently%20I%20went%20nuts%20having%20to%20login%20onto%20each%20server%20to%20look%20at%20its%20munin%20graphs.%20While%20you%20have%20few%20servers%20it%27s%20doable%2C%20but%20managing%20large%20farms%20and%20checking%20up%20on%20them%20while%20having%20to%20login%20into%20each%20is%20just%20pain%20in%20the%20ass.%0D%0ASo%20what%20to%20do%3F%0D%0AHey...%20let%27s%20make%20a%20central%20munin%20server%2C%20and%20let%27s" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-kaevur">
			<a href="http://kaevur.com/submit.php?url=http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/" rel="nofollow" class="external" title="Share this on Kaevur">Share this on Kaevur</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>No related posts.</p><img src="http://feeds.feedburner.com/~r/TOIC-ORG/~4/Aqv8rypbB3g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://toic.org/2009/10/03/munin-centralized-monitoring-on-centos/</feedburner:origLink></item>
		<item>
		<title>Tail -f in python, truncate aware</title>
		<link>http://feedproxy.google.com/~r/TOIC-ORG/~3/oEGauMyoJ7A/</link>
		<comments>http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 13:03:42 +0000</pubDate>
		<dc:creator>Branko</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[programing]]></category>

		<guid isPermaLink="false">http://toic.org/?p=314</guid>
		<description><![CDATA[So while doing a little coding I tried to find some tail -f class in python that will recognize when file that we tailing is been truncated. All I found was some tail -f classes that brakes on file truncate or rotate. Eventually I came up with this: import time from os import stat from [...]


No related posts.]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/ejKqCCc1iuXzSSuwsj3MXpU7v44/0/da"><img src="http://feedads.g.doubleclick.net/~a/ejKqCCc1iuXzSSuwsj3MXpU7v44/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ejKqCCc1iuXzSSuwsj3MXpU7v44/1/da"><img src="http://feedads.g.doubleclick.net/~a/ejKqCCc1iuXzSSuwsj3MXpU7v44/1/di" border="0" ismap="true"></img></a></p><p>So while doing a little coding I tried to find some tail -f class in python that will recognize when file that we tailing is been truncated. All I found was some tail -f classes that brakes on file truncate or rotate. </p>
<p>Eventually I came up with this:</p>
<div class="codecolorer-container python mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span><br />
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">os</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">stat</span><br />
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span> <span style="color: #ff7700;font-weight:bold;">import</span> abspath<br />
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">stat</span> <span style="color: #ff7700;font-weight:bold;">import</span> ST_SIZE<br />
&nbsp;<br />
<span style="color: #ff7700;font-weight:bold;">class</span> LogTail:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, logfile<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">logfile</span> = abspath<span style="color: black;">&#40;</span>logfile<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">f</span> = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">logfile</span>,<span style="color: #483d8b;">&quot;r&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; file_len = <span style="color: #dc143c;">stat</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">logfile</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>ST_SIZE<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">f</span>.<span style="color: black;">seek</span><span style="color: black;">&#40;</span>file_len<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">pos</span> = <span style="color: #008000;">self</span>.<span style="color: black;">f</span>.<span style="color: black;">tell</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> _reset<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">f</span>.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">f</span> = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">logfile</span>, <span style="color: #483d8b;">&quot;r&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">pos</span> = <span style="color: #008000;">self</span>.<span style="color: black;">f</span>.<span style="color: black;">tell</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> tail<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>: &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #ff4500;">1</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">pos</span> = <span style="color: #008000;">self</span>.<span style="color: black;">f</span>.<span style="color: black;">tell</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #008000;">self</span>.<span style="color: black;">f</span>.<span style="color: #dc143c;">readline</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> line:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">stat</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">logfile</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>ST_SIZE<span style="color: black;">&#93;</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #008000;">self</span>.<span style="color: black;">pos</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>._reset<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #dc143c;">time</span>.<span style="color: black;">sleep</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">f</span>.<span style="color: black;">seek</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">pos</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;&quot;&quot;print, return or otherwise manipulate<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; the tailed line&quot;&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> line</div></div>
<p>Maybe it&#8217;s a too much overhead to check each time for file size, but you get the general idea. </p>
<p>So anyways here&#8217;s a usage exampe:</p>
<p></code></p>
<div class="codecolorer-container python mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">tail = LogTail<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/var/log/messages&quot;</span><span style="color: black;">&#41;</span><br />
tail.<span style="color: black;">tail</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></div>
<p>This will print out any new line appended to /var/log/messages file. If the file gets truncated or log rotated, class will detect it and will return to the start.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Tail+-f+in+python%2C+truncate+aware++-+http://bit.ly/1axWHU&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/&amp;t=Tail+-f+in+python%2C+truncate+aware+" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/&amp;title=Tail+-f+in+python%2C+truncate+aware+" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Tail+-f+in+python%2C+truncate+aware+&amp;link=http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/&amp;title=Tail+-f+in+python%2C+truncate+aware+" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/&amp;title=Tail+-f+in+python%2C+truncate+aware+&amp;summary=So%20while%20doing%20a%20little%20coding%20I%20tried%20to%20find%20some%20tail%20-f%20class%20in%20python%20that%20will%20recognize%20when%20file%20that%20we%20tailing%20is%20been%20truncated.%20All%20I%20found%20was%20some%20tail%20-f%20classes%20that%20brakes%20on%20file%20truncate%20or%20rotate.%20%0D%0A%0D%0AEventually%20I%20came%20up%20with%20this%3A%0D%0A%0D%0A%0D%0Aimport%20time%0D%0Afrom%20os%20import%20stat%0D%0Afrom%20os&amp;source=- [ t o i c . o r g ] -" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/&amp;title=Tail+-f+in+python%2C+truncate+aware+" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/&amp;title=Tail+-f+in+python%2C+truncate+aware+" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Tail+-f+in+python%2C+truncate+aware+&amp;body=Link: http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A So%20while%20doing%20a%20little%20coding%20I%20tried%20to%20find%20some%20tail%20-f%20class%20in%20python%20that%20will%20recognize%20when%20file%20that%20we%20tailing%20is%20been%20truncated.%20All%20I%20found%20was%20some%20tail%20-f%20classes%20that%20brakes%20on%20file%20truncate%20or%20rotate.%20%0D%0A%0D%0AEventually%20I%20came%20up%20with%20this%3A%0D%0A%0D%0A%0D%0Aimport%20time%0D%0Afrom%20os%20import%20stat%0D%0Afrom%20os" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/&amp;title=Tail+-f+in+python%2C+truncate+aware+&amp;srcUrl=http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/&amp;srcTitle=Tail+-f+in+python%2C+truncate+aware+&amp;snippet=So%20while%20doing%20a%20little%20coding%20I%20tried%20to%20find%20some%20tail%20-f%20class%20in%20python%20that%20will%20recognize%20when%20file%20that%20we%20tailing%20is%20been%20truncated.%20All%20I%20found%20was%20some%20tail%20-f%20classes%20that%20brakes%20on%20file%20truncate%20or%20rotate.%20%0D%0A%0D%0AEventually%20I%20came%20up%20with%20this%3A%0D%0A%0D%0A%0D%0Aimport%20time%0D%0Afrom%20os%20import%20stat%0D%0Afrom%20os" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-kaevur">
			<a href="http://kaevur.com/submit.php?url=http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/" rel="nofollow" class="external" title="Share this on Kaevur">Share this on Kaevur</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>No related posts.</p><img src="http://feeds.feedburner.com/~r/TOIC-ORG/~4/oEGauMyoJ7A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://toic.org/2009/08/11/tail-f-in-python-truncate-aware/</feedburner:origLink></item>
		<item>
		<title>Firewalling xen bridge</title>
		<link>http://feedproxy.google.com/~r/TOIC-ORG/~3/RorhY34wsMk/</link>
		<comments>http://toic.org/2009/04/19/firewalling-xen-bridge/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 19:11:17 +0000</pubDate>
		<dc:creator>Branko</dc:creator>
				<category><![CDATA[The Art of Virtual]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://toic.org/?p=179</guid>
		<description><![CDATA[Occasionally you will wish to block certain ports to your DomUs from Dom0. By default you wish to allow any traffic from and to DomU but for some security considerations, I found it to be wise to block some ports to and from my clients DomUs. One such port range is for example IRC. Although [...]


Related posts:<ol><li><a href='http://toic.org/2008/10/06/multiple-network-interfaces-in-xen/' rel='bookmark' title='Permanent Link: Multiple network interfaces in Xen'>Multiple network interfaces in Xen</a></li>
<li><a href='http://toic.org/2008/09/22/preventing-ip-conflicts-in-xen/' rel='bookmark' title='Permanent Link: Preventing ip conflicts in xen'>Preventing ip conflicts in xen</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/pwd3Hbr3YHruXU7JSZVCvDi7ZT0/0/da"><img src="http://feedads.g.doubleclick.net/~a/pwd3Hbr3YHruXU7JSZVCvDi7ZT0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/pwd3Hbr3YHruXU7JSZVCvDi7ZT0/1/da"><img src="http://feedads.g.doubleclick.net/~a/pwd3Hbr3YHruXU7JSZVCvDi7ZT0/1/di" border="0" ismap="true"></img></a></p><p>Occasionally you will wish to block certain ports to your DomUs from Dom0. By default you wish to allow any traffic from and to DomU but for some security considerations, I found it to be wise to block some ports to and from my clients DomUs. One such port range is for example IRC. Although it can be routed trough alternate ports, most of those automated nasty malicious scripts use default ones. It&#8217;s quite handy to block them so they ain&#8217;t able to contact home.</p>
<p>As said by default Xen bridge is open for all traffics towards and from DomUs. It&#8217;s up to DomU admin to firewall their own virtual machine. Unfortunately some just forget to do the proper securing of the system, and as a result you get compromised DomU contacting various botnets, and executing all kind of nasty stuff.</p>
<p>To prevent this we can make a firewall rules in DomU that will by default block some traffic. Since I&#8217;m using bridged network firwalling must be done on bridge. I found <a href="http://www.shorewall.net/Xen.html" target="_blank">this</a> great article on shorewall manuals how  to setup bridged network firewall. I installed it and tested it on 32bit Centos 5.2 should work on any system though but I didn&#8217;t tested it on any other.<br />
<span id="more-179"></span><br />
<br />
Fist of all you will need to <a href="http://shorewall.net/download.htm">download</a> and install latest shorewall. As stated in documentation link above: Because Xen uses normal Linux bridging, you must enable bridge support in shorewall.conf</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nano /etc/shorewall/shorewall.conf</div></div>
<p>Set</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">BRIDGING=Yes</div></div>
<p>Now we have to edit our firewall zones:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nano /etc/shorewall/zones</div></div>
<p><strong> </strong>It should look something like this (<a href="http://toic.org/files/xenshorewall/zones" target="_blank">link to file</a>):</p>
<pre>#ZONE   TYPE            OPTIONS         IN                      OUT
#                                       OPTIONS                 OPTIONS
fw    firewall
dom0    ipv4
domU    ipv4
net     ipv4
#LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
</pre>
<p>Next thing to do is to define network interfaces, we will be dealing with two network interfaces: virtualized eth0 and bridge.</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nano /etc/shorewall/interfaces</div></div>
<p>And the file should look like this (<a href="http://toic.org/files/xenshorewall/interfaces" target="_blank">link to file</a>):</p>
<pre>#ZONE   INTERFACE    BROADCAST    OPTIONS
-    xenbr0          -               dhcp
net     eth0            detect          dhcp
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE</pre>
<p>And next we must edit hosts file</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nano /etc/shorewall/hosts</div></div>
<p>And the file should look like this (<a href="http://toic.org/files/xenshorewall/hosts" target="_blank">link to file</a>):</p>
<pre>#ZONE   HOST(S)                                 OPTIONS
dom0    xenbr0:vif0.0
domU    xenbr0:vif+                            routeback
net     xenbr0:peth0
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS LINE -- DO NOT REMOVE</pre>
<p>Now let&#8217;s make some policies in our firewall:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nano /etc/shorewall/policy</div></div>
<p>And the file should look like this (<a href="http://toic.org/files/xenshorewall/policy">link to file</a>):</p>
<pre>#SOURCE DEST    POLICY          LOG     LIMIT:          CONNLIMIT:
#                               LEVEL   BURST           MASK
fw    all     ACCEPT
all     fw    ACCEPT         info
dom0    all     ACCEPT
all     dom0    ACCEPT         info
domU    all     ACCEPT
all    domU        ACCEPT
net     net     NONE
all     all     REJECT         info
#LAST LINE -- DO NOT REMOVE</pre>
<p>This will by default allow any traffic through the bridge. You can also specify DROP policy for your Dom0 and then open necessary  the ports in rules file. Note that the fw and dom0 are the same the same but they both need to be declared in policy and rules file. So&#8230; for now this all does not block IRC traffic as we started to do, so all we need to do now is to setup the rules file.</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nano /etc/shorewall/rules</div></div>
<p>And the file should look like this (<a href="http://toic.org/files/xenshorewall/rules">link to file</a>):</p>
<pre>#ACTION         SOURCE          DEST            PROTO   DEST    SOURCE   ORIGINAL        RATE            USER/   MARK    CONNLIMIT    TIME                                                       PORT    PORT(S)         DEST            LIMIT           GROUP
#irc
REJECT          net             domU            tcp     6660:6669
REJECT          domU            net             tcp     6660:6669
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE</pre>
<p>Now this will block all incoming and outgoing traffic from port range 6660 to 6669 for all DomUs. If you wish to add an exception to one DomU you can simply edit the rules file and insert the exception above the REJECT (<a href="http://toic.org/files/xenshorewall/rulesexception">sample exception config</a>):</p>
<pre>#ACTION         SOURCE          DEST            PROTO   DEST    SOURCE   ORIGINAL        RATE            USER/   MARK    CONNLIMIT    TIME                                                       PORT    PORT(S)         DEST            LIMIT           GROUP
#DomU exceptions
ACCEPT  net     domU:192.168.0.10    tcp     6660:6669
ACCEPT  domU:192.168.0.10    net     tcp     6660:6669

#DomU restrictions
#irc
REJECT          net             domU            tcp     6660:6669
REJECT          domU            net             tcp     6660:6669
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
</pre>
<p>This way only the DomU with ip 192.168.0.10 will have unblocked IRC ports. Although the above config should work it didn&#8217;t for me. Centos 5.2 by default comes with</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">net.bridge.bridge-nf-call-iptables = 0</div></div>
<p>so no bridge firewalling is actually done. To enable this edit your sysctl.conf file</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nano /etc/sysctl.conf</div></div>
<p>and append:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">net.bridge.bridge-nf-call-iptables = 1</div></div>
<p>now run:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sysctl -p</div></div>
<p>And the bridged firewall for your DomUs should work now.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Firewalling+xen+bridge+-+http://bit.ly/9MteN&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://toic.org/2009/04/19/firewalling-xen-bridge/&amp;t=Firewalling+xen+bridge" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://toic.org/2009/04/19/firewalling-xen-bridge/&amp;title=Firewalling+xen+bridge" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Firewalling+xen+bridge&amp;link=http://toic.org/2009/04/19/firewalling-xen-bridge/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://toic.org/2009/04/19/firewalling-xen-bridge/&amp;title=Firewalling+xen+bridge" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://toic.org/2009/04/19/firewalling-xen-bridge/&amp;title=Firewalling+xen+bridge&amp;summary=Occasionally%20you%20will%20wish%20to%20block%20certain%20ports%20to%20your%20DomUs%20from%20Dom0.%20By%20default%20you%20wish%20to%20allow%20any%20traffic%20from%20and%20to%20DomU%20but%20for%20some%20security%20considerations%2C%20I%20found%20it%20to%20be%20wise%20to%20block%20some%20ports%20to%20and%20from%20my%20clients%20DomUs.%20One%20such%20port%20range%20is%20for%20example%20IRC.%20Although%20it%20can%20b&amp;source=- [ t o i c . o r g ] -" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://toic.org/2009/04/19/firewalling-xen-bridge/&amp;title=Firewalling+xen+bridge" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://toic.org/2009/04/19/firewalling-xen-bridge/&amp;title=Firewalling+xen+bridge" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Firewalling+xen+bridge&amp;body=Link: http://toic.org/2009/04/19/firewalling-xen-bridge/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Occasionally%20you%20will%20wish%20to%20block%20certain%20ports%20to%20your%20DomUs%20from%20Dom0.%20By%20default%20you%20wish%20to%20allow%20any%20traffic%20from%20and%20to%20DomU%20but%20for%20some%20security%20considerations%2C%20I%20found%20it%20to%20be%20wise%20to%20block%20some%20ports%20to%20and%20from%20my%20clients%20DomUs.%20One%20such%20port%20range%20is%20for%20example%20IRC.%20Although%20it%20can%20b" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://toic.org/2009/04/19/firewalling-xen-bridge/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://toic.org/2009/04/19/firewalling-xen-bridge/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://toic.org/2009/04/19/firewalling-xen-bridge/&amp;title=Firewalling+xen+bridge&amp;srcUrl=http://toic.org/2009/04/19/firewalling-xen-bridge/&amp;srcTitle=Firewalling+xen+bridge&amp;snippet=Occasionally%20you%20will%20wish%20to%20block%20certain%20ports%20to%20your%20DomUs%20from%20Dom0.%20By%20default%20you%20wish%20to%20allow%20any%20traffic%20from%20and%20to%20DomU%20but%20for%20some%20security%20considerations%2C%20I%20found%20it%20to%20be%20wise%20to%20block%20some%20ports%20to%20and%20from%20my%20clients%20DomUs.%20One%20such%20port%20range%20is%20for%20example%20IRC.%20Although%20it%20can%20b" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-kaevur">
			<a href="http://kaevur.com/submit.php?url=http://toic.org/2009/04/19/firewalling-xen-bridge/" rel="nofollow" class="external" title="Share this on Kaevur">Share this on Kaevur</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://toic.org/2008/10/06/multiple-network-interfaces-in-xen/' rel='bookmark' title='Permanent Link: Multiple network interfaces in Xen'>Multiple network interfaces in Xen</a></li>
<li><a href='http://toic.org/2008/09/22/preventing-ip-conflicts-in-xen/' rel='bookmark' title='Permanent Link: Preventing ip conflicts in xen'>Preventing ip conflicts in xen</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/TOIC-ORG/~4/RorhY34wsMk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://toic.org/2009/04/19/firewalling-xen-bridge/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://toic.org/2009/04/19/firewalling-xen-bridge/</feedburner:origLink></item>
		<item>
		<title>Secure synergy setup</title>
		<link>http://feedproxy.google.com/~r/TOIC-ORG/~3/-ZS29hvRonM/</link>
		<comments>http://toic.org/2009/02/01/secure-synergy-setup/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 20:47:03 +0000</pubDate>
		<dc:creator>Branko</dc:creator>
				<category><![CDATA[LInux Desktop]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://toic.org/?p=241</guid>
		<description><![CDATA[Synergy is a nifty tool for cross platform clipboard, keyboard and mouse sharing. It&#8217;s reasonably easy to configure synergy server for use with multiple synergy clients. Doing so will spare you some time while working on multiple computers at your desk at once. I use it at office to connect my laptop&#8217;s and office computer [...]


Related posts:<ol><li><a href='http://toic.org/2010/02/16/ssh-port-forwarding/' rel='bookmark' title='Permanent Link: SSH port forwarding'>SSH port forwarding</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/Zo1g2PaL8FSKDjW-vPAJ5w1qcjU/0/da"><img src="http://feedads.g.doubleclick.net/~a/Zo1g2PaL8FSKDjW-vPAJ5w1qcjU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Zo1g2PaL8FSKDjW-vPAJ5w1qcjU/1/da"><img src="http://feedads.g.doubleclick.net/~a/Zo1g2PaL8FSKDjW-vPAJ5w1qcjU/1/di" border="0" ismap="true"></img></a></p><p>Synergy is a nifty tool for cross platform clipboard, keyboard and mouse sharing. It&#8217;s reasonably easy to configure synergy server for use with multiple synergy clients. Doing so will spare you some time while working on multiple computers at your desk at once. I use it at office to connect my laptop&#8217;s and office computer mouse, keyboard and clipboard and thus reducing or completely eliminating need to lean over my laptop every time I need to use it. Anyway, most of the people use it with quicksynergy wrapper allowing even easier setup, but what the synergy lack is a means of authentication and security in data transfers. I&#8217;ll try to guide you how to make a secure synergy setup on untrusted networks.</p>
<p>So  for a starter you will need to setup a synergy config file to use it with your synergy server.<br />
While using a quicksynergy may be easier we won&#8217;t use it since it lacks some flexibility.</p>
<p>I&#8217;m using my laptop named blap and my office computer named kex. Blap is located to the left of kex so I will need a conf file looking like this:<br />
<span id="more-241"></span></p>
<pre>section: screens
    blap:
    kex:
end

section: links
    kex:
        left = blap
    blap:
        right = kex
end</pre>
<p><div class="diggbutton"><script type="text/javascript">digg_url = 'http://digg.com/security/Secure_synergy_setup';</script><script type="text/javascript" src="http://digg.com/api/diggthis.js"></script></div>at the first section we define two screens, one for laptop and one for office computer each named by their host name. At the second section we define links between two screens which states that left from computer kex is computer blap. And for blap right edge of screen is linked with computer kex. We can define as many hosts we like in relative positions. You can consult manual page of synergys for all available options.</p>
<p></p>
<p>When done configuring screens and links save that file as <strong>synergy.conf</strong> in your home directory.</p>
<p>Starting a server with:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">synergys -c /home/branko/synergy.conf</div></div>
<p>will allow us to connect to our office computer using our laptop and merging screens.<br />
Like stated earlier, synergy server have no means of authentication so any client within our network can connect to. Naturally if I&#8217;m on busy or untrusted network this isn&#8217;t very appealing thought. On top of that, all traffic between synergy server and client is unencrypted so anyone on local network can eavesdrop with tcpdump, wireshark or any other network capturing program. Anything that gets to clipboard is available to our malicious user on our local network.<br />
So how can we implement some sort of encryption and authentication on our synergy server.</p>
<p>First we will add additional parameter to our synergy server startup line:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">synergys -a 127.0.0.1 -c /home/branko/synergy.conf</div></div>
<p>this way synergy server will start listening on loopback network interface instead on all network interfaces. This way we are only allowing access to synergy server to locally authenticated users. You can now put this command in session startup.</p>
<p>Since now server is not available on any outside interface we must first login and authenticate our self to the office computer. While doing so we will also open a ssh tunnel to our laptop.</p>
<p>So prior to executing our synergy client on laptop I will need to execute:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ssh -N -f -L 24800:localhost:24800 branko@192.168.0.100</div></div>
<p>this will open up ssh connection to my office computer (192.168.0.100) for which I will need to login as user <strong>branko</strong> an when I do so port <strong>24800</strong> on <strong>192.168.0.100</strong> will be tunneled to my localhost&#8217;s port <strong>24800</strong>.</p>
<p>Now I can simply start up my synergy client on my laptop by executing:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;strong&gt;synergyc localhost&lt;/strong&gt;</div></div>
<p>Now all the traffic between my laptop and office computer is encrypted and as such information traveling trough the ssh tunnel are unavailable to possible eavesdropping, and since we started the server on a loopback interface no malicious client can be connected from outside. For the ease of use you can combine the above comands in single shell script and saving it in users private bin folder.</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">pico ~/bin/synergy</div></div>
<p>paste the text inside</p>
<pre>#!/bin/sh
ssh -N -f -L 24800:localhost:24800 username@synergyserver
synergyc localhost</pre>
<p>Make it executable:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">chmod +x ~/bin/synergy</div></div>
<p>And now you can simply type <strong>synergy</strong> at your terminal or run command prompt after pressing <strong>ALT + F2</strong></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Secure+synergy+setup+-+http://bit.ly/Ksg16&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://toic.org/2009/02/01/secure-synergy-setup/&amp;t=Secure+synergy+setup" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://toic.org/2009/02/01/secure-synergy-setup/&amp;title=Secure+synergy+setup" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Secure+synergy+setup&amp;link=http://toic.org/2009/02/01/secure-synergy-setup/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://toic.org/2009/02/01/secure-synergy-setup/&amp;title=Secure+synergy+setup" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://toic.org/2009/02/01/secure-synergy-setup/&amp;title=Secure+synergy+setup&amp;summary=Synergy%20is%20a%20nifty%20tool%20for%20cross%20platform%20clipboard%2C%20keyboard%20and%20mouse%20sharing.%20It%27s%20reasonably%20easy%20to%20configure%20synergy%20server%20for%20use%20with%20multiple%20synergy%20clients.%20Doing%20so%20will%20spare%20you%20some%20time%20while%20working%20on%20multiple%20computers%20at%20your%20desk%20at%20once.%20I%20use%20it%20at%20office%20to%20connect%20my%20lapto&amp;source=- [ t o i c . o r g ] -" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://toic.org/2009/02/01/secure-synergy-setup/&amp;title=Secure+synergy+setup" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://toic.org/2009/02/01/secure-synergy-setup/&amp;title=Secure+synergy+setup" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Secure+synergy+setup&amp;body=Link: http://toic.org/2009/02/01/secure-synergy-setup/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Synergy%20is%20a%20nifty%20tool%20for%20cross%20platform%20clipboard%2C%20keyboard%20and%20mouse%20sharing.%20It%27s%20reasonably%20easy%20to%20configure%20synergy%20server%20for%20use%20with%20multiple%20synergy%20clients.%20Doing%20so%20will%20spare%20you%20some%20time%20while%20working%20on%20multiple%20computers%20at%20your%20desk%20at%20once.%20I%20use%20it%20at%20office%20to%20connect%20my%20lapto" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://toic.org/2009/02/01/secure-synergy-setup/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://toic.org/2009/02/01/secure-synergy-setup/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://toic.org/2009/02/01/secure-synergy-setup/&amp;title=Secure+synergy+setup&amp;srcUrl=http://toic.org/2009/02/01/secure-synergy-setup/&amp;srcTitle=Secure+synergy+setup&amp;snippet=Synergy%20is%20a%20nifty%20tool%20for%20cross%20platform%20clipboard%2C%20keyboard%20and%20mouse%20sharing.%20It%27s%20reasonably%20easy%20to%20configure%20synergy%20server%20for%20use%20with%20multiple%20synergy%20clients.%20Doing%20so%20will%20spare%20you%20some%20time%20while%20working%20on%20multiple%20computers%20at%20your%20desk%20at%20once.%20I%20use%20it%20at%20office%20to%20connect%20my%20lapto" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-kaevur">
			<a href="http://kaevur.com/submit.php?url=http://toic.org/2009/02/01/secure-synergy-setup/" rel="nofollow" class="external" title="Share this on Kaevur">Share this on Kaevur</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://toic.org/2010/02/16/ssh-port-forwarding/' rel='bookmark' title='Permanent Link: SSH port forwarding'>SSH port forwarding</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/TOIC-ORG/~4/-ZS29hvRonM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://toic.org/2009/02/01/secure-synergy-setup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://toic.org/2009/02/01/secure-synergy-setup/</feedburner:origLink></item>
		<item>
		<title>Bypassing corporate firewall with reverse ssh port forwarding</title>
		<link>http://feedproxy.google.com/~r/TOIC-ORG/~3/sMXNKjWfCnQ/</link>
		<comments>http://toic.org/2009/01/18/reverse-ssh-port-forwarding/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 17:21:54 +0000</pubDate>
		<dc:creator>Branko</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Power of shell]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://toic.org/?p=207</guid>
		<description><![CDATA[Probably lots of you are behind some sort of very restrictive corporate firewall. Unable to access your office pc from home because of firewall policies. In normal cases this scenario is more than welcomed. No outsiders should be allowed to access internal parts of secure network! Ideally companies will setup secure VPN access thus allowing [...]


Related posts:<ol><li><a href='http://toic.org/2010/02/16/ssh-port-forwarding/' rel='bookmark' title='Permanent Link: SSH port forwarding'>SSH port forwarding</a></li>
<li><a href='http://toic.org/2009/02/01/secure-synergy-setup/' rel='bookmark' title='Permanent Link: Secure synergy setup'>Secure synergy setup</a></li>
<li><a href='http://toic.org/2008/11/17/ssh-basics/' rel='bookmark' title='Permanent Link: SSH basics'>SSH basics</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/R4PuEaefYtumlqFPlU5BisrgIVY/0/da"><img src="http://feedads.g.doubleclick.net/~a/R4PuEaefYtumlqFPlU5BisrgIVY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/R4PuEaefYtumlqFPlU5BisrgIVY/1/da"><img src="http://feedads.g.doubleclick.net/~a/R4PuEaefYtumlqFPlU5BisrgIVY/1/di" border="0" ismap="true"></img></a></p><p>Probably lots of you are behind some sort of very restrictive corporate firewall. Unable to access your office pc from home because of firewall policies. In normal cases this scenario is more than welcomed. No outsiders should be allowed to access internal parts of secure network! Ideally companies will setup secure VPN access thus allowing its employees to access their work computers and do some work remotely. What if you aren&#8217;t one of the lucky ones having such option? You desperately need to access your office pc?</p>
<h2><strong>The problem</strong></h2>
<p style="text-align: center;"><img class="size-full wp-image-212 aligncenter" title="current" src="http://images.toic.org/2009/01/current.png" alt="current" width="463" height="160" /></p>
<p><span id="more-207"></span><br />
<div class="diggbutton"><script type="text/javascript">digg_url = 'http://digg.com/linux_unix/Bypassing_corp_firewall_with_reverse_ssh_port_forwarding';</script><script type="text/javascript" src="http://digg.com/api/diggthis.js"></script></div>As shown on the picture above, we have our office PC behind very restrictive corporate firewall connected to Internet. Firewall will not allow any traffic originating from Internet to internal network except previously initiated traffic. Meaning you can contact remote hosts on Internet from your office PC and they can respond, but remote computers can&#8217;t initiate connection to your office PC. This is of course huge problem if you have to access your work materials on office PC from your home. Additionally corporate firewall will only allow certain traffic from your office PC to remote hosts. Meaning you can only establish FTP, SSH, HTTP, POP3&#8230; communications,  all other ports are blocked.</p>
<p>So how can you access your office PC? One way is to setup corporate VPN access allowing secure connections to internal network. Another method is to setup a port forwarding on corporate firewall so it redirects certain ports to your office PC. But if you don&#8217;t have the means to accomplish any of this then the only way to do it is to use ssh tunnels and reverse port forwarding.</p>
<h2><strong>The solution<br />
</strong></h2>
<p>So if we can only contact remote hosts on certain ports, the solution would be to contact remote hosts via allowed port and piggyback the connection on already established link.</p>
<p><img class="aligncenter size-full wp-image-219" title="reverese-ssh" src="http://images.toic.org/2009/01/reverese-ssh.png" alt="reverese-ssh" width="463" height="271" /></p>
<p>Something like shown on the picture above. Fortunately we can do this with ssh, all we need to do is met some requirements.</p>
<p></p>
<h2><strong>Real life example</strong></h2>
<p>I will assume that home PC is connected via dynamically assigned IP address. First thing you will need to make sure you have ssh server installed on your home PC and it should be accessible from Internet. If you have some NAT routers, be sure to forward port 22 to your home PC. Secondly you will need to setup a dyndns account so you can connect to your home PC regardless of IP address changes. Now the goal will be to connect to ssh server on our office PC. so the port in question will be 22 if you wish to forward another port change it in your configuration accordingly.</p>
<p>For the purpose of this example i will name my home PC: bhome.dyndns.com office computer name will be bwork.office.com</p>
<p>bwork computer uses  private IP range of 192.168.0.0/24 with address 192.168.0.100</p>
<p>So if the firewall is preventing outside connections to our bwork computer we must initiate connection from it.</p>
<p>We can do this with simple ssh command:</p>
<pre>ssh -R 2210:localhost:22 bhome.dyndns.com</pre>
<p>So what just happened here?</p>
<p>We are initiating ssh connection <strong>&#8220;ssh&#8221; </strong>with reverse port forwarding option <strong>&#8220;-R&#8221;</strong> which will then open listening port <strong>&#8220;2210:&#8221;</strong> who is going to be forwarded back to <strong>localhost</strong>&#8216;s  port <strong>&#8220;:22&#8243;</strong> and all this will happen on remote computer <strong>&#8220;bhome.dyndns.com&#8221;</strong>.</p>
<p>This connection represents the green line in the diagram above, and it&#8217;s a legit connection as far as corporate firewall is concerned.</p>
<p>So if we now open up a terminal on <strong>bhome</strong> computer, and type in:</p>
<pre>ssh -p 2210 localhost</pre>
<p>we will try to connect to <strong>localhost</strong> (bhome.dyndns.com) on port <strong>2210</strong>. Since that port is setuped by remote ssh connection it will tunnel the request back via that link to the <strong>bwork.office.com</strong> computer. This is the red line on the diagram above. Looking from firewall&#8217;s perspective it&#8217;s a legit traffic, since it is responding traffic on already initiated link from <strong>bwork</strong> computer.</p>
<h2><strong>Real life example 2</strong></h2>
<p>What if your home computer is not always on-line? Or perhaps you wish to access your office computer from multiple locations? For this you will have to have some dedicated server or VPS outside the corporate firewall.</p>
<p><img class="aligncenter size-full wp-image-225" title="reverese-ssh2" src="http://images.toic.org/2009/01/reverese-ssh2.png" alt="reverese-ssh2" width="463" height="248" />So to accomplish this we will use the same command as previously, only this time we will open up a reverse ssh tunnel to remote server or VPS.</p>
<p>For the purpose of this example we will name the server bserver.outside.com with IP 89.xxx.xx.4</p>
<pre>ssh -R 2210:localhost:22 bserver.outside.com</pre>
<p>again this will open up reverse ssh tunnel to the machine 89.xxx.xx.4 (bserver.outside.com). So when we login to the server and issue the command:</p>
<pre>ssh -p 2210 localhost </pre>
<p>we will end up with bwork computer&#8217;s ssh login prompt.</p>
<h3><strong>Can I use this previously established reverse ssh tunnel to the server to directly connect to my office computer?</strong></h3>
<p><br />
Of course, but some slight modifications are required.</p>
<p>By default ssh tunnels only bind to local address, and can be accessible only locally. Meaning, in the example above, you can&#8217;t just type:</p>
<pre>ssh -p 2210 bserver.outside.com</pre>
<p>on your home PC and be connected to your office PC</p>
<p>If you run:</p>
<pre>netstat -ntl </pre>
<p>on bserver you will see that the port 2210 is only listening on 127.0.0.1 IP address. To get it listen on interface connected to Internet we must enable GatewayPorts option in ssh server&#8217;s configuration.</p>
<p>By default GatewayPorts are disabled in sshd, we can simply enable them:</p>
<pre>nano /etc/ssh/sshd_config</pre>
<p>then add:</p>
<pre>GatewayPorts clientspecified</pre>
<p>save the file and restart sshd:</p>
<pre>/etc/init.d/ssh restart</pre>
<p>we could have just enable GatewayPorts by typing On instead of clientspecified, that would route any ssh tunnel to network interface. This way we can control which tunnel will be accessible from outside, and on which interface.</p>
<p>So if we initiate reverse ssh tunnel like this:</p>
<pre>ssh -R 89.xxx.xx.4:2210:localhost:22 bserver.outside.com</pre>
<p>we will have bserver listening on port 2210 on network interface bound to ip 89.xxx.xx.4 and forwarding all traffic via established tunnel to bwork computer. If you omit the 89.xxx.xx.4 address from the command above server will again listen on port 2210 only on local loopback interface. If you have multiple network interfaces on server be sure to select the one you can connect to.</p>
<p><img class="aligncenter size-full wp-image-226" title="reverese-ssh3" src="http://images.toic.org/2009/01/reverese-ssh3.png" alt="reverese-ssh3" width="504" height="263" />So now when we run:</p>
<pre>ssh -p 2210 bserver.outside.com </pre>
<p>from our home PC we will initiate ssh connection on port 2210 towards server bserver.outside.com (<span style="color: #0000ff;">blue line</span>). Server will then forward that traffic to office PC (<span style="color: #ff0000;">red line</span>) via the previously established reverse ssh tunnel (<span style="color: #008000;">gren line</span>). Of course you will have to open up port 2210 on server&#8217;s firewall to be able to connect.</p>
<p></p>
<h2><strong>Some more fun with reverse tunnels.</strong></h2>
<p>But i have a printer behind that corporate firewall. How can i connect to it? Easy&#8230; remember the first example? the command ssh -R is taking 5 arguments of which 4 are mandatory</p>
<pre>ssh -R [bind_address:]port:host:hostport</pre>
<p><strong>bind_address</strong> is the network address on which <strong>port</strong> will be listening, and forwarded to <strong>host</strong> (connected to network from which reverse tunnel originated) on <strong>hostport</strong>.</p>
<p>so if we issue the command like this on our bwork pc:</p>
<pre>ssh -R 89.xxx.xx.4:2211:192.168.0.10:631 bserver.outside.com</pre>
<p>we will get something like this:</p>
<p><img class="aligncenter size-full wp-image-228" title="reverese-ssh4" src="http://images.toic.org/2009/01/reverese-ssh4.png" alt="reverese-ssh4" width="504" height="305" />so again we have previously established reverse ssh tunnel listening on port 2210 to channel the ssh connection towards office PC. Now with this new command we established the reverse ssh tunnel (<span style="color: #d6d600;">yellow line</span>) towards bserver which will listen for incoming connections on port 2211. When the home pc makes a data connection to port 2211 on bserver (<span style="color: #993300;">brown line</span>) it is then forwarded to office PC (<strong>black line</strong>) which is then redirected towards office printer at address 192.168.0.10 on port 631 (<span style="color: #800080;">violet line</span>). Remember, all this traffic is passing trough corporate firewall as legit traffic, even if the illustration perhaps shows otherwise.</p>
<h2><strong>Automating the task</strong></h2>
<p>So by now we should have covered the basics on how to bypass corporate firewall in order to get to your office computer and network equipment. Now ssh -R isn&#8217;t really practical, it consumes one terminal, and as soon as it shuts down there is no tunnel and no outside connectivity for that matter. The easiest thing to do is putting a cron job that will connect to remote server if the connection fails, office computer reboots etc.</p>
<p>First of all <a href="http://toic.org/2008/11/17/ssh-basics/" target="_blank">generate ssh keys</a>, and add them to ssh-agent so that script won&#8217;t ask you for remote server&#8217;s password all the time.</p>
<p>Next we will add two extra parameters to our command -N and -f so that the connection goes into the background.</p>
<p>the command will look like:</p>
<pre>ssh -N -f -R [bind_address:]port:host:hostport </pre>
<p>next we need a shell script that will be triggered by the cron. For this example we will use the Real life example 2.</p>
<pre>#!/bin/sh
COMMAND="ssh -N -f -R 89.xxx.xx.4:2210:localhost:22 bserver.outside.com"
pgrep -f -x "$COMMAND" &gt; /dev/null 2&gt;&amp;1 || $COMMAND</pre>
<p>now edit this code so it suits your needs, and save it in your home dir as reverse_ssh_tunnel.sh<br />
Now we need to add a crontab entry which will trigger this script every 5 minutes.</p>
<pre>crontab -e</pre>
<p>and add:</p>
<pre>*/5 * * * * /bin/sh /home/username/reverse_ssh_tunnel.sh</pre>
<p>If you are connecting to different user name on remote server you can edit your commands so they look like:<br />
ssh -R [bind_address]:port:host:host_port username@remote_host</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Bypassing+corporate+firewall+with+reverse+ssh+port+forwarding+-+http://bit.ly/h1egD&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://toic.org/2009/01/18/reverse-ssh-port-forwarding/&amp;t=Bypassing+corporate+firewall+with+reverse+ssh+port+forwarding" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://toic.org/2009/01/18/reverse-ssh-port-forwarding/&amp;title=Bypassing+corporate+firewall+with+reverse+ssh+port+forwarding" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Bypassing+corporate+firewall+with+reverse+ssh+port+forwarding&amp;link=http://toic.org/2009/01/18/reverse-ssh-port-forwarding/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://toic.org/2009/01/18/reverse-ssh-port-forwarding/&amp;title=Bypassing+corporate+firewall+with+reverse+ssh+port+forwarding" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://toic.org/2009/01/18/reverse-ssh-port-forwarding/&amp;title=Bypassing+corporate+firewall+with+reverse+ssh+port+forwarding&amp;summary=Probably%20lots%20of%20you%20are%20behind%20some%20sort%20of%20very%20restrictive%20corporate%20firewall.%20Unable%20to%20access%20your%20office%20pc%20from%20home%20because%20of%20firewall%20policies.%20In%20normal%20cases%20this%20scenario%20is%20more%20than%20welcomed.%20No%20outsiders%20should%20be%20allowed%20to%20access%20internal%20parts%20of%20secure%20network%21%20Ideally%20companies%20&amp;source=- [ t o i c . o r g ] -" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://toic.org/2009/01/18/reverse-ssh-port-forwarding/&amp;title=Bypassing+corporate+firewall+with+reverse+ssh+port+forwarding" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://toic.org/2009/01/18/reverse-ssh-port-forwarding/&amp;title=Bypassing+corporate+firewall+with+reverse+ssh+port+forwarding" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Bypassing+corporate+firewall+with+reverse+ssh+port+forwarding&amp;body=Link: http://toic.org/2009/01/18/reverse-ssh-port-forwarding/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Probably%20lots%20of%20you%20are%20behind%20some%20sort%20of%20very%20restrictive%20corporate%20firewall.%20Unable%20to%20access%20your%20office%20pc%20from%20home%20because%20of%20firewall%20policies.%20In%20normal%20cases%20this%20scenario%20is%20more%20than%20welcomed.%20No%20outsiders%20should%20be%20allowed%20to%20access%20internal%20parts%20of%20secure%20network%21%20Ideally%20companies%20" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://toic.org/2009/01/18/reverse-ssh-port-forwarding/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://toic.org/2009/01/18/reverse-ssh-port-forwarding/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://toic.org/2009/01/18/reverse-ssh-port-forwarding/&amp;title=Bypassing+corporate+firewall+with+reverse+ssh+port+forwarding&amp;srcUrl=http://toic.org/2009/01/18/reverse-ssh-port-forwarding/&amp;srcTitle=Bypassing+corporate+firewall+with+reverse+ssh+port+forwarding&amp;snippet=Probably%20lots%20of%20you%20are%20behind%20some%20sort%20of%20very%20restrictive%20corporate%20firewall.%20Unable%20to%20access%20your%20office%20pc%20from%20home%20because%20of%20firewall%20policies.%20In%20normal%20cases%20this%20scenario%20is%20more%20than%20welcomed.%20No%20outsiders%20should%20be%20allowed%20to%20access%20internal%20parts%20of%20secure%20network%21%20Ideally%20companies%20" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-kaevur">
			<a href="http://kaevur.com/submit.php?url=http://toic.org/2009/01/18/reverse-ssh-port-forwarding/" rel="nofollow" class="external" title="Share this on Kaevur">Share this on Kaevur</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://toic.org/2010/02/16/ssh-port-forwarding/' rel='bookmark' title='Permanent Link: SSH port forwarding'>SSH port forwarding</a></li>
<li><a href='http://toic.org/2009/02/01/secure-synergy-setup/' rel='bookmark' title='Permanent Link: Secure synergy setup'>Secure synergy setup</a></li>
<li><a href='http://toic.org/2008/11/17/ssh-basics/' rel='bookmark' title='Permanent Link: SSH basics'>SSH basics</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/TOIC-ORG/~4/sMXNKjWfCnQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://toic.org/2009/01/18/reverse-ssh-port-forwarding/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		<feedburner:origLink>http://toic.org/2009/01/18/reverse-ssh-port-forwarding/</feedburner:origLink></item>
		<item>
		<title>Ubuntu Intrepid on Dell XPS M1530</title>
		<link>http://feedproxy.google.com/~r/TOIC-ORG/~3/L2rCV_NFGQQ/</link>
		<comments>http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 11:17:03 +0000</pubDate>
		<dc:creator>Branko</dc:creator>
				<category><![CDATA[LInux Desktop]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[nvidia]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://toic.org/?p=165</guid>
		<description><![CDATA[By default my Dell xps M1530 came with preinstalled windows vista, Media direct and all those fancy stuff, naturally it all had to go away. For some time I used it with dual boot, and installed Dell Media direct. Naturally I used anything else then Ubuntu so rarely it didn&#8217;t make sense in keeping those [...]


Related posts:<ol><li><a href='http://toic.org/2008/10/03/vodafone-mobile-and-ubuntu/' rel='bookmark' title='Permanent Link: Vodafone mobile and Ubuntu'>Vodafone mobile and Ubuntu</a></li>
<li><a href='http://toic.org/2008/11/24/ajax-problem-in-firefox-on-ubuntu/' rel='bookmark' title='Permanent Link: Ajax problem in Firefox 3 on Ubuntu'>Ajax problem in Firefox 3 on Ubuntu</a></li>
<li><a href='http://toic.org/2009/10/21/howto-create-rsync-server/' rel='bookmark' title='Permanent Link: Howto create rsync server'>Howto create rsync server</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/9LT1ImTlRKMoJSMDv2WNQUqHL4s/0/da"><img src="http://feedads.g.doubleclick.net/~a/9LT1ImTlRKMoJSMDv2WNQUqHL4s/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/9LT1ImTlRKMoJSMDv2WNQUqHL4s/1/da"><img src="http://feedads.g.doubleclick.net/~a/9LT1ImTlRKMoJSMDv2WNQUqHL4s/1/di" border="0" ismap="true"></img></a></p><p>By default my Dell xps M1530 came with preinstalled windows vista, Media direct and all those fancy stuff, naturally it all had to go away. For some time I used it with dual boot, and installed Dell Media direct. Naturally I used anything else then Ubuntu so rarely it didn&#8217;t make sense in keeping those stuff around no more. I decided to reformat everything and dedicate every last byte of available resources on my laptop to Ubuntu. While doing so I will try to keep a track in this post of everything that I do/install on my system so it would work perfectly with all available features.</p>
<p>Please note that following this guide from beginning to the end will most certainly erase all your data. So if you aren&#8217;t ready to make a full clean install please skip few first steps.</p>
<h2><strong>Step 1. Preparing for fresh install </strong></h2>
<h3><strong>1.A backing up existing data.</strong></h3>
<p>If you already used Ubuntu on your laptop and you actually want to reinstall your system but remain all current functionality you should backup your data.<br />
<span id="more-165"></span><br />
First thing you want to do is backup your existing home directory. Make sure you have enough disk space to archive your data on home partition.</p>
<p></p>
<p>To backup your home dir open gnome terminal and type in:</p>
<pre>cd /home/
tar -czvf homedir.tar.gz *</pre>
<p>it should take some time before archive is complete so go grab some cup of coffee, take your dog for a walk&#8230;</p>
<p>After it&#8217;s done copy your archive to some off site storage since your entire disk will be erased (yes no partition will remain intact).</p>
<p>You should also make a list of currently installed packages. List will be later used to repopulate your new system with currently used software.</p>
<p>To do so type in gnome terminal:</p>
<pre>sudo dpkg --get-selections >   package.selections
</pre>
<p>Now copy that file to off site storage to since we will need it after we are done reinstalling the system.</p>
<p>If you have some third-party software sources enabled backup your sources list file <em><strong>/etc/apt/sources.list</strong></em></p>
<p>and files in <em><strong>/etc/apt/sources.list.d/</strong></em> folder</p>
<blockquote><p><strong><span style="color: #ff0000;">Note:</span></strong> this will not backup your internal mysql databases, websites and other software or data not managed trough packet manager or located beyond /home folder.</p></blockquote>
<h3><strong>1.B removing all the content</strong></h3>
<p>Why so drastic measure? Simple, Dell uses hidden HPA partition used by Dell Media Direct button to boot up Media direct. Thing is.. if there is no media direct partition, that hidden partition and it&#8217;s boot up process will a) overwrite your current grub conf and b) rewrite your partition table in unforeseeable ways. Some like to call this button a Dell self-destruct button, since it renders your Linux installation useless if it can&#8217;t find what it&#8217;s looking for. For a better understanding of Dell&#8217;s Media Direct button functionality take a look <a href="http://www.goodells.net/dellrestore/mediadirect.htm" target="_blank">here</a>.</p>
<p>So how to render it ineffective? Simply do a low level format of you hard drive, it will rewrite HPA partition with zeros thus disabling self-destruct function from Media direct button.</p>
<blockquote><p><span style="color: #ff0000;"><span style="text-decoration: underline;"><strong>Be aware this will erase all your data currently residing on laptop&#8217;s hard disk!!!</strong></span></span></p></blockquote>
<p>To format your drive, boot up with your installation cd, don&#8217;t select to install your Ubuntu just yet, use the option to try Ubuntu without modifying current system. After boot up open gnome terminal and write:</p>
<pre>sudo dd if=/dev/zero of=/dev/sda</pre>
<p>Again, it will take some time.</p>
<h2><strong>Step 2 &#8211; Installation</strong></h2>
<p>Since installation is actually pretty straightforward there is no real need to guide you trough entire process. I will suggest though that you make your own custom partitioning. By default Ubuntu will make only one partition for system and data, and one swap partition. I suggests that you make at least one more on mount point <strong>/home</strong>. That way next time you have to reinstall the system you will only format the system partition, leave home partition intact and thus preserving all your configuration and personal data.</p>
<p>You will have to make root partition<strong> /</strong> <strong>swap</strong> partition (usualy 2x the amount of ram installed), and <strong>/home</strong> partition. I will leave the sizes allocation to your own discretion.</p>
<h2><strong>Step 3 &#8211; Post installation configuration</strong></h2>
<h3><strong>3.A &#8211; Touch pad</strong></h3>
<p>If you have already upgraded your bios first thing you will probably notice is touch pad not working properly. If you are without external mouse this can be pain in the ass so let&#8217;s fix that first.</p>
<p>Push <em><strong><alt>+F2</alt></strong></em> type in <em><strong>gnome-terminal</strong></em> and hit OK.</p>
<p>Now type in:</p>
<pre>sudo pico /boot/grub/menu.lst</pre>
<p>find:</p>
<pre>## additional options to use with the default boot option, but not with the 

## alternatives

## e.g. defoptions=vga=791 resume=/dev/hda5

# defoptions=quiet splash</pre>
<p>and add to defoptions line i8042.nomux=1 so it looks like this:</p>
<pre>## additional options to use with the default boot option, but not with the 

## alternatives

## e.g. defoptions=vga=791 resume=/dev/hda5

# defoptions=quiet splash i8042.nomux=1</pre>
<p>Save and close the file and type:</p>
<pre>sudo update-grub</pre>
<p>Reboot your system and your touch pad should work. Yes it works, but I found it to be a little rough to say at least.</p>
<p>Again open your terminal, type in:</p>
<pre>sudo pico /etc/X11/xorg.conf</pre>
<p>add the following:</p>
<pre>Section "InputDevice"

Identifier "Mouse0"

Driver "synaptics"

Option "SendCoreEvents" "true"

Option "Device" "/dev/psaux"

Option "Protocol" "auto-dev"

Option "ZAxisMapping" "4 5"

Option "Emulate3Buttons" "on"

Option "SHMConfig" "on"

Option "VertEdgeScroll" "on"

Option "VertTwoFingerScroll" "on"

Option "LeftEdge" "85"

Option "RightEdge" "910"

Option "TopEdge" "85"

Option "BottomEdge" "715"

Option "FingerLow" "25"

Option "FingerHigh" "30"

Option "MaxTapTime" "180"

Option "MaxTapMove" "220"

EndSection</pre>
<p>Save &#038; exit, restart your GDM with </p>
<pre>ctrl+alt+backspace</pre>
<h3><strong>3.B &#8211; Updates</strong></h3>
<p>Now that you have your touch pad operational, you should probably check for updates and install them.</p>
<p>Go to <strong>System > Administration > Update manager</strong></p>
<p>Check for updates, install them if any. You will probably need to reboot into new kernel.</p>
<h3><strong>3.C 	- installing proprietary drivers </strong></h3>
<p>If you wish your system to run 3D graphics, connect to wireless you should install additional hardware drivers. Go to: <strong>System > Administration > Hardware drivers</strong></p>
<p>Select and install latest <em><strong>Nvidia 177</strong></em> and <em><strong>Broadcom B43</strong></em> wireless driver</p>
<p>You don&#8217;t really need to reboot after each installed driver, but it is advisable after you installed them both.</p>
<h3><strong>3.D &#8211; fingerprint reader</strong></h3>
<p>There is actually two options to get fingerprint reader to work, since Dell&#8217;s fingerprint reader isn&#8217;t an imaging reader at the time it seamed to be best to install Thinkfinger. You can also try to install fprint reader.</p>
<p>To install Thinkfinger you will have to add following lines to your sources.list</p>
<pre>sudo pico /etc/apt/sources.list</pre>
<p>add:</p>
<pre>deb http://ppa.launchpad.net/jon-oberheide/ubuntu intrepid main
deb-src http://ppa.launchpad.net/jon-oberheide/ubuntu intrepid main
</pre>
<p>then do</p>
<pre>sudo apt-get update

sudo apt-get install thinkfinger-tools libpam-thinkfinger</pre>
<p>All we need to do now is test it:</p>
<pre>sudo tf-tool --acquire</pre>
<p>It will ask your fingerprint 3 times or more if there is failed scans. After you have done 3 successful scans, it will save your biometric readings in <em><strong>/home/user/.thinkfinger.bin</strong></em></p>
<p>Verify your fingerprint will be recognized</p>
<pre>sudo tf-tool --verify</pre>
<p>If it&#8217;s ok it should look something like this:</p>
<pre>Please swipe your finger (successful swipes 1/1, failed swipes: 0)... done. 

Result: Fingerprint does match.</pre>
<p>To use it every day modify <em><strong>/etc/pam.d/common-auth</strong></em></p>
<pre>sudo pico /etc/pam.d/common-auth</pre>
<p>add the following line before other auth lines:</p>
<pre>auth    sufficient      pam_thinkfinger.so</pre>
<p>it should look something like this:</p>
<pre>...

auth    sufficient      pam_thinkfinger.so

# here are the per-package modules (the "Primary" block) 

auth    [success=1 default=ignore]      pam_unix.so nullok_secure 

...</pre>
<p>After rebooting you should be able to use either your password or your fingerprint to authorize yourself.</p>
<h3><strong>3.E &#8211; internal microphone </strong></h3>
<p>It&#8217;s pretty simple actually, all you have to do is:</p>
<p><em><strong>1. Double-click the volume control icon in the top right of the screen.<br />
2. Select Edit / Preferences.<br />
3. Add &#8220;Digital&#8221; and &#8220;Digital Input Source&#8221; to the list of visible tracks.<br />
4. On the Options tab, select &#8220;Digital Mic 1&#8243; for &#8220;Digital Input Source&#8221;.<br />
5. On the Recording tab, set the volume for the microphone.</strong></em></p>
<p>You can test it out with Sound recorder: <strong><em>Applications > Sound &#038; Video > Sound Recorder</em></strong></p>
<h3><strong>3.F &#8211; webcam</strong></h3>
<p>By default webcam is working with skype, ekiga etc. except with cheese, there is bugreport at: <a href="https://bugs.launchpad.net/ubuntu/+source/cheese/+bug/290506">https://bugs.launchpad.net/ubuntu/+source/cheese/+bug/290506</a></p>
<p>It will however work with low resolutions like 352 x 288 and lower.</p>
<p>[edit@Jan 9, 2009]:</p>
<p>As of today there is an proposed update of cheese and kernel that addresses this previously mentioned bug. After fully upgrading your system cheese should work without any problems on all resolutions</p>
<p>[/edit]</p>
<p>From hardware point of view this is more or less everything you will need. Card reader will work automatically, mobile broadband with new network manager also. New Ubuntu Intrepid will even recognize multi purpose usb sticks like that Vodafones Huawei stick described in <a href="http://toic.org/2008/10/03/vodafone-mobile-and-ubuntu/" target="_blank">previous post</a>.</p>
<h3><strong>3.G &#8211; power savings</strong></h3>
<p>I use laptop-mode to do my power-savings, right now I won&#8217;t get into tips and tricks of power savings for laptops running Linux, maybe in another post in near future. For now all you need to know is it&#8217;s now a great time to check out your hard disk and its current behavior of head parking and tweak it if necessary. Long story short, new laptop hard drives can park its head when not in use. By default they park it very often when on battery and less often when on AC. In general this is a good thing since if your laptop is to suffer some physical trauma while on battery if the hard disk head is parked it will minimize the possibility of data loss. On the other hand head parking ability is not unlimited, it&#8217;s usually a number of about 600 000 head parks. One may say it&#8217;s a high number, but with default settings it will give your hard disk lifespan for about 6 months.</p>
<p>A quick view on current status:</p>
<pre>sudo apt-get install smartmontools

date; sudo smartctl -a /dev/sda | egrep '(Load_Cycle_Count|Temperature)'</pre>
<p>wait about 15 min on battery then issue the command above again:</p>
<pre>date; sudo smartctl -a /dev/sda | egrep '(Load_Cycle_Count|Temperature)'</pre>
<p>First line, last numberr will show Load Cycle count (head parks). If number is growing to fast consider doing steps as described in this post: <a href="http://ubuntuforums.org/showthread.php?t=795327">http://ubuntuforums.org/showthread.php?t=795327</a> even if your disk or laptop model is not on the list.</p>
<h2><strong>Step 4 &#8211; restoring backed up data</strong></h2>
<p>If you did make steps for backing up the data in step 1.A now is a good time to restore them.</p>
<p>First you will need to reinstall all those custom packages. If you had custom third-party software sources in your <em><strong>/etc/apt/sources.list</strong></em> file or <em><strong>/etc/atp/sources.list.d/</strong></em> directory restore them now and update the lines so they match new intrepid installation.</p>
<p>Copy yours <strong>package.selections</strong> file from remote storage to <strong>/home</strong> folder , and issue the following command:</p>
<pre>sudo dpkg --set-selections < /home/package.selections &#038;&#038; apt-get dselect-upgrade</pre>
<p>This will take some time since apt will have to re-download and install all the additional software you used. When it's done copy your home folder backed up archive to <strong>/home</strong> and unpack it with:</p>
</pre>
<pre>tar -xzvf homedir.tar.gz</pre>
<p>Now log out and log back in. Everything should be the way you remember it.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Ubuntu+Intrepid+on+Dell+XPS+M1530++-+http://bit.ly/GQwt5&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/&amp;t=Ubuntu+Intrepid+on+Dell+XPS+M1530+" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/&amp;title=Ubuntu+Intrepid+on+Dell+XPS+M1530+" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Ubuntu+Intrepid+on+Dell+XPS+M1530+&amp;link=http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/&amp;title=Ubuntu+Intrepid+on+Dell+XPS+M1530+" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/&amp;title=Ubuntu+Intrepid+on+Dell+XPS+M1530+&amp;summary=By%20default%20my%20Dell%20xps%20M1530%20came%20with%20preinstalled%20windows%20vista%2C%20Media%20direct%20and%20all%20those%20fancy%20stuff%2C%20naturally%20it%20all%20had%20to%20go%20away.%20For%20some%20time%20I%20used%20it%20with%20dual%20boot%2C%20and%20installed%20Dell%20Media%20direct.%20Naturally%20I%20used%20anything%20else%20then%20Ubuntu%20so%20rarely%20it%20didn%27t%20make%20sense%20in%20keeping%20th&amp;source=- [ t o i c . o r g ] -" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/&amp;title=Ubuntu+Intrepid+on+Dell+XPS+M1530+" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/&amp;title=Ubuntu+Intrepid+on+Dell+XPS+M1530+" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Ubuntu+Intrepid+on+Dell+XPS+M1530+&amp;body=Link: http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A By%20default%20my%20Dell%20xps%20M1530%20came%20with%20preinstalled%20windows%20vista%2C%20Media%20direct%20and%20all%20those%20fancy%20stuff%2C%20naturally%20it%20all%20had%20to%20go%20away.%20For%20some%20time%20I%20used%20it%20with%20dual%20boot%2C%20and%20installed%20Dell%20Media%20direct.%20Naturally%20I%20used%20anything%20else%20then%20Ubuntu%20so%20rarely%20it%20didn%27t%20make%20sense%20in%20keeping%20th" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/&amp;title=Ubuntu+Intrepid+on+Dell+XPS+M1530+&amp;srcUrl=http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/&amp;srcTitle=Ubuntu+Intrepid+on+Dell+XPS+M1530+&amp;snippet=By%20default%20my%20Dell%20xps%20M1530%20came%20with%20preinstalled%20windows%20vista%2C%20Media%20direct%20and%20all%20those%20fancy%20stuff%2C%20naturally%20it%20all%20had%20to%20go%20away.%20For%20some%20time%20I%20used%20it%20with%20dual%20boot%2C%20and%20installed%20Dell%20Media%20direct.%20Naturally%20I%20used%20anything%20else%20then%20Ubuntu%20so%20rarely%20it%20didn%27t%20make%20sense%20in%20keeping%20th" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-kaevur">
			<a href="http://kaevur.com/submit.php?url=http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/" rel="nofollow" class="external" title="Share this on Kaevur">Share this on Kaevur</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://toic.org/2008/10/03/vodafone-mobile-and-ubuntu/' rel='bookmark' title='Permanent Link: Vodafone mobile and Ubuntu'>Vodafone mobile and Ubuntu</a></li>
<li><a href='http://toic.org/2008/11/24/ajax-problem-in-firefox-on-ubuntu/' rel='bookmark' title='Permanent Link: Ajax problem in Firefox 3 on Ubuntu'>Ajax problem in Firefox 3 on Ubuntu</a></li>
<li><a href='http://toic.org/2009/10/21/howto-create-rsync-server/' rel='bookmark' title='Permanent Link: Howto create rsync server'>Howto create rsync server</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/TOIC-ORG/~4/L2rCV_NFGQQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://toic.org/2008/12/29/ubuntu-intrepid-on-dell-xps-m1530/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 1.884 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-07-16 08:45:37 -->
