<?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>nme.pl » English</title>
	
	<link>http://www.nme.pl</link>
	<description>sys/net/dev blog</description>
	<lastBuildDate>Mon, 26 Jul 2010 07:31:19 +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/nmepl_en" /><feedburner:info uri="nmepl_en" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Django application development</title>
		<link>http://feedproxy.google.com/~r/nmepl_en/~3/Iusu4W_UgZc/</link>
		<comments>http://www.nme.pl/2010/07/django-application-development/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 16:48:20 +0000</pubDate>
		<dc:creator>nme</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.nme.pl/?p=1578</guid>
		<description><![CDATA[Most developers work on their startups far away from the daylight &#8211; they keep it in complete secret till the end. I&#8217;ve decided to do something new &#8211; I&#160;have started a&#160;project which is available to preview during the whole development. It is available at urevs.com. I&#160;also share all the project info on dedicated blog: blog.urevs.com. [...]]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><p>Most developers work on their startups far away from the daylight &#8211; they keep it in complete secret till the end. I&#8217;ve decided to do something new &#8211; I&nbsp;have started a&nbsp;project which is available to preview during the whole development. It is available at <a href="http://urevs.com/">urevs.com</a>. I&nbsp;also share all the project info on dedicated blog: <a href="http://blog.urevs.com/">blog.urevs.com</a>.</p>
<p>This project consists currently of authentication framework and a&nbsp;lot of backend solutions. Site allows users to login using OpenID&#8217;s, Google, Twitter, Facebook or Yahoo Accounts. Full details are available here &#8211; <a href=" http://blog.urevs.com/2010/07/19/social-bootstrap-engine-for-django/">social bootstrap engine for Django</a>.</p>
<p>I&#8217;d be very glad to hear from You, about every suggestion You have.</p>
<p><a href="http://blog.urevs.com/"><img class="aligncenter size-full wp-image-1580" title="openid-auth" src="http://www.nme.pl/wp-content/uploads/2010/07/openid-auth.png" alt="" width="467" height="106" /></a></p>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end --><img src="http://feeds.feedburner.com/~r/nmepl_en/~4/Iusu4W_UgZc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nme.pl/2010/07/django-application-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.nme.pl/2010/07/django-application-development/</feedburner:origLink></item>
		<item>
		<title>Ubuntu: which package a file belongs to?</title>
		<link>http://feedproxy.google.com/~r/nmepl_en/~3/VyjxO6JGG3I/</link>
		<comments>http://www.nme.pl/2010/07/ubuntu-which-package-a-file-belongs-to/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 17:06:54 +0000</pubDate>
		<dc:creator>nme</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.nme.pl/?p=1567</guid>
		<description><![CDATA[Some of us dont know this command, so: nme@werewolf ~ $ dpkg -S /usr/bin/ffmpeg ffmpeg: /usr/bin/ffmpeg nme@werewolf ~ $ or nme@werewolf ~ $ dpkg -S `which gcc` gcc: /usr/bin/gcc nme@werewolf ~ $ or nme@werewolf ~ $ dpkg -S *bash xz-utils: /usr/share/doc/xz-utils/extra/7z2lzma/7z2lzma.bash bash: /usr/share/menu/bash util-linux: /usr/share/doc/util-linux/examples/getopt-test.bash util-linux: /usr/share/doc/util-linux/examples/getopt-parse.bash bash: /bin/bash apparmor: /etc/apparmor.d/abstractions/bash bash: /bin/rbash bash-completion, bash: [...]]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><p>Some of us dont know this command, so:</p>
<p>nme@werewolf ~ $ <code>dpkg -S /usr/bin/ffmpeg<br />
ffmpeg: /usr/bin/ffmpeg</code><br />
nme@werewolf ~ $ </p>
<p>or</p>
<p>nme@werewolf ~ $ <code>dpkg -S `which gcc`<br />
gcc: /usr/bin/gcc</code><br />
nme@werewolf ~ $ </p>
<p>or</p>
<p>nme@werewolf ~ $ <code>dpkg -S *bash<br />
xz-utils: /usr/share/doc/xz-utils/extra/7z2lzma/7z2lzma.bash<br />
bash: /usr/share/menu/bash<br />
util-linux: /usr/share/doc/util-linux/examples/getopt-test.bash<br />
util-linux: /usr/share/doc/util-linux/examples/getopt-parse.bash<br />
bash: /bin/bash<br />
apparmor: /etc/apparmor.d/abstractions/bash<br />
bash: /bin/rbash<br />
bash-completion, bash: /usr/share/doc/bash<br />
global: /usr/bin/globash</code><br />
nme@werewolf ~ $ </p>
<p>You know smarter way? Add Your comment!</p>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end --><img src="http://feeds.feedburner.com/~r/nmepl_en/~4/VyjxO6JGG3I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nme.pl/2010/07/ubuntu-which-package-a-file-belongs-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.nme.pl/2010/07/ubuntu-which-package-a-file-belongs-to/</feedburner:origLink></item>
		<item>
		<title>IPv4 CIDR to netmask in Python</title>
		<link>http://feedproxy.google.com/~r/nmepl_en/~3/wNFAQp3Y918/</link>
		<comments>http://www.nme.pl/2010/05/ipv4-cidr-to-netmask-in-python/#comments</comments>
		<pubDate>Sun, 30 May 2010 13:35:17 +0000</pubDate>
		<dc:creator>nme</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.nme.pl/?p=1538</guid>
		<description><![CDATA[I needed small function to validate IPv4 netmasks, havent found one, so I&#160;wrote my own. I&#8217;ve decided to use IPv4 CIDR notation to get corresponding netmasks. Here is the code: def ipv4_cidr_to_netmask(bits): """ Convert CIDR bits to netmask """ netmask = '' for i in range(4): if i: netmask += '.' if bits >= 8: [...]]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><p>I needed small function to validate IPv4 netmasks, havent found one, so I&nbsp;wrote my own. I&#8217;ve decided to use <a href="http://infocenter.guardiandigital.com/manuals/IDDS/node9.html">IPv4 CIDR notation</a> to get corresponding netmasks. Here is the code:</p>
<pre class="prettyprint">
def ipv4_cidr_to_netmask(bits):

    """ Convert CIDR bits to netmask """

    netmask = ''
    for i<b></b> in range(4):
        if i:
            netmask += '.'
        if bits >= 8:
            netmask += '%d' % (2**8-1)
            bits -= 8
        else:
            netmask += '%d' % (256-2**(8-bits))
            bits = 0
    return netmask
</pre>
<p>Example usage is presented below. They also show how lambda mappings are useful in regular, daily use.</p>
<h3>List all possible netmasks:</h3>
<pre class="prettyprint">
for netmask in map(lambda x: ipv4_cidr_to_netmask(x), range(0,33)):
    print netmask

0.0.0.0
128.0.0.0
192.0.0.0
224.0.0.0
240.0.0.0
248.0.0.0
252.0.0.0
254.0.0.0
255.0.0.0
255.128.0.0
255.192.0.0
255.224.0.0
255.240.0.0
255.248.0.0
255.252.0.0
255.254.0.0
255.255.0.0
255.255.128.0
255.255.192.0
255.255.224.0
255.255.240.0
255.255.248.0
255.255.252.0
255.255.254.0
255.255.255.0
255.255.255.128
255.255.255.192
255.255.255.224
255.255.255.240
255.255.255.248
255.255.255.252
255.255.255.254
255.255.255.255
</pre>
<h3>Get netmask for /24:</h3>
<pre class="prettyprint">
print ipv4_cidr_to_netmask(24)

255.255.255.0
</pre>
<h3>Is 255.255.254.0 valid IPv4 netmask?</h3>
<pre class="prettyprint">
print "255.255.254.0" in map(lambda x: ipv4_cidr_to_netmask(x), range(0,33))

True
</pre>
<h3>Reverse search &#8211; get CIDR for 255.255.192.0 netmask</h3>
<pre class="prettyprint">
print map(lambda x: ipv4_cidr_to_netmask(x), range(0,33)).index('255.255.254.0')

23
</pre>
<p>As usual &#8211; enjoy <img src='http://www.nme.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end --><img src="http://feeds.feedburner.com/~r/nmepl_en/~4/wNFAQp3Y918" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nme.pl/2010/05/ipv4-cidr-to-netmask-in-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.nme.pl/2010/05/ipv4-cidr-to-netmask-in-python/</feedburner:origLink></item>
		<item>
		<title>Simple WordPress plugin debugging</title>
		<link>http://feedproxy.google.com/~r/nmepl_en/~3/U94cPO42Qzg/</link>
		<comments>http://www.nme.pl/2010/05/simple-wordpress-plugin-debugging/#comments</comments>
		<pubDate>Tue, 25 May 2010 19:51:25 +0000</pubDate>
		<dc:creator>nme</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.nme.pl/?p=1358</guid>
		<description><![CDATA[I&#8217;d like to present simplest way I&#160;know to debug WordPress plugins. It is a&#160;method I&#160;was using developing plugin to cloak URL&#8216;s described earlier. Below You can find the most minimalistic example plugin code possible &#8211; all it does is log REQUEST_URI to our debug file located at wp-content/plugins/debug. Row by row. Dirty and simple &#8211; [...]]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><p>I&#8217;d like to present simplest way I&nbsp;know to debug WordPress plugins. It is a&nbsp;method I&nbsp;was using developing <a href="http://www.nme.pl/2010/05/wordpress-plugin-to-redirect-or-cloak-urls/">plugin to cloak URL</a>&#8216;s described earlier.</p>
<p>Below You can find the most minimalistic example plugin code possible &#8211; all it does is log <code>REQUEST_URI</code> to our debug file located at <code>wp-content/plugins/debug</code>. Row by row. Dirty and simple &#8211; and the most important &#8211; it does <strong>not require</strong> us to switch our WordPress to  debug mode.</p>
<p>Plugin consists of three parts &#8211; plugin description header, debugging function and hook to <code>main</code> function which is executed right before page is rendered.</p>
<div class="prettydiv">
<p>&lt; ?php</p>
<pre class="prettyprint">/*
Plugin Name: test
Plugin URI:
Description:
Version:
Author:
Author URI:
*/
</pre>
<p>?&gt;<br />
&lt; ?php</p>
<pre class="prettyprint">function debug($msg)
{
        $fp = fopen('wp-content/plugins/debug', 'a');
        fwrite($fp, $msg."\n");
        fclose($fp);
}

function main()
{
        debug($_SERVER['REQUEST_URI']);
}

add_action('init', 'main');
</pre>
<p>?&gt;</p>
</div>
<p>Of course the most important part of the code is <code>debug</code> function which stores results we need to verify to our debug file.</p>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end --><img src="http://feeds.feedburner.com/~r/nmepl_en/~4/U94cPO42Qzg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nme.pl/2010/05/simple-wordpress-plugin-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.nme.pl/2010/05/simple-wordpress-plugin-debugging/</feedburner:origLink></item>
		<item>
		<title>jQuery-UI themeselect widget published</title>
		<link>http://feedproxy.google.com/~r/nmepl_en/~3/qGGdicB8EKc/</link>
		<comments>http://www.nme.pl/2010/05/jquery-ui-themeselect-widget-published/#comments</comments>
		<pubDate>Sun, 23 May 2010 17:46:29 +0000</pubDate>
		<dc:creator>nme</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery-ui]]></category>

		<guid isPermaLink="false">http://www.nme.pl/?p=1478</guid>
		<description><![CDATA[I&#8217;ve recently published jQuery-UI themeselect widget allowing users to add friendly looking, themable dropdown to instant theme switch. In oppose to standard jQuery-UI themeswitcher, this one looks exacly like the rest of the theme. My ui-themeselect has been published on New BSD License making it freely available and the code is hosted at Google Code. [...]]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><p><a href="http://www.nme.pl/wp-content/uploads/2010/05/screenshot.png"><img class="alignright size-thumbnail wp-image-1479" title="screenshot" src="http://www.nme.pl/wp-content/uploads/2010/05/screenshot-150x150.png" alt="" width="150" height="150" /></a>I&#8217;ve recently published jQuery-UI <a href="http://code.google.com/p/ui-themeselect/">themeselect</a> widget allowing users to add friendly looking, themable dropdown to instant theme switch.</p>
<p>In oppose to standard jQuery-UI themeswitcher, this one looks exacly like the rest of the theme.</p>
<p>My ui-themeselect has been published on <a href="http://www.opensource.org/licenses/bsd-license.php">New BSD License</a> making it freely available and the code is hosted at Google Code. If You are familiar with Mercurial, you can clone the repository using command below:</p>
<pre class="prettyprint">hg clone https://ui-themeselect.googlecode.com/hg/ ui-themeselect</pre>
<p>I have ripped the code out from my own Django / Google App Engine applications development Javascript bootstrap, because I&nbsp;think that someone else might consider it useful.</p>
<p>As an example how can it look inside jQuery-UI themed interface, take a&nbsp;look at this screenshot taken from one of my apps:</p>
<p style="margin: 0.4em 0;">
<p><a href="http://www.nme.pl/wp-content/uploads/2010/05/themeselect-usage.png"><img class="aligncenter size-full wp-image-1481" title="themeselect-usage" src="http://www.nme.pl/wp-content/uploads/2010/05/themeselect-usage.png" alt="" width="400" height="349" /></a></p>
<p style="margin: 0.7em 0;">Enjoy! <img src='http://www.nme.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end --><img src="http://feeds.feedburner.com/~r/nmepl_en/~4/qGGdicB8EKc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nme.pl/2010/05/jquery-ui-themeselect-widget-published/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.nme.pl/2010/05/jquery-ui-themeselect-widget-published/</feedburner:origLink></item>
		<item>
		<title>WordPress plugin to redirect or cloak URL’s</title>
		<link>http://feedproxy.google.com/~r/nmepl_en/~3/VDFxiUrqIew/</link>
		<comments>http://www.nme.pl/2010/05/wordpress-plugin-to-redirect-or-cloak-urls/#comments</comments>
		<pubDate>Tue, 18 May 2010 19:02:18 +0000</pubDate>
		<dc:creator>nme</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.nme.pl/?p=1328</guid>
		<description><![CDATA[After few unsuccessful searches for free WordPress plugin that would allow me to cloak URL&#8217;s on my blog &#8211; I&#160;decided to write my own. It was not really hard. I&#8217;m publishing it on GPLv3 license. Plugin is really simple &#8211; full code consists of 75 lines of code. It does not contain database support, hits [...]]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><p>After few unsuccessful searches for <strong>free</strong> WordPress plugin that would allow me to cloak URL&#8217;s on my blog &#8211; I&nbsp;decided to write my own. It was not really hard. I&#8217;m publishing it on <a href="http://www.gnu.org/licenses/gpl.html">GPLv3</a> license.</p>
<p>Plugin is really simple &#8211; full code consists of 75 lines of code. It <strong>does not</strong> contain database support, hits counting nor wp-admin interface. If some of You will like to extend it including those features &#8211; please do it and inform me &#8211; I&nbsp;will be first betatester <img src='http://www.nme.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Plugin assumes that You already accomplished redirecting URL&#8217;s to WordPress subsystem that You would like to be handled by WordPress in a&nbsp;different way.</p>
<p>There are three possible kinds of URL threating:</p>
<ul>
<li>Permanent redirect &#8211; typical <code>HTTP 301 redirect</code></li>
<li>Temporary redirect &#8211; typical <code>HTTP 302 redirect</code></li>
<li>Local cloak &#8211; <strong>it works only on Your blog web page</strong> (thats why it is called local) &#8211; it will hide real destination URL leaving it cloaked</li>
</ul>
<h3>How does it work?</h3>
<p>The core of the plugin source is pasted below. Maybe some of You will consider it as interesting <img src='http://www.nme.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  The most unfortunate part of the plugin is need to use <code>/wp-admin/plugins.php</code> <code>Edit plugin</code> feature to manually change URL&#8217;s. Those are listed inside <code>$redirect</code> variable.</p>
<div class="prettydiv">
<pre class="prettyprint">define('PERMANENT_REDIRECT',301);
define('TEMPORARY_REDIRECT',302);
define('LOCAL_CLOAK',1);

$redirects = array(
  # source match         TYPE                           destination url
  # /u
  "^/u$" =>              array(TEMPORARY_REDIRECT,      "/u/"),
  "^/u/(.*)$" =>         array(LOCAL_CLOAK,             "/category/u/$1"),
}

function url_cloaker()
{
    global $redirects;
    $src_url = $_SERVER['REQUEST_URI'];
    foreach ($redirects as $src => $dst) {
        $src = str_replace('/','\/',$src);
        if (preg_match('/'.$src.'/',$src_url)) {
            #__d('Matched: '.$src);
            $dst_url = preg_replace('/'.$src.'/', $dst[1], $src_url);
            switch ($dst[0]) {
                case PERMANENT_REDIRECT:
                    wp_redirect($dst_url, PERMANENT_REDIRECT);
                    exit;
                case TEMPORARY_REDIRECT:
                    wp_redirect($dst_url, TEMPORARY_REDIRECT);
                    exit;
                case LOCAL_CLOAK:
                    $_SERVER['REQUEST_URI'] = $dst_url;
                    break;
            }
        }
    }
}

add_action('init', 'url_cloaker');
</pre>
</div>
<p>Plugin use actions hooking framework inside WordPress to make sure it is fired before page is shown.</p>
<p>The code above seems to be unreadable for You? Get this <span style="font-weight:bold"> <a href="http://80ee0zjm8mjsdqfgxdtklfsb0d.hop.clickbank.net/" target="_top">PHP book</a></span>, because PHP is very simple language to learn and it <strong>offers a&nbsp;lot of new possibilities</strong> for those who know how to use it.</p>
<div style="background: none repeat scroll 0% 0% #eeeeff; padding: 0.5em 0pt; margin-bottom: 2em; text-align: center;"><em>The plugin is available <a href="http://www.nme.pl/pub/url-cloaker-wordpress-plugin/url-cloaker.phps">here</a> for download.</em></div>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end --><img src="http://feeds.feedburner.com/~r/nmepl_en/~4/VDFxiUrqIew" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nme.pl/2010/05/wordpress-plugin-to-redirect-or-cloak-urls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.nme.pl/2010/05/wordpress-plugin-to-redirect-or-cloak-urls/</feedburner:origLink></item>
		<item>
		<title>How to add IMQ patch to Ubuntu 10.04 Lucid Lynx</title>
		<link>http://feedproxy.google.com/~r/nmepl_en/~3/pOt4Q7o8ecg/</link>
		<comments>http://www.nme.pl/2010/05/how-to-add-imq-patch-to-ubuntu-10-04-lucid-lynx/#comments</comments>
		<pubDate>Mon, 10 May 2010 06:11:11 +0000</pubDate>
		<dc:creator>nme</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[net]]></category>
		<category><![CDATA[sys]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.nme.pl/?p=1220</guid>
		<description><![CDATA[Those of you, who are having problems adding IMQ support to recent Ubuntu/Debian release, might consider this blog entry useful I will not discuss what IMQ is and wheater is it good or bad &#8211; I&#160;will describe how to prepare kernel, iptables packages and how to deploy them to our Debian/Ubuntu system including taking care [...]]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><div style="float: right; border: 1px solid black; width: 250px; height: 130px; margin-left: 10px;"><a href="http://www.nme.pl/wp-content/uploads/2010/05/ipt_limit.png"><img class="alignright size-full wp-image-1247" style="margin-top: -30px; margin-right: -25px;" title="ipt_limit" src="http://www.nme.pl/wp-content/uploads/2010/05/ipt_limit.png" alt="" width="302" height="182" /></a></div>
<p>Those of you, who are having problems adding IMQ support to recent Ubuntu/Debian release, might consider this blog entry useful <img src='http://www.nme.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I will not discuss <a href="http://wiki.nix.hu/cgi-bin/twiki/view/IMQ/ImqFaq#Use_of_IMQ">what IMQ is</a> and wheater is it good or bad &#8211; I&nbsp;will describe how to prepare kernel, iptables packages and how to deploy them to our Debian/Ubuntu system including taking care of making them immune to accidential system upgrade packages replacement.</p>
<h3>Kernel package with IMQ support</h3>
<p>Before we start &#8211; we need few packages that will might be required:</p>
<pre class="prettyprint">sudo aptitude install fakeroot build-essential kernel-package ncurses-dev
</pre>
<p>Now we are ready to start: first, we need our current kernel with distro patches. For desktop instance I&nbsp;would use <code>-generic</code> instead of <code>-server</code>:</p>
<pre class="prettyprint">apt-get source linux-image-2.6.32-22-server
</pre>
<p>Now, we download imq patch, apply it and compile kernel:</p>
<pre class="prettyprint">wget http://linuximq.net/patchs/linux-2.6.32-imq-test2.diff

cd linux-2.6.32/

patch -p1 < ../linux-2.6.32-imq-test2.diff

fakeroot time make-kpkg --initrd --append_to_version=imq linux-image
</pre>
<p>During the compilation process, make-kpkg script will discover unanswered features that we need to check as modules:</p>
<pre>  "IMQ" target support (NETFILTER_XT_TARGET_IMQ) [N/m/?] (NEW) <code>m</code>

  IMQ (intermediate queueing device) support (IMQ) [M/y/?] (NEW) <code>M</code>

    IMQ behavior (PRE/POSTROUTING)

      1. IMQ AA (IMQ_BEHAVIOR_AA) (NEW)

    &gt; 2. IMQ AB (IMQ_BEHAVIOR_AB) (NEW)

      3. IMQ BA (IMQ_BEHAVIOR_BA) (NEW)

      4. IMQ BB (IMQ_BEHAVIOR_BB) (NEW)

    choice[1-4?]: <code>2</code>

    Number of IMQ devices (IMQ_NUM_DEVS) [16] (NEW)
</pre>
<p>Finally... in parent directory we will find:</p>
<p>linux-image-2.6.32.11+drm33.2imq_2.6.32.11+drm33.2imq-10.00.Custom_i386.deb</p>
<p>If everything went fine and our package is present - we can clean up compiled object files that will not be required anymore, recovering few GB of hard disk space:</p>
<pre class="prettyprint">./debian/rules clean
</pre>
<p>in case You forget to generate <code>initrd</code> file, it always might be generated by hand:</p>
<pre class="prettyprint">sudo -i

cd /boot/

mkinitramfs-kpkg -o initrd.img-2.6.32.11+drm33.2imq 2.6.32.11+drm33.2imq

update-grub
</pre>
<h3>Iptables package with IMQ support</h3>
<p>First, the patch - there is no iptables-1.4.4 imq patch available on <a href="http://linuximq.net">linuximq.net</a> I'm afraid. I&nbsp;have used iptables-1.4.6-imq patch and fixed it to compile with iptables-1.4.4.</p>
<p>Original patch can be found <a href="http://linuximq.net/patchs/iptables-1.4.6-imq.diff">here</a>.</p>
<p>Changes:</p>
<pre class="prettyprint">diff -Naurw iptables-1.4.6-imq.diff iptables-1.4.4-imq.diff
--- iptables-1.4.6-imq.diff	2010-01-27 11:53:22.000000000 +0100
+++ iptables-1.4.4-imq.diff	2010-05-08 13:18:21.000000000 +0200
@@ -43,7 +43,7 @@
 +
 +	switch(c) {
 +	case '1':
-+		if (xtables_check_inverse(optarg, &amp;invert, NULL, 0, argv))
++		if (xtables_check_inverse(optarg, &amp;invert, 0, argv))
 +			xtables_error(PARAMETER_PROBLEM,
 +				   "Unexpected `!' after --todev");
 +		mr->todev=atoi(optarg);
</pre>
<p>Ready to use patch can be downloaded from <a href="http://nme.pl/pub/patches/iptables-1.4.4-imq.diff">here</a> using command below:</p>
<pre class="prettyprint">wget http://nme.pl/pub/patches/iptables-1.4.4-imq.diff
</pre>
<p>Ok, now since we got patch ready, we can download iptables sources and compile our deb package:</p>
<pre class="prettyprint">apt-get source iptables
</pre>
<pre class="prettyprint">cd iptables-1.4.4
</pre>
<p><del datetime="2010-05-10T08:28:38+00:00">cp ../iptables-1.4.4-imq.diff debian/patch/1009-iptables-1.4.4-imq.diff<br />
echo "1009-iptables-1.4.4-imq.diff" &gt;&gt;debian/patch/series</del></p>
<pre class="prettyprint">patch -p0 < ../iptables-1.4.4-imq.diff

dpkg-buildpackage -rfakeroot -uc -b
</pre>
<p>In case You are recompiling for some reason, one of the distro patches might fail - in this case edit debian/patches/series using Your favourite editor and comment out the following patch:</p>
<pre>0902-docs-version-reference.diff    -&gt;    #0902-docs-version-reference.diff
</pre>
<p>Operation above might be archived by in place edition of debian/patch/series using command below:</p>
<pre class="prettyprint">sed -i 's/^0902/#0902/' debian/patch/series
</pre>
<p>When compilation ends, You should get two packages in parent directory: <code>iptables</code> and <code>iptables-dev</code>.</p>
<h3>Installation &amp; freezing our changes</h3>
<p>Now we can install our packages:</p>
<pre class="prettyprint">dpkg -i *.deb
</pre>
<p>It will install following packages:</p>
<pre>iptables_1.4.4-2ubuntu2_i386.deb
linux-image-2.6.32.11+drm33.2imq_2.6.32.11+drm33.2imq-10.00.Custom_i386.deb
iptables-dev_1.4.4-2ubuntu2_i386.deb
</pre>
<p>You might also consider holding packages to be sure that they will not be replaced during standard regular-basis upgrade:</p>
<pre class="prettyprint">aptitude hold linux-image iptables iptables-dev
</pre>
<h3>IMQ development, status and replacement discussion</h3>
<p>It is not true that recent IMQ patches are not stable as I&nbsp;have read on some web pages. Since Jussi joined the IMQ team, problems I&nbsp;have had with 2.6.18-24 kernels have gone to past.</p>
<p>Kernel 2.6.28.9 with iptables 1.4.0 works perfectly stable taking care of huge loads of network traffic. I&nbsp;think that current patch described above will work the same (im making before-production tests currently and it seems to work fine).</p>
<p>On the other hand - <a href="http://www.linuxfoundation.org/collaborate/workgroups/networking/ifb">IFB</a> - which is meant as replacement for IMQ - as for me - it does not offer the same functionality for bridge environment I&nbsp;need... Of course - I&nbsp;might be mistaken. Thats why - if anyone of You have replaced IMQ with IFB for bridge devices with ingress and egress traffic shaping - I'm very interested in the solution.</p>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end --><img src="http://feeds.feedburner.com/~r/nmepl_en/~4/pOt4Q7o8ecg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nme.pl/2010/05/how-to-add-imq-patch-to-ubuntu-10-04-lucid-lynx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.nme.pl/2010/05/how-to-add-imq-patch-to-ubuntu-10-04-lucid-lynx/</feedburner:origLink></item>
	</channel>
</rss>
