<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mudy&#039;s Blog</title>
	<atom:link href="https://blog.mudy.info/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.mudy.info</link>
	<description>Linux, webserver, hosting and more</description>
	<lastBuildDate>Sat, 24 Dec 2016 02:13:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.7.12</generator>
	<item>
		<title>IPv6 Day</title>
		<link>https://blog.mudy.info/2011/06/ipv6-day/</link>
		<comments>https://blog.mudy.info/2011/06/ipv6-day/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 04:00:36 +0000</pubDate>
		<dc:creator><![CDATA[mudy]]></dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[ipv6]]></category>

		<guid isPermaLink="false">http://blog.mudy.info/?p=823</guid>
		<description><![CDATA[Today both google and facebook turn on their IPv6 addresses in their DNS servers for one day. C:>ping www.google.com Pinging www.l.google.com [2001:4860:800c::93] with 32 bytes of data: Reply from 2001:4860:800c::93: time=29ms Reply from 2001:4860:800c::93: time=32ms Reply from 2001:4860:800c::93: time=68ms Reply &#8230;<p class="read-more"><a href="https://blog.mudy.info/2011/06/ipv6-day/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>Today both google and facebook turn on their IPv6 addresses in their DNS servers for one day.</p>
<pre>C:>ping www.google.com

Pinging www.l.google.com [2001:4860:800c::93] with 32 bytes of data:
Reply from 2001:4860:800c::93: time=29ms
Reply from 2001:4860:800c::93: time=32ms
Reply from 2001:4860:800c::93: time=68ms
Reply from 2001:4860:800c::93: time=28ms

Ping statistics for 2001:4860:800c::93:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 28ms, Maximum = 68ms, Average = 39ms

C:>ping www.facebook.com

Pinging www.facebook.com [2620:0:1c00:0:face:b00c:0:2] with 32 bytes of data:
Reply from 2620:0:1c00:0:face:b00c:0:2: time=102ms
Reply from 2620:0:1c00:0:face:b00c:0:2: time=125ms
Reply from 2620:0:1c00:0:face:b00c:0:2: time=94ms
Reply from 2620:0:1c00:0:face:b00c:0:2: time=95ms

Ping statistics for 2620:0:1c00:0:face:b00c:0:2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 94ms, Maximum = 125ms, Average = 104ms</pre>
<p><a href="http://www.worldipv6day.org/">More Information</a></p>
<p>My ISP timewarner cable does not support native ipv6 yet, so I am still using <a href="http://tunnelbroker.net/">he tunnelbroker</a> for my home connection. Nonetheless it works pretty well. </p>
<p>Both most recent <a href="http://www.4shared.com/dir/v1BuINP3/Toastman_Builds.html">Tomato Firmware</a> and <a href="http://openwrt.org/">Openwrt </a>trunk version have built-in 6in4 and 6to4 support.</p>
<p>Update 1:  <a href="http://test-ipv6.com/">http://test-ipv6.com/</a><br />
<a href="/wp-content/uploads/2011/06/Y8PjG.png"><img src="/wp-content/uploads/2011/06/Y8PjG-300x145.png" alt="" title="test-ipv6.com" width="300" height="145" class="aligncenter size-medium wp-image-832" /></a></p>
<p>Update 2: <a href="http://ipv6-test.com/">http://ipv6-test.com/</a><br />
<a href="/wp-content/uploads/2011/06/6a894af42be3265d66de53d1e63f8124.png"><img src="/wp-content/uploads/2011/06/6a894af42be3265d66de53d1e63f8124.png" alt="" title="ipv6-test.com" width="300" height="135" class="aligncenter size-full wp-image-845" /></a></p>
]]></content:encoded>
			<wfw:commentRss>https://blog.mudy.info/2011/06/ipv6-day/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Source address route with multiple IPv6 addresses</title>
		<link>https://blog.mudy.info/2011/05/source-address-route-with-multiple-ipv6-addresses/</link>
		<comments>https://blog.mudy.info/2011/05/source-address-route-with-multiple-ipv6-addresses/#comments</comments>
		<pubDate>Mon, 23 May 2011 00:02:08 +0000</pubDate>
		<dc:creator><![CDATA[mudy]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mudy.info/?p=809</guid>
		<description><![CDATA[I always had ipv6 tunneling enabled on my server. One with he.net and one with 6to4. I never had any problems with them with either as a default route. Recently my server provider linode.com start supporting native IPv6, but I &#8230;<p class="read-more"><a href="https://blog.mudy.info/2011/05/source-address-route-with-multiple-ipv6-addresses/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>I always had ipv6 tunneling enabled on my server. One with <a href="http://tunnelbroker.net/">he.net</a> and one with <a href="http://en.wikipedia.org/wiki/6to4">6to4</a>. I never had any problems with them with either as a default route. Recently my server provider <a href="http://www.linode.com/?r=9464c622b468bb1f04a03dc4e5cd1896df0863c7">linode.com</a> start supporting native IPv6, but I found out other IP addresses are not route-able through native interface. Linux is only smart enough to pick which source address to use for outgoing connection, but not so much about return path. </p>
<p>The solution is <a href="http://en.wikipedia.org/wiki/Policy-based_routing">policy based routing</a> with IPv6. There are two related options in kernel configure, so make sure they are enabled. If not, you will encounter an error. </p>
<p>First install <a href="http://en.wikipedia.org/wiki/Iproute2">iproute2</a> and add a new route table.</p>
<pre lang="bash">echo "200 to4" >> /etc/iproute2/rt_tables</pre>
<p>Then you can add source based rules and routes to this table.</p>
<pre lang="bash">ip -6 rule add from 2002::/16 table to4
ip -6 route add 2002::/16 dev 6to4 table to4
ip -6 route add default via ::192.88.99.1 dev 6to4 table to4</pre>
<p>One thing I am still not sure is whether to delete the 2002::/16 from main route table. </p>
<pre>ip -6 route del 2002::/16</pre>
<p>I think this can solve some stateful firewall problem, but not necessary.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.mudy.info/2011/05/source-address-route-with-multiple-ipv6-addresses/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Add QR code to Tumblr Posts</title>
		<link>https://blog.mudy.info/2010/10/add-qr-code-to-tumblr-posts/</link>
		<comments>https://blog.mudy.info/2010/10/add-qr-code-to-tumblr-posts/#respond</comments>
		<pubDate>Mon, 25 Oct 2010 04:45:33 +0000</pubDate>
		<dc:creator><![CDATA[mudy]]></dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[qr code]]></category>
		<category><![CDATA[tumblr]]></category>

		<guid isPermaLink="false">http://blog.mudy.info/?p=801</guid>
		<description><![CDATA[It&#8217;s super simple to add a QR code to each Tumblr post. Just add this to anywhere between {block:posts} in your custom template. {block:posts} &#60;img src="http://chart.apis.google.com/chart?cht=qr&#38;chs=116x116&#38;chl={ShortURL}"/&#62; {/block:posts} Here is an Example on my tumblr.]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s super simple to add a QR code to each <a href="http://www.tumblr.com/">Tumblr </a> post. Just add this to anywhere between {block:posts} in your custom template.</p>
<pre>{block:posts}
&lt;img src="http://chart.apis.google.com/chart?cht=qr&amp;chs=116x116&amp;chl={ShortURL}"/&gt;
{/block:posts}</pre>
<p>Here is an <a href="http://yejun.me/">Example</a> on my tumblr.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.mudy.info/2010/10/add-qr-code-to-tumblr-posts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CloudFlare free cdn service</title>
		<link>https://blog.mudy.info/2010/10/cloudflare-free-cdn-service/</link>
		<comments>https://blog.mudy.info/2010/10/cloudflare-free-cdn-service/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 20:28:20 +0000</pubDate>
		<dc:creator><![CDATA[mudy]]></dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[cdn]]></category>
		<category><![CDATA[cloudflare]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.mudy.info/?p=782</guid>
		<description><![CDATA[CloudFlare is a new cloud service which provides free website security and caching. A quick test revealed that it uses anycast geodns technology with nginx reverse caching. The setup process is very easy. You only need to change DNS server &#8230;<p class="read-more"><a href="https://blog.mudy.info/2010/10/cloudflare-free-cdn-service/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p><a href="https://www.cloudflare.com/">CloudFlare </a>is a new cloud service which provides free website security and caching. A quick <a href="http://p.aaronyy.com/">test </a>revealed that it uses anycast geodns technology with nginx reverse caching.</p>
<p><P>The setup process is very easy. You only need to change DNS server from domain registry. Setup wizard will automatically import old DNS setting. However multi tiered sub domain won&#8217;t be detected. Both CNAME and A host will be proxyed through by default.</p>
<p>Once DNS change finished, your website will be severed with transparent proxies. Unwanted visitor will be screened and static assets will be cached.</p>
<p><!--11dbcaca0ffc49b6a355ce5f89a104bc--><br />
Here is the page loading timeline of my <a href="http://p.aaronyy.com/">test page</a><br />
<b>Without CloudFlare</b><br />
<a href="/wp-content/uploads/2010/10/withoutcloudflare.png"><img src="/wp-content/uploads/2010/10/withoutcloudflare-300x122.png" alt="Without CloudFlare" title="Without CloudFlare" width="300" height="122" class="aligncenter size-medium wp-image-783" /></a><br />
<b>With CloudFlare</b><br />
<a href="/wp-content/uploads/2010/10/withcloudflare.png"><img src="/wp-content/uploads/2010/10/withcloudflare-300x110.png" alt="With CloudFlare" title="With CloudFlare" width="300" height="110" class="aligncenter size-medium wp-image-784" /></a><br />
The page is very simple, but still it clearly shows there&#8217;s no measurable latency with dynamic contents and notable improvement with static assets. However text assets like html, css and js have slightly bigger size. My original is compressed with gzip -9.</p>
<h3>Pro:</h3>
<ul>
<li>Anycast GeoDNS hosting</li>
<li>Vistor security screen</li>
<li>Slick analytics</li>
<li>Transparent caching around world</li>
<li>Basic account is free</li>
<li>Very easy to setup</li>
</ul>
<h3>Con:</h3>
<ul>
<li>Http only, no video streaming</li>
<li>Slow in Asia </li>
<li>Suboptimal gzip compression ratio</li>
</ul>
<p>Overall I am very impressed with the free features and performance.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.mudy.info/2010/10/cloudflare-free-cdn-service/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Simple OpenID Login Example on Appengine</title>
		<link>https://blog.mudy.info/2010/10/a-simple-openid-login-example/</link>
		<comments>https://blog.mudy.info/2010/10/a-simple-openid-login-example/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 09:24:30 +0000</pubDate>
		<dc:creator><![CDATA[mudy]]></dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[openid]]></category>
		<category><![CDATA[openid selector]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.mudy.info/?p=766</guid>
		<description><![CDATA[I wrote a simple openid login example. I used user api to do the real login. Here is source code. The idea is very simple. Instead of redirecting main page, I use javascript to popup a small page. Most providers &#8230;<p class="read-more"><a href="https://blog.mudy.info/2010/10/a-simple-openid-login-example/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>I wrote a simple openid login example.
</p>
<p>
I used <a href="http://code.google.com/appengine/docs/python/users/loginurls.html">user api</a> to do the real login.<br />
<a href="http://www.simpleopenid.com/"><img src="/wp-content/uploads/2010/10/loginbuttons.png" alt="Login Buttons" title="Login Buttons" width="356" height="226" class="aligncenter size-full wp-image-767" /></a>
</p>
<p>
Here is <a href="http://github.com/yejun/gaeopenid">source code</a>.
</p>
<p> The idea is very simple. Instead of redirecting main page, I use javascript to popup a small page. Most providers have webpage optimized for popup. Then this page will detect callback and refresh main page and close itself. A hidden iframe will also try previous login url if available.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.mudy.info/2010/10/a-simple-openid-login-example/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Integrate open graph with tumblr</title>
		<link>https://blog.mudy.info/2010/10/integrate-open-graph-with-tumblr/</link>
		<comments>https://blog.mudy.info/2010/10/integrate-open-graph-with-tumblr/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 19:41:41 +0000</pubDate>
		<dc:creator><![CDATA[mudy]]></dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[like]]></category>
		<category><![CDATA[likebutton]]></category>
		<category><![CDATA[opengraphprotocol]]></category>
		<category><![CDATA[tumblr]]></category>

		<guid isPermaLink="false">http://blog.mudy.info/?p=746</guid>
		<description><![CDATA[Facebook Like button relies on Open Graph protocol to provide site information such as name, image and title. With tumblr&#8216;s custom HTML theme, you can integrate open graph protocol in your theme. When user click on a like button, facebook &#8230;<p class="read-more"><a href="https://blog.mudy.info/2010/10/integrate-open-graph-with-tumblr/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>Facebook <a href="http://developers.facebook.com/docs/reference/plugins/like">Like button</a> relies on <a href="http://developers.facebook.com/docs/opengraph">Open Graph protocol</a> to provide site information such as name, image and title.</p>
<p>With <a href="http://www.tumblr.com/">tumblr</a>&#8216;s <a href="http://www.tumblr.com/docs/en/custom_themes">custom HTML theme</a>, you can integrate open graph protocol in your theme. When user click on a like button, facebook will display your real site name instead of domain itself. If it is a photo post, in activity stream a nice thumbnail will be displayed.</p>
<p>My test page<br />
<img src="/wp-content/uploads/2010/10/fbactivitywithog2.png" alt="Facebook with open graph" title="Facebook with open graph" width="276" height="193" class="aligncenter size-full wp-image-763" /></a></p>
<p>Here is a tumblr theme fragment which includes required items. I also uploaded images for all post types.</p>
<pre lang="html"><meta property="og:site_name" content="{Title}" />
<meta property="fb:app_id" content="FACEBOOK_APPID"/>
<meta property="fb:admins" content="FACEBOOK_USERID" />
{block:IndexPage}
    <meta property="og:image" content="{PortraitURL-128}" />
    <meta property="og:title" content="{Title}" />
    <meta property="og:type" content="blog" />
    <meta property="og:url" content="YOUR_SITE_URL" />
{/block:IndexPage}
{block:PostSummary}
    <meta property="og:title" content="{PlaintextPostSummary}" />
{/block:PostSummary}
{block:Permalink}
  <meta property="og:type" content="article" />
  <meta property="og:url" content="{Permalink}" />
  {block:Posts}
      {block:Text}
        <meta property="og:image" content="http://static.tumblr.com/vswwmyc/mmHla8c7g/text.png"/>
      {/block:Text}
      {block:Photo}
        <meta property="og:image" content="{PhotoURL-500}"/>
      {/block:Photo}
      {block:Photoset}
        <meta property="og:image" content="http://static.tumblr.com/vswwmyc/ACBla8cb5/photo.png"/> 
      {/block:Photoset}
      {block:Quote}
        <meta property="og:image" content="http://static.tumblr.com/vswwmyc/kahla8ccw/quote.png"/>
      {/block:Quote}
      {block:Link}
        <meta property="og:image" content="http://static.tumblr.com/vswwmyc/K6Vla8cek/link.png"/>
      {/block:Link}
      {block:Chat}
        <meta property="og:image" content="http://static.tumblr.com/vswwmyc/9Ysla8cgl/chat.png"/>
      {/block:Chat}
      {block:Video}
        <meta property="og:image" content="http://static.tumblr.com/vswwmyc/KiUla8chx/video.png"/>
      {/block:Video}
      {block:Audio}
        <meta property="og:image" content="http://static.tumblr.com/vswwmyc/FyZla8c36/audio.png"/>
      {/block:Audio}
      {block:Answer}
        <meta property="og:image" content="{AskerPortraitURL-128}"/>
      {/block:Answer}
    {/block:Posts}
{/block:Permalink}
</pre>
<p>If you use <a href="http://disqus.com/">Disqus </a>comments system, you probably already have a facebook app id. You can find out both your app id and user id on facebook <a href="http://www.facebook.com/insights/">insights page</a>. When you click &#8220;Insights for your Domain&#8221;, you will see a list of your apps and yourself. If you select any of them, the correct meta tag will be displayed.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.mudy.info/2010/10/integrate-open-graph-with-tumblr/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Boot grub2 stage2 directly from windows bootmgr with grub4dos stage1</title>
		<link>https://blog.mudy.info/2010/08/boot-grub2-stage2-directly-from-windows-bootmgr-with-grub4dos-stage1/</link>
		<comments>https://blog.mudy.info/2010/08/boot-grub2-stage2-directly-from-windows-bootmgr-with-grub4dos-stage1/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 17:33:55 +0000</pubDate>
		<dc:creator><![CDATA[mudy]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mudy.info/?p=733</guid>
		<description><![CDATA[There is problem which has been puzzled me for long time. When the grub2 root is on 2nd disk, the stage2 is not directly bootable from grub4dos stage1, but can be chain loaded from grub4dos as a linux kernel. The &#8230;<p class="read-more"><a href="https://blog.mudy.info/2010/08/boot-grub2-stage2-directly-from-windows-bootmgr-with-grub4dos-stage1/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>There is problem which has been puzzled me for long time. When the <a href="http://www.gnu.org/software/grub/">grub2 </a>root is on 2nd disk, the stage2 is not directly bootable from <a href="http://gna.org/projects/grub4dos/">grub4dos </a>stage1, but can be chain loaded from grub4dos as a linux kernel. The same problem happens to <a href="http://code.google.com/p/burg/">burg </a>as well.</p>
<p>It turns out the stage2 file only has the relative path from root if you use grub-install script. So all you have to do is to embed a absolute path in prefix. Here is the brief step to make a direct bootable stage2.</p>
<pre>grub-mkimage --output=/boot/grub/core.img --prefix=<strong>(hd1,2)</strong>/boot/grub 
         biosdisk part_msdos ext2
cat /boot/grub/lnxboot.img /boot/grub/core.img > g2ldr</pre>
<p>Now copy g2ldr to your windows&#8217; partition. Make a grub4dos stage1 file</p>
<pre>grubinst.exe -o -b=g2ldr g2ldr.mbr</pre>
<p>You can find grubinst.exe from grub4dos website.</p>
<p>Add it to windows bootmgr with bcdedit</p>
<pre>bcdedit /create /d Linux /application BOOTSECTOR
bcdedit /set {ID} device partition=c:
bcdedit /set {ID}  path g2ldr.mbr
bcdedit /displayorder {ID} /addlast</pre>
]]></content:encoded>
			<wfw:commentRss>https://blog.mudy.info/2010/08/boot-grub2-stage2-directly-from-windows-bootmgr-with-grub4dos-stage1/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Linux container LXC on Amazon EC2 server (Cloud inside Cloud)</title>
		<link>https://blog.mudy.info/2010/07/linux-container-on-amazon-ec2-server/</link>
		<comments>https://blog.mudy.info/2010/07/linux-container-on-amazon-ec2-server/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 23:28:40 +0000</pubDate>
		<dc:creator><![CDATA[mudy]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[ami]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[lxc]]></category>
		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://blog.mudy.info/?p=704</guid>
		<description><![CDATA[Amazon AWS announced supporting pvgrub kernel a week ago. So it is possible to run your own kernel with new features like btrfs, cgroup, namespace, high resolution timers. Just be aware the AWS still use a very ancient xen version, &#8230;<p class="read-more"><a href="https://blog.mudy.info/2010/07/linux-container-on-amazon-ec2-server/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>Amazon AWS <a href="http://aws.typepad.com/aws/2010/07/use-your-own-kernel-with-amazon-ec2.html">announced</a> supporting pvgrub kernel a week ago. So it is possible to run your own kernel with new features like btrfs, cgroup, namespace, high resolution timers.  Just be aware the AWS still use a very ancient xen version, so you will need to patch stock kernel to be bootable.</p>
<p>Here is a step by step guide on how to setup a <a href="http://lxc.sourceforge.net/">linux container </a>on top of EC2. Since EC2 itself is virtual environment, it is almost impossible to run other vm technology on top of it. You can read these general guide [<a href="http://lxc.teegra.net/">1</a>] [<a href="http://www.ibm.com/developerworks/linux/library/l-lxc-containers/">2</a>] on how to setup a linux container. </p>
<h3>Step 1: Host VM</h3>
<p>In order to run lxc, the host will need to support cgroup and namespace. Ubuntu 10.4 lucid or newer includes them. I also made two public archlinux AMIs which support all these features, you can find them <a href="http://blog.mudy.info/2009/04/archlinux-ec2-public-ami/">here</a>.<br />
Mount up /cgroup,</p>
<pre>mkdir /cgroup
mount -t cgroup none /cgroup</pre>
<p>In order for network to work you will need these two packages: <strong>iptables </strong>and <strong>bridge-utils</strong>. Ubuntu has <a href="http://packages.ubuntu.com/lucid/lxc">lxc </a>package, but on archlinux you will need to build it from <a href="http://wiki.archlinux.org/index.php/AUR">aur</a>.</p>
<p>Bring up the virtual network interface, you only need one here for all your lxc.</p>
<pre>brctl addbr br0
ifconfig br0 192.168.3.1 up</pre>
<p>Of course, you can pick other network address. You should <strong>skip </strong>the step mentioned in other guide to add your physical network such as &#8220;brctl addif br0 eth0&#8221;, because amazon will not route your private packet.</p>
<h3>Step 2: Filesystem</h3>
<p>Lxc installation should already include templates for some popular linux distribution. You can read the guide I mentioned above. For archlinux you can use my <a href="http://blog.mudy.info/2009/03/deploy-archlinux-chroot-onto-vps/">chroot script</a> and <a href="http://static.iphash.net/lxc.patch">patch</a>.<br />
I am not sure how to manually setup network for other distribution. You can also setup a dhcpd on host for the container. <br />
On archlinux you can disable the eth0 setup but enable the default route like this in rc.conf,</p>
<pre>INTERFACES=()
gateway="default gw 192.168.3.1"
ROUTES=(gateway)</pre>
<p>Here I assume your new root filesystem inside <strong>/mnt/mini</strong>. You LXC config file should look like this</p>
<pre>lxc.utsname = mini
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.name = eth0
lxc.network.ipv4 = 192.168.3.20/24
lxc.mount.entry = none /mnt/mini/dev/pts devpts newinstance 0 0
lxc.mount.entry = none /mnt/mini/proc    proc   defaults 0 0
lxc.mount.entry = none /mnt/mini/sys     sysfs  defaults 0 0
lxc.mount.entry = none /mnt/mini/dev/shm tmpfs  defaults 0 0
lxc.rootfs = /mnt/mini
lxc.tty = 3
lxc.pts = 1024</pre>
<h3>Step 3: Container network</h3>
<p>For network inside container to work, you still need to do two more things.</p>
<pre>cp /etc/resolve.conf /mnt/mini/etc</pre>
<pre>iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sysctl -w net.ipv4.ip_forward=1</pre>
<p>Now you can start your container.</p>
<pre>lxc-create -f /mnt/config -n mini</pre>
<pre>lxc-start -n mini</pre>
<p>If there is no error during container boot, you can proceed to enter your container.</p>
<pre>lxc-console -n mini</pre>
<p>Login as root with no password.</p>
<pre>ping www.google.com</pre>
<p>If you are lucky, you should see ping go through. It may take a second to discover the new route inside container.</p>
<h3>Step 3: Run service inside container</h3>
<p>The main reason for most people to setup a container inside an EC2 is probably for jailing network daemons. But your container only have non reachable private address, so do it home router style using port forwarding with iptables.<br />
For example, start your httpd daemon inside container as usual, then run this on host</p>
<pre>iptables -t nat -A PREROUTING -i eth0 -p tcp 
   --dport 80 -j DNAT --to-destination 192.168.3.20</pre>
<p>Now you should be able to reach your container from public ip.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.mudy.info/2010/07/linux-container-on-amazon-ec2-server/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Linux file copy benchmark cp vs cpio vs tar vs rsync</title>
		<link>https://blog.mudy.info/2010/07/linux-file-copy-benchmark-cp-vs-cpio-vs-tar-vs-rsync/</link>
		<comments>https://blog.mudy.info/2010/07/linux-file-copy-benchmark-cp-vs-cpio-vs-tar-vs-rsync/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 18:55:13 +0000</pubDate>
		<dc:creator><![CDATA[mudy]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mudy.info/?p=681</guid>
		<description><![CDATA[There are many commands to copy a directory in Linux. The difference between them in current Linux distribution are very small. All of them support link, time, ownership and sparse. I tested them to copy a Linux kernel source tree. &#8230;<p class="read-more"><a href="https://blog.mudy.info/2010/07/linux-file-copy-benchmark-cp-vs-cpio-vs-tar-vs-rsync/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>There are many commands to copy a directory in Linux. The difference between them in current Linux distribution are very small. All of them support link, time, ownership and sparse.</p>
<p>I tested them to copy a Linux kernel source tree. Each command I tested twice and keep the lower result.<br />
The original directory size is 639660032 bytes. All methods generate exact same size of 675446784 bytes without sparse option.</p>
<table>
<thead>
<tr>
<th></th>
<th>Non Sparse</th>
<th>Sparse</th>
</tr>
</thead>
<tbody>
<tr>
<th>rsync</th>
<td>rsync -a src /tmp</td>
<td>rsync -a -S src /tmp</td>
</tr>
<tr>
<th>cpio</th>
<td>find src -depth|cpio -pdm /tmp</td>
<td>find src -depth|cpio -pdm &#8211;sparse /tmp</td>
</tr>
<tr>
<th>cp</th>
<td>cp -a &#8211;sparse=never src /tmp</td>
<td>cp -a &#8211;sparse=always src /tmp</td>
</tr>
<tr>
<th>tar</th>
<td>tar -c src|tar -x -C /tmp</td>
<td>tar -c -S src|tar -x -C /tmp</td>
</tr>
</tbody>
</table>
<p>Time used and destination size:<br />
<iframe width='500' height='300' frameborder='0' src='https://spreadsheets.google.com/pub?key=0AlLk6MsRSXwtdFRLY1RCZkhMSnN0a3J2TVpDSFZyaEE&#038;hl=en&#038;single=true&#038;gid=0&#038;output=html&#038;widget=true'></iframe></p>
<p><img src="https://spreadsheets0.google.com/oimg?key=0AlLk6MsRSXwtdFRLY1RCZkhMSnN0a3J2TVpDSFZyaEE&#038;oid=2&#038;zx=28897i-qbrbr1" /></p>
<p><strong>Concolusion</strong>:<br />
For non sparse copy, rsync is the fastest. For sparse copy, rsync and cpio have the best space efficiency, but slow.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.mudy.info/2010/07/linux-file-copy-benchmark-cp-vs-cpio-vs-tar-vs-rsync/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Ziproxy to block ads and save bandwidth</title>
		<link>https://blog.mudy.info/2010/06/using-ziproxy/</link>
		<comments>https://blog.mudy.info/2010/06/using-ziproxy/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 05:15:50 +0000</pubDate>
		<dc:creator><![CDATA[mudy]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[ads]]></category>
		<category><![CDATA[at&t]]></category>
		<category><![CDATA[blocking]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[Poptop]]></category>
		<category><![CDATA[pppd]]></category>
		<category><![CDATA[pptp]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[proxy.pac]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[vpn]]></category>
		<category><![CDATA[ziproxy]]></category>

		<guid isPermaLink="false">http://blog.mudy.info/?p=633</guid>
		<description><![CDATA[Recently AT&#038;T ended unlimited wireless data plan for iphone and ipad and starbucks will offer free wifi. If you are an iphone or ipad user, you might be wondering how to save bandwidth and secure wifi access. If you also &#8230;<p class="read-more"><a href="https://blog.mudy.info/2010/06/using-ziproxy/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>Recently <a href="http://news.cnet.com/8301-17938_105-20006534-1.html">AT&#038;T ended unlimited wireless data plan for iphone and ipad</a> and <a href="http://news.cnet.com/8301-1035_3-20007752-94.html">starbucks will offer free wifi</a>. If you are an iphone or ipad user, you might be wondering how to save bandwidth and secure wifi access.  If you also own a Linux server with fast internet access, here is how. </p>
<h2>Table of Content</h2>
<ol>
<li><a href="#Ziproxy_test">Ziproxy</a></li>
<li><a href="#Ad_block">Ad Block</a></li>
<li><a href="#pptp">PPTP VPN</a></li>
<li><a href="#Client_config">Client Configure</a></li>
</ol>
<h3 id="Ziproxy_test">1. Ziproxy</h3>
<p><a href="http://ziproxy.sourceforge.net/">Ziproxy</a> is free opensource non-cache proxy to reduce webpage size by recompress image files.<br />
I run a simple test on some of my favorite websites by measuring full page loading size. These data are measured by Firefox, so the flash is included. Images have visible compression artifact at normal viewing distance, but that&#8217;s the price you have to pay for saving bandwidth. Ads are stripped away in proxy testing, see <a href="#Ad_block">next section</a>.
</p>
<p><iframe width='500' height='410' frameborder='0' src='https://spreadsheets.google.com/pub?key=0AlLk6MsRSXwtdGhTS2RaVkNpS3g1cGtFSGhwLXVCZ3c&#038;hl=en&#038;single=true&#038;gid=0&#038;output=html&#038;widget=true'></iframe><br />
<a href="http://blog.mudy.info/wp-content/uploads/2010/06/ziproxy_test.png"><img src="http://blog.mudy.info/wp-content/uploads/2010/06/ziproxy_test-300x180.png" alt="Ziproxy Test" title="Ziproxy Test" width="300" height="180" class="aligncenter size-medium wp-image-643" /></a></p>
<p><a href="http://ziproxy.sourceforge.net/download.html">Install</a> ziproxy or from package manager.<br />
Modify /etc/ziproxy/ziproxy.conf</p>
<pre>Port = 3128
RunAsUser = "nobody"
RunAsGroup = "nobody"
PreemptNameRes = true
ImageQuality = {65,65,65,65}
URLReplaceDataCT = "/etc/ziproxy/replace_ct.list"
URLReplaceDataCTList = {"image/jpeg", "image/gif", "image/png", "application/x-shockwave-flash"}
</pre>
<p>Don&#8217;t use VPN end point address here, because it doesn&#8217;t exist before VPN established. Depends on how you setup VPN, you can either limit access from iptables or binding address. You can also start ziproxy from ppp if-up script to avoid binding address problem.<br />
65% compression has a good balance between quality and size. URLReplaceDataCT will be used for adblocking to further reduce bandwidth usage. </p>
<p><strong>Update</strong>:  I did some real test on iPad. I used the traffic number on VPN interface to measure the total bandwidth usage to visit all above website once. I also measured multiple times to make sure data convergent. Here is the result<br />
No Proxy: TX 13.3MB RX 1.6MB<br />
With Ziproxy: TX 8.2MB RX 1.5MB<br />
Total: 35% Bandwidth save before VPN overhead.</p>
<h3  id="Ad_block">2. Ad Block</h3>
<p>There are several ways to block ads.<br />
First, VPN configure of your iPad or iPhone supports proxy autoconfigure. You can use a special <a href="http://www.schooner.com/~loverso/no-ads/">proxy.pac</a> file to block ads. It will redirect urls to a fake proxy. </p>
<p>You can also chain <a href="http://www.privoxy.org/">privoxy</a> to your ziproxy.</p>
<p>Another way is url block list used by ziproxy<br />
/etc/ziproxy/replace_ct.list</p>
<pre>http://*.yimg.com/*/promotions/*
http://*.doubleclick.net/*
http://*.2mdn.net/*
http://*.serving-sys.com/*
http://*.adtechus.com/*
http://*.eyewonder.com/*
http://*.atdmt.com/*
http://*.fbcdn.net/ads*/*
http://*.advertising.com/*
http://*.smartadserver.com/*
http://*.mediaplex.com/*
http://*.zedo.com/*
http://*.tumri.com/*
http://*yieldmanager*
http://*.checkm8.com/*
http://*.pointroll.com/*
http://*.tubemogul.com/*
http://*.intellitxt.com/*
http://*.crispwireless.com/*
http://*.condenet.com/*
http://*.eyereturn.com/*
http://*.linkstorm.net/*
http://*.optmd.com*
http://*.tcgmsrv.net*
http://*.videoegg.com*
http://adserver.*
http://ads.*
http://ad.*
http://*/ads/*
http://*adsfile*
http://*adfile*
http://*ad_file*
http://*ads_file*
http://*banner*
http://*banners*
http://*sponsor*
http://*sponsor*
http://*/adRequest/*
http://*Advertising*
http://*/adx/*
http://*marketing*
http://*adspace*
http://*adimage*
http://*ad_*
http://*AdManager*
http://*adscontent*
http://*adcontent*</pre>
<p>These are urls I found in my testing website.</p>
<h3 id="pptp">3. PPTP VPN</h3>
<p><a href="http://www.poptop.org/">Poptop</a> is a PPTP server.  Most linux should include it in <strong>ppp </strong>package.<br />
Here is some sample configure, you can use<br />
/etc/pptpd.conf</p>
<pre>option /etc/ppp/options.pptpd
localip 192.168.x.1
remoteip 192.168.x.234-238,192.168.x.245</pre>
<p>/etc/ppp/options.pptpd</p>
<pre>name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128</pre>
<p>/etc/ppp/chap-secrets</p>
<pre>user pptpd password *</pre>
<p>If you want to enable &#8220;Send All Traffic&#8221; option on your iDevice, you also need to enable nat and ipv4 forwarding.  This is only needed if you want to use application which does not support normal proxy. I use <a href="http://www.shorewall.net/manpages/shorewall-masq.html">shorewall </a> for NAT setup.</p>
<p>As I mentioned in previous section, you can enable ad block in VPN setting with proxy.pac file.</p>
<h3 id="Client_config">4. Client Configure</h3>
<p>Here is example setting for vpn and proxy.<br />
<a href="http://blog.mudy.info/wp-content/uploads/2010/06/vpnsetting.jpg"><img src="http://blog.mudy.info/wp-content/uploads/2010/06/vpnsetting-281x300.jpg" alt="Client VPN and Proxy Setting" title="Client VPN and Proxy Setting" width="281" height="300" class="aligncenter size-medium wp-image-669" /></a></p>
<p>If you don&#8217;t need ad block. Here is a simple proxy.pac, or you can use manual proxy setting.</p>
<pre>function FindProxyForURL(url, host) {
         if ( url.substring(0, 6) == "https:" ) { return "DIRECT"; }
         return "PROXY 192.168.x.1:3128; DIRECT";
}</pre>
]]></content:encoded>
			<wfw:commentRss>https://blog.mudy.info/2010/06/using-ziproxy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
