<?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>Brandon&#039;s Blog &#187; qmail</title>
	<atom:link href="http://www.brandonturner.net/blog/tag/qmail/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brandonturner.net/blog</link>
	<description>Random thoughts on web applications, software development and Linux</description>
	<lastBuildDate>Thu, 08 Apr 2010 01:47:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>IPv6 support for qmail-jms1</title>
		<link>http://www.brandonturner.net/blog/2009/08/qmail-ipv6-jms1/</link>
		<comments>http://www.brandonturner.net/blog/2009/08/qmail-ipv6-jms1/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 21:13:34 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[Server Admin]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[qmail]]></category>

		<guid isPermaLink="false">http://www.brandonturner.net/blog/?p=462</guid>
		<description><![CDATA[This post is part of a series of posts dedicated to IPv6 support for qmail: Qmail IPv6 support tcpserver and rblsmtpd sslserver jgreylist jms1 combined patch IPv6 support in qmail Supporting IPv6 in qmail largely revolves around DNS lookups. Patches for tcpserver and sslserver allow incoming connections over IPv6. In order to support IPv6 in [...]]]></description>
			<content:encoded><![CDATA[<p>This post is part of a series of posts dedicated to IPv6 support for qmail:</p>
<ul class="noseparation">
<li><a href="/blog/2009/08/qmail-ipv6/">Qmail IPv6 support</a>
<ul class="noseparation">
<li><a href="/blog/2009/08/qmail-ipv6-tcpserver/">tcpserver and rblsmtpd</a></li>
<li><a href="/blog/2009/08/qmail-ipv6-sslserver/">sslserver</a></li>
<li><a href="/blog/2009/08/qmail-ipv6-jgreylist/">jgreylist</a></li>
<li><strong>jms1 combined patch</strong></li>
</ul>
</li>
</ul>
<h4>IPv6 support in qmail</h4>
<p>Supporting IPv6 in qmail largely revolves around DNS lookups.  Patches for <a href="/blog/2009/08/qmail-ipv6-tcpserver">tcpserver</a> and <a href="/blog/2009/08/qmail-ipv6-sslserver">sslserver</a> allow incoming connections over IPv6.  In order to support IPv6 in qmail:</p>
<ul class="noseparation">
<li>DNS lookups should prefer AAAA records, falling back to A records only if AAAA records are not available</li>
<li>All code referencing IP addresses should support IPv4 and IPv6 addresses</li>
<li>SPF queries should support IPv6 addresses</li>
</ul>
<h4>The fujiwara patch</h4>
<p>A <a href="http://member.wide.ad.jp/~fujiwara/files/qmail-1.03-v6-20021006.diff">qmail IPv6 patch</a> has existed since 2002 that covers the first two issues above.  It is written to apply cleanly on the base qmail-1.03 distributed on <a href="http://cr.yp.to/qmail.html">Daniel Bernstein&#8217;s site</a>.  It does not include support for SPF queries as SPF is not included in the original version of qmail.</p>
<h4>John Simpson&#8217;s combined patch</h4>
<p>I use John Simpson&#8217;s <a href="http://qmail.jms1.net/patches/combined.shtml">combined patch</a> for my qmail installs.  This patch adds support for <a href="http://www.openspf.org/">SPF</a> as well as many other things.  I have modified the fujiwara patch to apply on top of John&#8217;s combined patch as well as support SPF queries.</p>
<p>You can download my modified patch: <a href="http://www.bltweb.net/qmail/qmail-1.03-jms1.7.08-ipv6.patch">qmail-1.03-jms1.7.08-ipv6.patch</a>.  Installing it is simple:</p>
<div class="prompt">
$ <span class="cmd">wget <a href="http://cr.yp.to/software/qmail-1.03.tar.gz">http://cr.yp.to/software/qmail-1.03.tar.gz</a></span><br />
$ <span class="cmd">wget <a href="http://qmail.jms1.net/patches/qmail-1.03-jms1.7.08.patch">http://qmail.jms1.net/patches/qmail-1.03-jms1.7.08.patch</a></span><br />
$ <span class="cmd">wget <a href="http://www.bltweb.net/qmail/qmail-1.03-jms1.7.08-ipv6.patch">http://www.bltweb.net/qmail/qmail-1.03-jms1.7.08-ipv6.patch</a></span><br />
$ <span class="cmd">tar -xzf qmail-1.03.tar.gz</span><br />
$ <span class="cmd">mv qmail-1.03 qmail-1.03-jms1.7.08</span><br />
$ <span class="cmd">cd qmail-1.03-jms1.7.08</span><br />
$ <span class="cmd">patch &lt; ../qmail-1.03-jms1.7.08.patch</span><br />
$ <span class="cmd">patch -p1 &lt; ../qmail-1.03-jms1.7.08-ipv6.patch</span><br />
$ <span class="cmd">sed -ie 	&#8217;1s/$/ -DINET6/&#8217; conf-cc</span><br />
$ <span class="cmd">make</span><br />
$ <span class="cmd">make man</span><br />
$ <span class="cmd">sudo make setup check</span>
</div>
<h4>Configuration and running</h4>
<p>No special configuration is needed for this patch.</p>
<p>When applied, connections will prefer IPv6, transparently falling back to IPv4 if no IPv6 addresses are available.  This patch allows sending outbound messages over IPv6.  For inbound messages, you must apply the <a href="/blog/2009/08/qmail-ipv6-tcpserver/">tcpserver</a> or <a href="/blog/2009/08/qmail-ipv6-sslserver/">sslserver</a> patches.</p>
<p>Email addresses on my <code>bltweb.net</code> domain are IPv6 enabled thanks to a <a href="http://tunnelbroker.net">free IPv6 tunnel</a> provided by Hurricane Electric.  Feel free to send me an email once you are IPv6 enabled!</p>
<h4>Summary</h4>
<p>Feel free to leave any comments, corrections or questions below.  Remember Gentoo users can apply all of my qmail patches automatically by using the ebuilds in my <a href="/blog/gentoo-overlay/">gentoo-overlay</a>.</p>
<p>Once you have compiled qmail with IPv6 support, you should re-visit my main <a href="/blog/2009/08/qmail-ipv6/">qmail IPv6</a> post for information about testing and using your new IPv6 qmail install.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brandonturner.net/blog/2009/08/qmail-ipv6-jms1/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>IPv6 support for jgreylist</title>
		<link>http://www.brandonturner.net/blog/2009/08/qmail-ipv6-jgreylist/</link>
		<comments>http://www.brandonturner.net/blog/2009/08/qmail-ipv6-jgreylist/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 21:13:23 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[Server Admin]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[qmail]]></category>

		<guid isPermaLink="false">http://www.brandonturner.net/blog/?p=456</guid>
		<description><![CDATA[In this post I describe how to modify jgreylist to support IPv6 connections.  This is one step to supporting IPv6 in qmail.]]></description>
			<content:encoded><![CDATA[<p>This post is part of a series of posts dedicated to IPv6 support for qmail:</p>
<ul class="noseparation">
<li><a href="/blog/2009/08/qmail-ipv6/">Qmail IPv6 support</a>
<ul class="noseparation">
<li><a href="/blog/2009/08/qmail-ipv6-tcpserver/">tcpserver and rblsmtpd</a></li>
<li><a href="/blog/2009/08/qmail-ipv6-sslserver/">sslserver</a></li>
<li><strong>jgreylist</strong></li>
<li><a href="/blog/2009/08/qmail-ipv6-jms1/">jms1 combined patch</a></li>
</ul>
</li>
</ul>
<h4>jgreylist Changes</h4>
<p><a href="http://qmail.jms1.net/scripts/jgreylist.shtml">jgreylist</a> is a program provided by John Simpson to allow <a href="http://en.wikipedia.org/wiki/Greylisting">greylisting</a> in qmail.  John provides two versions, one written in Perl, and one written in C.  I chose to only patch the C version.</p>
<p>jgreylist works by using the unix timestamps of empty files to track when individual IP address or class C blocks last visited your qmail server.  John does a great job of explaining how this works on his <a href="http://qmail.jms1.net/scripts/jgreylist.shtml">jgreylist</a> page.  You should understand how his program, especially the C version, works and is configured before continuing.</p>
<p>Normally, the IP addresses are stored in a directory such as <code>/var/qmail/jgreylist</code>.  Each byte of the IP address is stored in a directory so that the IP address 127.0.0.1 would be stored in <code>/var/qmail/jgreylist/127/000/000/001</code>.  To reduce the number of files needed, by default <code>jgreylist</code> actually only stores the first 3 bytes, so 127.0.0.1 would actually be stored in <code>/var/qmail/jgreylist/127/000/000</code>.  Which behavior <code>jgreylist</code> uses depends on the value of the <code>JGREYLIST_BY_IP</code> environment variable.</p>
<p>My patch changes the directory structure slightly.  All IPv4 addresses are stored inside an <code>ip4</code> directory.  IPv6 addresses are stored in an <code>ip6</code> directory.</p>
<p>IPv6 addresses are stored in directories for each byte in the address.  Unlike IPv4 addresses, each byte is represented in hex rather than decimal.  When <code>JGREYLIST_BY_IP</code> is a non-zero value, the entire address is stored.  Otherwise only the first 64 bits of the address is stored.  For example, the IPv6 <code>2001:470:1f0f:350::1</code> address would be stored in: <code>/var/qmail/jgreylist/ip6/20/01/04/70/1f/0f/03/50</code>.</p>
<h4>Download jgreylist with IPv6 support</h4>
<p>John distributes his <code>jgreylist</code> program using a single C file that you compile on your system.  I needed to pull in some additional files for the IPv6 stuff so I&#8217;ve repackaged John&#8217;s file with a Makefile and other dependencies.  This modified <code>jgreylist</code> must be run using an IPv6 patched <a href="/blog/2009/08/qmail-ipv6-tcpserver/">tcpserver</a> or <a href="/blog/2009/08/qmail-ipv6-sslserver">sslserver</a>.</p>
<p>You can download the package here: <a href="http://www.bltweb.net/qmail/jgreylist-0.8-ipv6.tar.gz">jgreylist-0.8-ipv6.tar.gz</a>.</p>
<p>Compiling and installing is easy:</p>
<div class="prompt">
$ <span class="cmd">wget <a href="http://www.bltweb.net/qmail/jgreylist-0.8-ipv6.tar.gz">http://www.bltweb.net/qmail/jgreylist-0.8-ipv6.tar.gz</a></span><br />
$ <span class="cmd">tar -xzf jgreylist-0.8-ipv6.tar.gz</span><br />
$ <span class="cmd">cd jgreylist-0.8-ipv6</span><br />
$ <span class="cmd">make</span><br />
$ <span class="cmd">sudo make install</span>
</div>
<p>After installing, you should follow John&#8217;s <a href="http://qmail.jms1.net/scripts/jgreylist.shtml">instructions</a> on configuring and running.</p>
<p>The <code>jgreylist-clean</code> perl script is included in the tar file above.  It required no changes.</p>
<h4>Summary</h4>
<p>If you have any comments, corrections or questions, feel free to post them below.  Remember Gentoo users can apply all of my qmail patches automatically by using the ebuilds in my <a href="/blog/gentoo-overlay/">gentoo-overlay</a>.  <code>jgreylist</code> is built in to the <code>qmail-jms1</code> ebuild, just use the <code>jgreylist<code> USE flag.</p>
<p>Once you've patched <code>jgreylist</code> you should move on to <a href="/blog/2009/08/qmail-ipv6-jms1/">patching qmail-jms1 or IPv6 support</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brandonturner.net/blog/2009/08/qmail-ipv6-jgreylist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IPv6 support for sslserver</title>
		<link>http://www.brandonturner.net/blog/2009/08/qmail-ipv6-sslserver/</link>
		<comments>http://www.brandonturner.net/blog/2009/08/qmail-ipv6-sslserver/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 21:13:14 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[Server Admin]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[qmail]]></category>

		<guid isPermaLink="false">http://www.brandonturner.net/blog/?p=446</guid>
		<description><![CDATA[In this post I describe how to add IPv6 support to sslserver via a custom patch.  This is one step in enabling IPv6 support for qmail.]]></description>
			<content:encoded><![CDATA[<p>This post is part of a series of posts dedicated to IPv6 support for qmail:</p>
<ul class="noseparation">
<li><a href="/blog/2009/08/qmail-ipv6/">Qmail IPv6 support</a>
<ul class="noseparation">
<li><a href="/blog/2009/08/qmail-ipv6-tcpserver/">tcpserver and rblsmtpd</a></li>
<li><strong>sslserver</strong></li>
<li><a href="/blog/2009/08/qmail-ipv6-jgreylist/">jgreylist</a></li>
<li><a href="/blog/2009/08/qmail-ipv6-jms1/">jms1 combined patch</a></li>
</ul>
</li>
</ul>
<h4>ucspi-ssl</h4>
<p>The <a href="http://www.superscript.com/ucspi-ssl/index.html">ucspi-ssl</a> package provides the <code>sslserver</code> program.  <code>sslserver</code> accepts incoming SSL connections and passes them to another program such as <code>qmail-smtpd</code>.  <code>sslserver</code> is almost identical to tcpserver except that it deals with encrypted SSL traffic rather than clear text.</p>
<p>I could not find an IPv6 patch for <code>sslserver</code>, however I was able to port the <a href="/blog/2009/08/qmail-ipv6-tcpserver/">tcpserver patch</a> to <code>sslserver</code>.  You can easily apply my <a href="http://www.bltweb.net/qmail/ucspi-ssl-0.70-ipv6.patch">ucspi-ssl-0.70-ipv6.patch</a>:</p>
<div class="prompt">
$ <span class="cmd">wget <a href="http://www.superscript.com/ucspi-ssl/ucspi-ssl-0.70.tar.gz">http://www.superscript.com/ucspi-ssl/ucspi-ssl-0.70.tar.gz</a></span><br />
$ <span class="cmd">wget <a href="http://www.bltweb.net/qmail/ucspi-ssl-0.70-ipv6.patch">http://www.bltweb.net/qmail/ucspi-ssl-0.70-ipv6.patch</a></span><br />
$ <span class="cmd">tar -xzf ucspi-ssl-0.70.tar.gz</span><br />
$ <span class="cmd">cd host/superscript.com/net/ucspi-ssl-0.70</span><br />
$ <span class="cmd">patch -p1 < ../../../../ucspi-ssl-0.70-ipv6.patch</span><br />
$ <span class="cmd">package/compile</span><br />
$ <span class="cmd">sudo package/install</span>
</div>
<h4>sslserver</h4>
<p>To understand what the <code>sslserver</code> portion of the IPv6 patch does, you should be familiar with the <a href="http://www.superscript.com/ucspi-ssl/sslserver.html">sslserver man page</a> and read about how <code>tcpserver</code> handles IPv6 on <a href="http://www.fefe.de/ucspi/">Fefe&#8217;s ucspi-tcp</a> page.  Essentially, if a client connects via IPv4, <code>sslserver</code> exhibits it&#8217;s normal behavior.  If a client connects with IPv6, the <code>PROTO</code> environment variable will be set to &#8220;<code>SSL6</code>&#8221; instead of &#8220;<code>SSL</code>&#8220;.</p>
<p>The patch also supports using IPv6 addresses in your tcprules files.  A new rule may look like this:</p>
<div class="file">
# Don&#8217;t delay the greeting for my home server<br />
2001:470:1f0f:350::1:allow,GREETDELAY=&#8221;0&#8243;
</div>
<p>After applying this patch, you may notice that your logs are filled with addresses similar to: <code>::ffff:192.168.1.1</code>.  This is because internally <code>sslserver</code> treats every IP as an IPv6 address.  IPv4 addresses are represented using their <a href="http://en.wikipedia.org/wiki/IPv6#IPv4_mapped_addresses">IPv4 mapped address</a>.</p>
<h4>Summary</h4>
<p>If you have any comments, corrections, or questions, please feel free to leave a comment below.  Remember Gentoo users can apply all of my qmail patches automatically by using the ebuilds in my <a href="/blog/gentoo-overlay/">gentoo-overlay</a>.</p>
<p>Once you&#8217;ve patched <code>sslserver</code>, you should move on to <a href="/blog/2009/08/qmail-ipv6-jgreylist/">patching jgreylist for IPv6</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brandonturner.net/blog/2009/08/qmail-ipv6-sslserver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IPv6 support for tcpserver and rblsmtpd</title>
		<link>http://www.brandonturner.net/blog/2009/08/qmail-ipv6-tcpserver/</link>
		<comments>http://www.brandonturner.net/blog/2009/08/qmail-ipv6-tcpserver/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 21:13:07 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[Server Admin]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[qmail]]></category>

		<guid isPermaLink="false">http://www.brandonturner.net/blog/?p=427</guid>
		<description><![CDATA[In this post I describe how to add IPv6 support to tcpserver and rblsmtpd via a custom patch.  This is one step in enabling IPv6 support for qmail.]]></description>
			<content:encoded><![CDATA[<p>This post is part of a series of posts dedicated to IPv6 support for qmail:</p>
<ul class="noseparation">
<li><a href="/blog/2009/08/qmail-ipv6/">Qmail IPv6 support</a>
<ul class="noseparation">
<li><strong>tcpserver and rblsmtpd</strong></li>
<li><a href="/blog/2009/08/qmail-ipv6-sslserver/">sslserver</a></li>
<li><a href="/blog/2009/08/qmail-ipv6-jgreylist/">jgreylist</a></li>
<li><a href="/blog/2009/08/qmail-ipv6-jms1/">jms1 combined patch</a></li>
</ul>
</li>
</ul>
<h4>ucspi-tcp</h4>
<p>The <a href="http://cr.yp.to/ucspi-tcp.html">ucspi-tcp</a> package provides the <code>tcpserver</code> and <code>rblsmtpd</code> programs.  <code>tcpserver</code> accepts incoming TCP connections and passes them to another program such as <code>qmail-smtpd</code>.  <code>rblsmtpd</code> blocks connections from RBL listed IPs.</p>
<p>Thanks to Fefe, a <a href="http://www.fefe.de/ucspi/">patch</a> has been around for a while that adds IPv6 support to <code>tcpserver</code>.  Fefe&#8217;s patch does not touch <code>rblsmtpd</code>, however.</p>
<p>I&#8217;ve modified Fefe&#8217;s patch to patch rblsmtpd as well.  You can easily apply my <a href="http://www.bltweb.net/qmail/ucspi-tcp-0.88-ipv6.patch">ucspi-tcp-0.88-ipv6.patch</a>:</p>
<div class="prompt">
$ <span class="cmd">wget <a href="http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz">http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz</a></span><br />
$ <span class="cmd">wget <a href="http://www.bltweb.net/qmail/ucspi-tcp-0.88-ipv6.patch">http://www.bltweb.net/qmail/ucspi-tcp-0.88-ipv6.patch</a></span><br />
$ <span class="cmd">tar -xzf ucspi-tcp-0.88.tar.gz</span><br />
$ <span class="cmd">cd ucspi-tcp-0.88</span><br />
$ <span class="cmd">patch -p1 < ../ucspi-tcp-0.88-ipv6.patch</span><br />
$ <span class="cmd">make</span><br />
$ <span class="cmd">sudo make install</span>
</div>
<h4>tcpserver</h4>
<p>To understand what the <code>tcpserver</code> portion of the IPv6 patch does, you should read <a href="http://www.fefe.de/ucspi/">Fefe&#8217;s ucspi-tcp</a> page.  Essentially, if a client connects via IPv4, <code>tcpserver</code> exhibits it&#8217;s normal behavior.  If a client connects with IPv6, the <code>PROTO</code> environment variable will be set to &#8220;<code>TCP6</code>&#8220;.</p>
<p>The patch also supports using IPv6 addresses in your tcprules files.  A new rule may look like this:</p>
<div class="file">
# Ignore RBL lookups for home server<br />
2001:470:1f0f:350::1:allow:RBLSMTPD=&#8221;"
</div>
<p>After applying this patch, you may notice that your logs are filled with addresses similar to: <code>::ffff:192.168.1.1</code>.  This is because internally <code>tcpserver</code> treats every IP as an IPv6 address.  IPv4 addresses are represented using their <a href="http://en.wikipedia.org/wiki/IPv6#IPv4_mapped_addresses">IPv4 mapped address</a>.</p>
<h4>rblsmtpd</h4>
<p>When patching <code>rblsmtpd</code> for IPv6 support, I had to decide how to lookup IPv6 addresses.  As far as I know, there aren&#8217;t any IPv6 blacklists yet.  There isn&#8217;t a spec on how these addresses should be queried.  My patch will use a new namespace, <code>ipv6</code>, when querying RBLs as described <a href="http://mail-archives.apache.org/mod_mbox/spamassassin-dev/200508.mbox/%3C136001c5a72c$39cf6560$7d25a8c0@watson1%3E">here</a>.  This means if you connect via <code>2001:470:1f0f:350::1</code>, a <code>TXT</code> DNS lookup will be made to:</p>
<div style="padding-left: 8px;" class="prompt">
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.5.3.0.f.0.f.1.0.7.4.0.1.0.0.2.ipv6.rbl.example.org
</div>
<p>If anyone knows of a working RBL that differs, please let me know.</p>
<h4>Summary</h4>
<p>If you have any comments, corrections, or questions, please feel free to leave a comment below.  Remember Gentoo users can apply all of my qmail patches automatically by using the ebuilds in my <a href="/blog/gentoo-overlay/">gentoo-overlay</a>.</p>
<p>Once you&#8217;ve patched <code>tcpserver</code>, you should move on to <a href="/blog/2009/08/qmail-ipv6-sslserver/">patching ucspi-ssl (sslserver) for IPv6</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brandonturner.net/blog/2009/08/qmail-ipv6-tcpserver/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Qmail IPv6</title>
		<link>http://www.brandonturner.net/blog/2009/08/qmail-ipv6/</link>
		<comments>http://www.brandonturner.net/blog/2009/08/qmail-ipv6/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 21:12:56 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[Server Admin]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[qmail]]></category>

		<guid isPermaLink="false">http://www.brandonturner.net/blog/?p=423</guid>
		<description><![CDATA[In this series of posts I describe how to enable IPv6 support in qmail, including tcpserver, sslserver, rblsmtpd, qmail-smtpd, qmail-remote and jgreylist.]]></description>
			<content:encoded><![CDATA[<p>Adding IPv6 support to qmail can be a daunting task.  A <em>modern</em> qmail system includes several different components, with various patches and configuration options for each.  There are a few patches on the internet that claim to add IPv6 support for a specific component, but I had trouble finding patches for every piece of my qmail install.</p>
<p>I&#8217;m not trying to defend IPv6. I realize there are many people with strong feelings towards the subject, including <a href="http://cr.yp.to/djbdns/ipv6mess.html">qmail&#8217;s author</a>.  Switching to IPv6 is a monumental task.  It may never happen, but something needs to &#8211; we can&#8217;t keep NATing forever.</p>
<p>Many software projects have already added support for IPv6.  My Gentoo box has been on an IPv6 network, via Hurricane Electric&#8217;s free <a href="http://tunnelbroker.net">tunnel broker</a> service for a while now.  Mac OS X has support for IPv6, as do the latest versions of Windows.  Even Windows XP can support IPv6 if enabled.  <a href="http://www.postfix.org/IPV6_README.html">Postfix</a>, <a href="http://www.exim.org/exim-html-3.20/doc/html/spec_4.html#SEC24">Exim</a>, and <a href="http://www.sendmail.org/~ca/email/sm-810.html">Sendmail</a> all support IPv6.</p>
<p>In this series of posts, I will outline the steps I took to add IPv6 support to qmail.  I use John Simpson&#8217;s <a href="http://qmail.jms1.net/patches/combined-details.shtml">combined patch</a> for qmail as well as many other tools and methodologies described on his <a href="http://qmail.jms1.net/">site</a>, however many of the patches and instructions in these posts will work for other <em>versions</em> of qmail as well.</p>
<p><a name="components"></a></p>
<h4>Components</h4>
<p>John Simpson has an excellent illustration of a typical qmail system, <a href="http://qmail.jms1.net/qmail-system.pdf">Anatomy of a typical qmail system</a> [PDF], on his website.  The following articles describe the steps I took to enable IPv6 for each of the necessary components:</p>
<ul class="noseparation">
<li><a href="/blog/2009/08/qmail-ipv6-tcpserver/">tcpserver and rblsmtpd</a></li>
<li><a href="/blog/2009/08/qmail-ipv6-sslserver/">sslserver</a></li>
<li><a href="/blog/2009/08/qmail-ipv6-jgreylist/">jgreylist</a></li>
<li><a href="/blog/2009/08/qmail-ipv6-jms1/">jms1 combined patch</a></li>
</ul>
<p>For Gentoo users, the patches described in each of the above posts can be installed automatically using the ebuilds in my <a href="/blog/gentoo-overlay/">gentoo-overlay</a>.  For others, I&#8217;ve listed all the IPv6 patches on my <a href="http://www.bltweb.net/qmail/">qmail patches</a> page.</p>
<h4>Testing</h4>
<p>Testing your IPv6 enabled qmail setup can be a little confusing.  There aren&#8217;t that many IPv6 enabled mail servers out there.  Even worse, most people don&#8217;t have IPv6 connections.</p>
<p>Hurricane Electric provides a free <a href="http://tunnelbroker.net/">IPv6 tunnel broker</a> service that will allocate a /64 block of addresses that you can use.  I host my personal mail server on a <a href="http://www.linode.com/">Linode</a> which, despite being an excellent VPS, doesn&#8217;t have native IPv6.  To get around this I set up a tunnel broker and enabled AAAA entries in DNS.</p>
<p>To test my setup, I had to install two separate qmail installs on different servers.  Email addresses on my bltweb.net domain are now IPv6 enabled.  If you&#8217;d like to use them to test, feel free to shoot me an email.  Perhaps one day I&#8217;ll set up some type of reflector to automatically test.</p>
<h4>IPv6 email experience</h4>
<p>I&#8217;ve been running IPv6 mail servers at home and work for a few months now.  I haven&#8217;t been keeping detailed statistics, but for the most part the only connections I&#8217;ve seen over IPv6 thus far have been spam <img src='http://www.brandonturner.net/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Still, enabling IPv6 in qmail wasn&#8217;t as hard as I thought it was going to be, thanks to the pre-existing patches on the internet.  Hopefully more and more companies will start to enable IPv6 on their networks, such as <a href="http://www.personal.psu.edu/dvm105/blogs/ipv6/2009/06/netflix-streaming-over-ipv6.html">Netflix</a>.  While email may still be even further out it never hurts to be ready.</p>
<p>Hopefully these posts have helped you add IPv6 support to your qmail install.  Feel free to leave comments or questions below and I&#8217;ll do my best to address them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brandonturner.net/blog/2009/08/qmail-ipv6/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Gentoo ebuild for qmail with JMS1 combined patch</title>
		<link>http://www.brandonturner.net/blog/2009/04/qmail-jms1-ebuild/</link>
		<comments>http://www.brandonturner.net/blog/2009/04/qmail-jms1-ebuild/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 05:07:00 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[DKIM]]></category>
		<category><![CDATA[ebuild]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[qmail]]></category>

		<guid isPermaLink="false">http://www.brandonturner.net/blog/?p=255</guid>
		<description><![CDATA[In a previous post, I introduced a patch to add DKIM and DomainKeys support to Qmail with John Simpson&#8217;s combined patch. In this post I&#8217;ll introduce the ebuild I wrote (well, modified) to allow easily installing qmail-jms1 on a Gentoo system. Though this ebuild makes installing qmail with John&#8217;s patch a little easier, it doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://www.brandonturner.net/blog/2009/03/dkim-and-domainkeys-for-qmail/">previous post</a>, I introduced a patch to add DKIM and DomainKeys support to Qmail with <a href="http://qmail.jms1.net/patches/combined.shtml">John Simpson&#8217;s combined patch</a>.  In this post I&#8217;ll introduce the ebuild I wrote (well, modified) to allow easily installing <em>qmail-jms1</em> on a Gentoo system.</p>
<p>Though this ebuild makes installing qmail with John&#8217;s patch a little easier, it doesn&#8217;t make administering a qmail system child&#8217;s play.  Before merging this ebuild, you should read through <a href="http://qmail.jms1.net">John&#8217;s website</a>.  You may also want to read about <a href="http://www.gentoo.org/doc/en/qmail-howto.xml">netqmail on Gentoo</a>.  While this ebuild has nothing to do with netqmail, it does borrow some the conventions presented in the Gentoo doc concerning starting, stopping and controlling qmail.</p>
<p>I didn&#8217;t include any of John&#8217;s run scripts or configuration files.  Only the combined patch is applied to the base qmail image.  I&#8217;ve also included some additional patches I&#8217;ve found useful.  They are described in more detail on my <a href="http://www.bltweb.net/qmail">qmail patches page</a>.  Most of my extra patches are controlled by use flags (<code>dkim, ipv6</code>) and not applied by default.</p>
<p>For the impatient, here is a direct link to the ebuild:<br />
<a href="http://svn.bltweb.net/repos/public/gentoo_overlay/mail-mta/qmail-jms1/qmail-jms1-7.08-r1.ebuild">http://svn.bltweb.net/repos/public/gentoo_overlay/mail-mta/qmail-jms1/qmail-jms1-7.08-r1.ebuild</a></p>
<h4>Install my portage overlay</h4>
<p>The easiest way to use the qmail-jms1 ebuild is to use my <a href="http://www.brandonturner.net/blog/gentoo-overlay/">Gentoo Portage Overlay</a>.  Please see the <a href="http://www.brandonturner.net/blog/gentoo-overlay/">overlay page</a> for instructions on how to set it up.</p>
<p>You will need the following ebuilds from my overlay:</p>
<ul class="noseparation">
<li><a href="http://svn.bltweb.net/repos/public/gentoo_overlay/virtual/qmail/">virtual/qmail</a></li>
<li><a href="http://svn.bltweb.net/repos/public/gentoo_overlay/mail-mta/qmail-jms1/">mail-mta/qmail-jms1</a></li>
<li><a href="http://svn.bltweb.net/repos/public/gentoo_overlay/sys-apps/ucspi-tcp/">sys-apps/ucspi-tcp</a></li>
<li><a href="http://svn.bltweb.net/repos/public/gentoo_overlay/mail-filter/libdkim/">mail-filter/libdkim</a> (only needed if using the <code>dkim</code> use flag)</li>
</ul>
<h4>Install Qmail</h4>
<p>Once the overlay is set up, installing qmail-jms1 is easy.</p>
<p>Add the following to your <code>/etc/portage/package.keywords</code> file:</p>
<div class="file">
mail-mta/qmail-jms1<br />
sys-apps/ucspi-tcp<br />
mail-filter/libdkim<br />
# You may also need these:<br />
net-mail/dot-forward<br />
sys-process/daemontools<br />
sys-apps/ucspi-ssl<br />
virtual/checkpassword<br />
net-mail/checkpassword-pam
</div>
<p>Now install qmail-jms1:</p>
<div class="prompt">
$ <span class="cmd">emerge -pv qmail-jms1</span><br />
$ <span class="cmd">sudo emerge qmail-jms1</span>
</div>
<h4>Configure Qmail</h4>
<p>Yeah right&#8230;  There is plenty of documentation elsewhere for this.  Try <a href="http://qmail.jms1.net/">John&#8217;s website</a>.</p>
<h4>Start Qmail</h4>
<div class="prompt">
# <span class="cmd">ln -s /var/qmail/supervise/qmail-send /service/qmail-send</span><br />
# <span class="cmd">ln -s /var/qmail/supervise/qmail-smtpd /service/qmail-smtpd</span><br />
# <span class="cmd">rc-update add svscan default</span><br />
# <span class="cmd">/etc/init.d/svscan start</span>
</div>
<p>&nbsp;<br />
&nbsp;<br />
That&#8217;s all I have for now.  Installing, configuring and administering qmail should not be taken lightly.  This ebuild has made it easier for me to set up and maintain my servers, however you should only consider using it if you are already familiar with setting up a qmail server.</p>
<p>Feel free to leave any comments, suggestions or problems below!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brandonturner.net/blog/2009/04/qmail-jms1-ebuild/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DKIM and DomainKeys for qmail</title>
		<link>http://www.brandonturner.net/blog/2009/03/dkim-and-domainkeys-for-qmail/</link>
		<comments>http://www.brandonturner.net/blog/2009/03/dkim-and-domainkeys-for-qmail/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 05:13:21 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[Server Admin]]></category>
		<category><![CDATA[DKIM]]></category>
		<category><![CDATA[DomainKeys]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[qmail]]></category>

		<guid isPermaLink="false">http://www.brandonturner.net/blog/?p=134</guid>
		<description><![CDATA[This patch adds support for signing and verifying DKIM and DomainKeys signatures to qmail.]]></description>
			<content:encoded><![CDATA[<p><a href="http://domainkeys.sourceforge.net/">DomainKeys</a> and its successor <a href="http://www.dkim.org/">DomainKeys Identified Mail (DKIM)</a> are technologies that allow organizations to take responsibility for a message.  This is done by cryptographically signing an email as it leaves an organization in route to its destination.  The signature can be verified using the DNS system to establish trust.  In theory the technologies help cut down on spam by proving a message originated from the domain it says it does.</p>
<p>Support for DomainKeys in qmail has existed for a while thanks to a <a href="http://www.qmail.org/qmail-1.03-dk-0.53.patch">patch</a> by Russel Nelson.  Kyle Wheeler created a set of <a href="http://www.memoryhole.net/qmail/#dkim">wrapper scripts</a> that can be used to provide support for DKIM and DomainKeys.  Mihai Secasiu has some <a href="http://patchlog.com/security/qmail-and-dkim/">wrapper scripts</a> similar to Kyle&#8217;s that provide support for DKIM via the libdkim library instead of Perl&#8217;s <a href="http://search.cpan.org/~jaslong/Mail-DKIM-0.31/">Mail::DKIM</a> module.</p>
<p>The current methods take different approaches to implement DKIM and DomainKeys.  The DomainKeys patch creates a single program, <code>qmail-dk</code> that is called before <code>qmail-queue</code>.  This program signs or verifies all <em>incoming</em> messages (that may later become outbound) based on the existence of the <code>DKSIGN</code> and <code>DKVERIFY</code> variables.  The DKIM wrapper scripts wrap <code>qmail-remote</code> to sign messages and wrap <code>qmail-queue</code> (or <code>qmail-dk</code>) to verify incoming messages.  This can be easier understood by looking at the <a href="http://www.nrg4u.com/">qmail big picture</a>.</p>
<p>I tend to agree with separate programs for signing outbound messages and verifying inbound messages as this allows signing <em>all</em> outbound messages, even those (such as NDRs) that never pass through <code>qmail-queue</code>.  I also prefer patching qmail as it tends to be a little easier and requires less configuration after qmail is installed.</p>
<p>In this post I will show you how to patch qmail to support DKIM as well as DomainKeys.  My <a href="http://www.bltweb.net/qmail/qmail-1.03-jms1.7.08-dkim-r1.patch">qmail DKIM/DomainKeys patch</a> uses neither Russel Nelson&#8217;s DomainKeys patch nor Kyle Wheeler&#8217;s DKIM/DomainKey wrappers, but borrows ideas from both.  My patch uses the <a href="http://sourceforge.net/projects/domainkeys/">libdomainkeys</a> and <a href="http://sourceforge.net/projects/libdkim/">libdkim</a> libraries to do the actual signing and verifying.  Rather than creating two new programs, I patch <code>qmail-smtpd</code> (for verifying) and <code>qmail-remote</code> (for signing) directly.</p>
<p>I&#8217;ll do my best to provide step by step instructions for patching and installing for you non-Gentoo users, but in my next post I&#8217;ll share my ebuild which does it all for you.</p>
<p><a name="libdomainkeys"></a><br />
<h4>1. Install libdomainkeys</h4>
<p>The <code>libdomainkeys</code> library is used to sign and verify DomainKeys signatures.</p>
<div class="prompt">
$ <span class="cmd">wget <a href="http://downloads.sourceforge.net/domainkeys/libdomainkeys-0.69.tar.gz">http://downloads.sourceforge.net/domainkeys/libdomainkeys-0.69.tar.gz</a></span><br />
$ <span class="cmd">tar -xzf libdomainkeys-0.69.tar.gz</span><br />
$ <span class="cmd">cd libdomainkeys-0.69</span><br />
$ <span class="cmd">make</span><br />
<span style="color: red;">(If you get errors during <code>make</code>, edit the Makefile and add <code>-lresolv</code> to the end of the <code>LIBS</code> line)</span><br />
$ <span class="cmd">sudo install -m 644 libdomainkeys.a /usr/local/lib</span><br />
$ <span class="cmd">sudo install -m 644 domainkeys.h dktrace.h /usr/local/include</span><br />
$ <span class="cmd">sudo install -m 755 dknewkey /usr/local/bin</span><br />
$ <span class="cmd">cd ..</span>
</div>
<p><a name="libdkim"></a><br />
<h4>2. Install libdkim</h4>
<p>The <code>libdkim</code> library is used to sign and verify DKIM signatures.  You&#8217;ll need g++ to compile this on your system.  The library claims to be portable, but I needed to patch it to get it to compile on my Gentoo box.  I&#8217;ve also included a (slightly modified) patch from <a href="http://patchlog.com/security/qmail-and-dkim/">Mihai Secasiu</a> that makes working with libdkimtest much easier.</p>
<div class="prompt">
$ <span class="cmd">wget <a href="http://downloads.sourceforge.net/libdkim/libdkim-1.0.19.zip">http://downloads.sourceforge.net/libdkim/libdkim-1.0.19.zip</a></span><br />
$ <span class="cmd">wget <a href="http://www.bltweb.net/qmail/libdkim-1.0.19-linux.patch">http://www.bltweb.net/qmail/libdkim-1.0.19-linux.patch</a></span><br />
$ <span class="cmd">wget <a href="http://www.bltweb.net/qmail/libdkim-1.0.19-extra-options.patch">http://www.bltweb.net/qmail/libdkim-1.0.19-extra-options.patch</a></span><br />
$ <span class="cmd">unzip libdkim-1.0.19.zip</span><br />
$ <span class="cmd">cd libdkim/src</span><br />
$ <span class="cmd">patch -p2 < ../../libdkim-1.0.19-linux.patch</span><br />
$ <span class="cmd">patch -p2 < ../../libdkim-1.0.19-extra-options.patch</span><br />
$ <span class="cmd">make</span><br />
$ <span class="cmd">sudo make install</span><br />
$ <span class="cmd">cd ../..</span>
</div>
<p><a name="install_qmail"></a><br />
<h4>3. Patch and install qmail</h4>
<p>I&#8217;m currently using <a href="http://qmail.jms1.net/patches/combined.shtml">John Simpson&#8217;s qmail Combined Patch Set</a> for my qmail installation.  The instructions below highlight how to apply my DKIM/DomainKeys patch on top of John&#8217;s combined patch.  I&#8217;d highly recommend checking out John&#8217;s combined patch as it is about as close as you can get to an actively maintained qmail.</p>
<p>I&#8217;m <strong>not</strong> attempting to describe or document John&#8217;s patch in anyway in this post, as John runs an excellent site about qmail (<a href="http://qmail.jms1.net/">qmail.jms1.net</a>) that contains far more information than is contained here.  Do not attempt to proceed without reading through John&#8217;s documentation as well as the rest of this post.</p>
<div class="prompt">
$ <span class="cmd">wget <a href="http://cr.yp.to/software/qmail-1.03.tar.gz">http://cr.yp.to/software/qmail-1.03.tar.gz</a></span><br />
$ <span class="cmd">wget <a href="http://qmail.jms1.net/patches/qmail-1.03-jms1.7.08.patch">http://qmail.jms1.net/patches/qmail-1.03-jms1.7.08.patch</a></span><br />
$ <span class="cmd">wget <a href="http://www.bltweb.net/qmail/qmail-1.03-jms1.7.08-dkim-r1.patch">http://www.bltweb.net/qmail/qmail-1.03-jms1.7.08-dkim-r1.patch</a></span><br />
$ <span class="cmd">tar -xzf qmail-1.03.tar.gz</span><br />
$ <span class="cmd">mv qmail-1.03 qmail-1.03-jms1.7.08</span><br />
$ <span class="cmd">cd qmail-1.03-jms1.7.08</span><br />
$ <span class="cmd">patch < ../qmail-1.03-jms1.7.08.patch</span><br />
$ <span class="cmd">patch -p1 < ../qmail-1.03-jms1.7.08-dkim-r1.patch</span><br />
$ <span class="cmd">sed -ie 	&#39;1s/$/ -DDKIM/&#39; conf-cc</span><br />
$ <span class="cmd">make</span><br />
$ <span class="cmd">make man</span><br />
$ <span class="cmd">sudo make setup check</span><br />
$ <span class="cmd">cd ..</span>
</div>
<p><a name="sign"></a><br />
<h4>4. Configure DKIM/DomainKeys signing</h4>
<p>Signing is done by <code>qmail-remote</code> and is controlled by the <code>dksign</code> control file.  Signatures are created using a private key on your system, and verified by a public key stored in the DNS for the email domain.</p>
<h5>Generate keys</h5>
<p>Before you can sign an email, you must create at least one public/private key pair.  You should create key pairs for every domain you wish to sign.  To create keys for <code>example.com</code>:</p>
<div class="prompt">
# <span class="cmd">mkdir -p /etc/domainkeys/example.com</span><br />
# <span class="cmd">cd /etc/domainkeys/example.com</span><br />
# <span class="cmd">dknewkey default 1024 > default.pub</span><br />
# <span class="cmd">chown -R root:root /etc/domainkeys</span><br />
# <span class="cmd">chmod 640 /etc/domainkeys/example.com/default</span><br />
# <span class="cmd">chown root:qmail /etc/domainkeys/example.com/default</span>
</div>
<p>It is very important that the default file be readable only by <code>root</code> and the group which <code>qmailr</code> (the <code>qmail-remote</code> user) belongs to.  This is the private key used for signing messages and, if compromised, would allow others to sign messages as your domain.</p>
<p>Now add a <code>TXT</code> entry to the DNS for <code>default._domainkey.example.com</code> containing the quoted part in the <code>/etc/domainkeys/example.com/default.pub</code>.  NOTE: You normally want to include the quotes!</p>
<h5>Configure control files</h5>
<p>Create a file <code>/var/qmail/control/dksign</code> containing one line:</p>
<div class="file">
/etc/domainkeys/%/default
</div>
<p>The <code>%</code> will be replaced with the domain name in the <code>From:</code> header (or the <code>Sender:</code> header if it exists).  If no file exists for the given domain, parent domains will be tried.  For example if the message is from <code>foo@bar.example.com</code>, <code>/etc/domainkeys/bar.example.com/default</code> will be tested first.  If the file does not exist, <code>/etc/domainkeys/example.com/default</code> will be tested.  If no key can be found, the message will not be signed.  If a key exists, but cannot be read or contains invalid data, the message will not be sent and will remain in the queue until the problem is fixed.</p>
<p>If you do not create the <code>/var/qmail/control/dksign</code> file, no messages will be signed.</p>
<h5>Test outbound signing</h5>
<p>Now that DKIM/DomainKeys signing is configured, you can test it by sending an email to <code>sa-test (at) sendmail dot net</code>.  This reflector will reply (within seconds) to the envelope sender with a status of the DomainKeys and DKIM signatures.</p>
<p>If you experience problems, consult the <code>qmail-remote</code> man page or post a comment below and I&#8217;ll try to help.</p>
<p><a name="verify"></a><br />
<h4>5. Configure DKIM/DomainKeys verification</h4>
<p>Verification is performed by <code>qmail-smtpd</code> and is controlled by the <code>DKVERIFY</code> environment variable.  Messages are only verified if <code>DKVERIFY</code> is set and RELAYCLIENT is <strong>not</strong> set.  You may control which IP addresses are verified using the tcpserver access file (sometimes stored in <code>/etc/tcprules.d/tcp.qmail-smtp</code>).</p>
<p>When verifying a message, the contents of <code>DKVERIFY</code> are checked against the status of the DomainKeys and DKIM results.  Each test result is represented by a letter.  <code>DKVERIFY</code> should contain a series of letters for DomainKeys results, a comma, and then a series of letters for the DKIM results.  If the letter is uppercase, the message will be rejected (hard error).  If the letter is lowercase, the message will be deferred (soft error).  The <code>DKVERIFY</code> variable can be set but empty, in which case messages will be verified and an <code>Authentication-Results:</code> header will be added but <em>all</em> messages will be accepted regardless of status.</p>
<p>The letters for DomainKeys results are:</p>
<table>
<tr>
<th>Code</th>
<th>Status</th>
<th>Description</th>
</tr>
<tr>
<td>A</td>
<td>OK</td>
<td>The message contained a signature which correctly matched the contents of the message.</td>
</tr>
<tr>
<td>B</td>
<td>BADSIG</td>
<td>The message contained a signature which DID NOT correctly match the contents of the message. The signature may be forged, or the content may have been changed after the original server applied the signature.</td>
</tr>
<tr>
<td>C</td>
<td>NOSIG</td>
<td>The message did not contain a <code>DomainKey-Signature</code> header, or contained one which was missing a required field, or had a signature header without a &#8220;From:&#8221; header.</td>
</tr>
<tr>
<td>D</td>
<td>NOKEY</td>
<td>The public key needed to verify the signature does not exist (i.e. the authoritative DNS server for the domain says that the TXT record which should contain the key does not exist.)</td>
</tr>
<tr>
<td>E</td>
<td>BADKEY</td>
<td>The public key which was found in DNS is not usable.</td>
</tr>
<tr>
<td>F</td>
<td>CANTVRFY</td>
<td>The public key needed to verify the signature cannot be found, because the DNS server which should have the key is not responding, or returned a temporary error condition. The domainkeys specification says that the server SHOULD treat this as a soft error, telling the client to try their delivery again at some point in the future.</td>
</tr>
<tr>
<td>G</td>
<td>SYNTAX</td>
<td>The message is not in the proper format. This could be an improperly formatted email address, a duplicate &#8220;From:&#8221; header in the message, or any number of things which &#8220;confuse&#8221; the program.</td>
</tr>
<tr>
<td>H</td>
<td>NORESOURCE</td>
<td>Out of memory. The domainkeys specification says that the server SHOULD treat this as a soft error, telling the client to try their delivery again at some point in the future.</td>
</tr>
<tr>
<td>I</td>
<td>ARGS</td>
<td>Arguments are not usable</td>
</tr>
<tr>
<td>J</td>
<td>REVOKED</td>
<td>The key which was used to generate the signature has been revoked.</td>
</tr>
<tr>
<td>K</td>
<td>INTERNAL</td>
<td>There was an internal error in the libdomainkeys library</td>
</tr>
</table>
<p>The letters for the DKIM results are:</p>
<table>
<tr>
<th>Code</th>
<th>Status</th>
<th>Description</th>
</tr>
<tr>
<td>A</td>
<td>OK</td>
<td>The message contained a signature which correctly matched the contents of the message.</td>
</tr>
<tr>
<td>B</td>
<td>FAIL</td>
<td>The message failed verification</td>
</tr>
<tr>
<td>C</td>
<td>BAD_SYNTAX</td>
<td>The <code>DKIM-Signature</code> header could not be parsed or had bad tags/values</td>
</tr>
<tr>
<td>D</td>
<td>SIG BAD</td>
<td>RSA verify failed</td>
</tr>
<tr>
<td>E</td>
<td>SIG BAD (testing)</td>
<td>RSA verify failed but testing</td>
</tr>
<tr>
<td>F</td>
<td>SIG EXPIRED</td>
<td>Signature is expired (x= is old)</td>
</tr>
<tr>
<td>G</td>
<td>SELECTOR INVALID</td>
<td>Selector doesn&#8217;t parse or contains invalid values</td>
</tr>
<tr>
<td>H</td>
<td>SELECTOR MISMATCH</td>
<td>Selector granularity doesn&#8217;t match</td>
</tr>
<tr>
<td>I</td>
<td>SELECTOR REVOKED</td>
<td>The selector was revoked (p= is empty)</td>
</tr>
<tr>
<td>J</td>
<td>DOMAIN TOO LONG</td>
<td>The domain name is too long to request</td>
</tr>
<tr>
<td>K</td>
<td>DNS TEMP FAIL</td>
<td>Temporary DNS error requesting public key</td>
</tr>
<tr>
<td>L</td>
<td>DNS PERM FAIL</td>
<td>Permanent DNS error requestion public key</td>
</tr>
<tr>
<td>M</td>
<td>PUBLIC KEY INVALID</td>
<td>Public key isn&#8217;t valid or can&#8217;t be parsed</td>
</tr>
<tr>
<td>N</td>
<td>NO SIG</td>
<td>The message contains no DKIM signatures</td>
</tr>
<tr>
<td>O</td>
<td>NO VALID SIG</td>
<td>The message contains no valid signatures</td>
</tr>
<tr>
<td>P</td>
<td>BAD BODY HASH</td>
<td>The message body doesn&#8217;t verify</td>
</tr>
<tr>
<td>Q</td>
<td>ALGORITHM MISMATCH</td>
<td>The selector (h=) doesn&#8217;t match signature (a=)</td>
</tr>
<tr>
<td>R</td>
<td>STAT INCOMPAT</td>
<td>Incompatible v=</td>
</tr>
</table>
<p>I recommend a <code>DKVERIFY</code> value of <code><strong>DEGIJKfh,CGHIJMQRkl</strong></code>.  This will only reject improperly formatted messages.  Messages that don&#8217;t verify will still be allowed.  I would advise against rejecting messages that don&#8217;t verify as there are still some problems with DomainKeys and DKIM (such as mailing lists).  Rather than rejecting bad signatures, incorporate the <code>Authentication-Results</code> header into your broader spam prevention strategy.</p>
<h5>The <code>Authentication-Results</code> header</h5>
<p>All messages received by <code>qmail-smtpd</code> when <code>DKVERIFY</code> is set will add an <code>Authentication-Results</code> header to the incoming message.  This header conforms to the <a href="http://tools.ietf.org/html/draft-kucherawy-sender-auth-header-20">IETF internet draft</a>.  Here&#8217;s an example from one of my emails:</p>
<pre>Authentication-Results: bltweb.net; domainkeys=pass (ok); dkim=pass (ok)</pre>
<p><a name="examples"></a><br />
<h4>6. Examples</h4>
<p>Here are some examples to help you configure your box.  Anything that normally should be private is made up.</p>
<h5>Keys</h5>
<p>For my bltweb.net domain name, here&#8217;s what my keys look like (these are not the actual keys installed on my system, those are private):</p>
<div class="prompt">
$ <span class="cmd">ls -l /etc/domainkeys/bltweb.net</span><br />
total 8.0K<br />
-rw-r&#45;&#45;&#45;&#45;&#45; 1 root qmail 887 Mar  4 18:49 default<br />
-rw-r&#45;&#45;r&#45;&#45; 1 root root&nbsp; 254 Mar  4 18:49 default.pub<br />
<br />
$ <span class="cmd">cat /etc/domainkeys/bltweb.net/default.pub</span><br />
default._domainkey	IN	TXT	&#8220;k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDbFnVeFZdlud6/xvLoMt2/g9qrQzZjg6mopp4IYgPwNxRfQTsvYJo4dxP/aIt5UcL1YWtEnOm6/VL+wzj33WvVGL8GWdJDcUWGpCOysWuKasH/sXCaxoZSFMNM02K5pOgzaIVinWZNLIv+yaDSnBC3zb35HoQOnU4KLySECWPRuQIDAQAB&#8221;<br />
<br />
$ <span class="cmd">sudo cat /etc/domainkeys/bltweb.net/default</span><br />
&#8212;&#8211;BEGIN RSA PRIVATE KEY&#8212;&#8211;<br />
MIICXAIBAAKBgQDbFnVeFZdlud6/xvLoMt2/g9qrQzZjg6mopp4IYgPwNxRfQTsv<br />
YJo4dxP/aIt5UcL1YWtEnOm6/VL+wzj33WvVGL8GWdJDcUWGpCOysWuKasH/sXCa<br />
xoZSFMNM02K5pOgzaIVinWZNLIv+yaDSnBC3zb35HoQOnU4KLySECWPRuQIDAQAB<br />
AoGAXuZniI2JuwK8Pg4LghEmhKK0waKnmIubnfYuVis+0XrKVEiJPoh1xSevfd7n<br />
K3IDJQ9By8K8a8b3gGtH7fX3ktWWFNz++DpewvWzFksC++7rhZoarBC1puWxVNYI<br />
M4xdqEtKXHIzaj3nRHM76RBD5htqa2hZkIDqfK7vDVZUkEECQQD0C5pmMGaBjO1K<br />
bC0hs8dMogxsrnwooIiHg1FO0WhOXGxKYuQGxXjR/fNz8gUyeicCPB3/piKaucGT<br />
OY1X0b9FAkEA5dHhTQTnkMD0pLow6yXTehy8NWzmIl9/EeIQu9HoXVpIGePy4Mrr<br />
ydJzaisQ+RJ8dO5C+1PeR89IRYdeGS/l5QJBAKHRG8SMbTuTdTe2uMozCYA/pttd<br />
asgJgd3Q7dXENlRXJhrArY/r2ivrJkUIAfgxVLI/qGh+AU30w2zaaWUEl70CQEe7<br />
wv8vULg2AiaIl0xOejvbTEPAwfRoqlkCnwaA9m5tB6RNKjpQHFjaf3vcBWg5BO/a<br />
jr2z5+WyJXTOU+i4sqECQC/lZY/0/cgEyyD0UL+oqYrVmlIm5Sc9Pnsu1fIRsfgC<br />
SnHS8/eTTUxNERGIYso4+wVFHR82oR8hucVYa8iY7CM=<br />
&#8212;&#8211;END RSA PRIVATE KEY&#8212;&#8211;
</div>
<h5>Signing Configuration</h5>
<p>To sign emails for all domains for which I have a key in <code>/etc/domainkeys</code>, I set the <code>control/dksign</code> configuration file:</p>
<div class="prompt">
$ <span class="cmd">ls -l /var/qmail/control/dksign</span><br />
-rw-r&#45;&#45;r&#45;&#45; 1 root root 31 Mar 17 14:02 /var/qmail/control/dksign<br />
<br />
$ <span class="cmd">cat /var/qmail/control/dksign</span><br />
/etc/domainkeys/%/default
</div>
<h5>Verify Configuration</h5>
<p>Here&#8217;s an example of my <code>/etc/tcprules.d/tcp.qmail-smtp</code> file.  Make sure you regenerate the cdb file after editing your <code>tcp.qmail-smtp</code> file!</p>
<div class="file">
# Connections from localhost are allowed to relay<br />
127.0.0.1:allow,RELAYCLIENT=&quot;&quot;,RBLSMTPD=&quot;&quot;<br />
<br />
# Everyone else can&#8217;t relay unless they auth<br />
# All signed mail is allowed, even if it&#8217;s bad, but still prepend the<br />
# Authentication-Results header<br />
:allow,DKVERIFY=&quot;&quot;,AUTH_UNSET_DKVERIFY=&quot;&quot;<br />
<br />
# Or if I want to use the recommend DKIM settings, comment out the line<br />
# above and use<br />
# :allow,DKVERIFY=&quot;DEGIJKfh,CGHIJMQRkl&quot;,AUTH_UNSET_DKVERIFY=&quot;&quot;
</div>
<p><a name="finished"></a><br />
<h4>7. Finished</h4>
<p>That&#8217;s it.  You should now have a qmail installation capable of signing and verifying messages.  More information is contained in the <code>qmail-smtpd</code> and <code>qmail-remote</code> man pages.</p>
<p>If you have any comments or find any bugs, please feel free to post a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brandonturner.net/blog/2009/03/dkim-and-domainkeys-for-qmail/feed/</wfw:commentRss>
		<slash:comments>63</slash:comments>
		</item>
	</channel>
</rss>
