<rdf:RDF
    xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
    xmlns:s='http://snipsnap.org/rdf/snip-schema#'
    xml:base='http://bliki.rimuhosting.com/rdf'>
    <s:Snip rdf:about='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/dkfilter+setup'
         s:cUser='retep'
         s:oUser=''
         s:mUser='alex'>
        <s:name>knowledgebase/linux/mail/dkfilter setup</s:name>
        <s:content>If you are using postfix, and want to implement domain keys, using dkfilter is a good way to go.  If your email is not being accepted by Yahoo, this could help fix that problem. Recently I followed the instructions here to implement domain keys:&#xD;&#xA;&#xD;&#xA;http://jason.long.name/dkfilter/&#xD;&#xA;&#xD;&#xA;Also more information and specifications on Domain Keys here:&#xD;&#xA;&#xD;&#xA;http://www.dkim.org/&#xD;&#xA; &#xD;&#xA;1 Install PERL modules&#xD;&#xA;&#xD;&#xA;You can use CPAN to install these modules, although sometimes packages don&apos;t install as smoothly as you would hope.  &#xD;&#xA;&#xD;&#xA;Depending on which distro you are using, you will need the openssl-devel package or equivalent. &#xD;&#xA;&#xD;&#xA;1.1 On Centos 4 (EL4):&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;apt-get install openssl-devel&#xD;&#xA;Reading Package Lists... Done&#xD;&#xA;Building Dependency Tree... Done&#xD;&#xA;The following extra packages will be installed:&#xD;&#xA;  e2fsprogs-devel krb5-devel zlib-devel&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;After that I should be able to install the Crypt::OpenSSL::RSA module via CPAN&#xD;&#xA;{code}&#xD;&#xA;perl -MCPAN -e &apos;install Crypt::OpenSSL::RSA&apos;&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;But ran into this problem when compiling the module:&#xD;&#xA;{code}&#xD;&#xA;Running make test&#xD;&#xA;PERL_DL_NONLAZY=1 /usr/bin/perl \&quot;-MExtUtils::Command::MM&quot; &quot;-e&quot; &quot;test_harness(0, &apos;blib/lib&apos;, &apos;blib/arch&apos;)&quot; t/*.t&#xD;&#xA;t/bignum....skipped&#xD;&#xA;        all skipped: no reason given&#xD;&#xA;t/format....ok                                                               &#xD;&#xA;t/rsa.......FAILED tests 44-45       &#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;I googled for the answer, but couldn&apos;t find anything, so I entered the CPAN shell and used force install:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;perl -MCPAN -e shell&#xD;&#xA;CPAN: File::HomeDir loaded ok (v0.64)&#xD;&#xA;&#xD;&#xA;cpan shell -- CPAN exploration and modules installation (v1.9101)&#xD;&#xA;ReadLine support enabled&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;cpan[1]&gt; force install Crypt::OpenSSL::RSA&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Which resulted in this:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod&#xD;&#xA;  IROBERTS/Crypt-OpenSSL-RSA-0.24.tar.gz&#xD;&#xA;  /usr/bin/make install  -- OK&#xD;&#xA;Failed during \this command:&#xD;&#xA; IROBERTS/Crypt-OpenSSL-RSA-0.24.tar.gz       : make_test FAILED but failure ignored because &apos;force&apos; in effect&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;We can live with that for now, if we find the solution to this build problem in the future, we will make a note of it here. &#xD;&#xA;&#xD;&#xA;I was able to install the rest of the necessary modules except for Net::DNS without having to &apos;force install&apos;.   Some modules were already installed.  In theory these commands should just all work:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;perl -MCPAN -e &apos;install Crypt::OpenSSL::RSA&apos;&#xD;&#xA;perl -MCPAN -e &apos;install Mail::Address&apos;&#xD;&#xA;perl -MCPAN -e &apos;install MIME::Base64&apos;&#xD;&#xA;perl -MCPAN -e &apos;install Net::DNS&apos;&#xD;&#xA;perl -MCPAN -e &apos;install Net::Server&apos;&#xD;&#xA;perl -MCPAN -e &apos;install Test::More&apos;&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;In my experience though, there is usually some finagling you have to do here. &#xD;&#xA;&#xD;&#xA;1.1 on Debian Etch&#xD;&#xA;&#xD;&#xA;A CPAN name like Crypt::OpenSSL::RSA translates into a Debian package name of libcrypt-openssl-rsa-perl.  So a::b::c is liba-b-c-perl.  Thus, you want libcrypt-openssl-rsa-perl libmail-address-perl libmime-base64-perl ...&#xD;&#xA;&#xD;&#xA;However, Mail::Address and Test::More don&apos;t seem to be packaged in the Etch repos, so we&apos;ll install them via CPAN as above.&#xD;&#xA;&#xD;&#xA;Debian already has libmail-dkim-perl which is Mail::DKIM which is the replacement for dkfilter (per Justin Long&apos;s site).  However, the Etch package is old.&#xD;&#xA;&#xD;&#xA;1.1 on Debian Lenny&#xD;&#xA;&#xD;&#xA;You should use libmail-dkim-perl instead&#xD;&#xA;&#xD;&#xA;1.1 on EL5&#xD;&#xA;&#xD;&#xA;I prefer to install the rpmforge repo and then the perl module RPMs from there.  install rpmforge-release-0.3.6-1.el5.rf.i386.rpm and yum-protectbase (important!)&#xD;&#xA;Then install ...&#xD;&#xA;&#xD;&#xA;1 Install dkfilter&#xD;&#xA;&#xD;&#xA;With the required modules installed I downloaded the latest dkfilter tar, and compiled it, and created a user for it to run as. &#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA; wget http:\//jason.\long.name/dkfilter/dkfilter-0.11.tar.gz&#xD;&#xA;./configure --prefix=/usr/local/dkfilter&#xD;&#xA;make install&#xD;&#xA;adduser -s /sbin/nologin dkfilter&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;The package archive comes with a sample init script, which I copied into place, and found needed only one small edit to work in my environment. &#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;cp sample-dkfilter-init-script.sh /etc/init.d/dkfilter&#xD;&#xA;chmod +x /etc/init.d/dkfilter &#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;I happened to notice that &apos;hostname -d&apos; only echoed &quot;com&quot; on my host, but &apos;hostname -f&apos; seemed to give the correct output.  I edited the script: &#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;#This won&apos;t work &#xD;&#xA;#DOMAIN=`hostname -d`&#xD;&#xA;DOMAIN=`hostname -f`&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;You may find the script doesn&apos;t need to be changed for your environment, or even more edits may be necessary. &#xD;&#xA;&#xD;&#xA;Then in /usr/local/dkfilter I created a private/public key pair&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;openssl genrsa -out \private.key 1024&#xD;&#xA;Generating RSA \private key, 1024 bit \long modulus&#xD;&#xA;.......................++++++&#xD;&#xA;....++++++&#xD;&#xA;e is 65537 (0x10001)&#xD;&#xA;openssl rsa -in \private.key -pubout -out \public.key&#xD;&#xA;writing RSA key&#xD;&#xA;chown dkfilter.dkfilter *.key&#xD;&#xA;chmod 600 *.key&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;After this I pasted in the code available on the dkfilter page listed above, into:&#xD;&#xA;/etc/postfix/master.cf&#xD;&#xA;&#xD;&#xA;It was important to read the FAQ and add this content filter to the pickup filter in master.cf:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;pickup    fifo  n       -       n       60      1       pickup&#xD;&#xA;    -o content_filter=dksign:127.0.0.1:10027&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;This is important if you are sending mail locally, from an application, i.e. automated responders which email passwords to you users.  &#xD;&#xA;&#xD;&#xA;1 Editing your DNS Zone records&#xD;&#xA;&#xD;&#xA;This is easy to do using your Rimuhosting DNS control panel.  From the control panel, go to &quot;Manage your DNS&quot;, if you have more than one domain, select the zone you want to add domain keys to.  &#xD;&#xA;&#xD;&#xA;In the &quot;Edit&quot; menu, click on &quot;Text (TXT)&quot;.   Your current records will be displayed, and beneath that will be a box to add a new record.   We are going to add two records.  A policy and a selector record. &#xD;&#xA;&#xD;&#xA;First the policy &#xD;&#xA;&#xD;&#xA;In the &quot;Name&quot; field, put:&#xD;&#xA;{code}&#xD;&#xA;_domainkey&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;In the &quot;Value&quot; field put:&#xD;&#xA;{code}&#xD;&#xA;t=y; o=~&#xD;&#xA;{code}&#xD;&#xA; &#xD;&#xA;You can check this record here: http://domainkeys.sourceforge.net/policycheck.html&#xD;&#xA;&#xD;&#xA;To find the meaning of this concise and cryptic code, consult section 3.6.2 &quot;Interim sending domain policy&quot; of the Domain Keys Internet Draft available here: &#xD;&#xA;http://sourceforge.net/docman/index.php?group_id=107680&#xD;&#xA;&#xD;&#xA;Assuming you are following the install instructions on the dkfilter (http://jason.long.name/dkfilter/)&#xD;&#xA; page to the letter.   Your next step is to add the selector record. &#xD;&#xA;&#xD;&#xA;In the &quot;Name&quot; field, put:&#xD;&#xA;{code}&#xD;&#xA;selector1._domainkey&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;In the &quot;Value&quot; field you will put something like this:&#xD;&#xA;{code}&#xD;&#xA;k=rsa; p=MHwwDQYJK ... OprwIDAQAB; t=y&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;You can test your setup by emailing test@dktest.jason.long.name, you should get happy message back saying something like this:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;*** This is an automated response ***&#xD;&#xA;&#xD;&#xA;This is the result of the message verification:&#xD;&#xA;  pass&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;You can also test here:&#xD;&#xA;http://domainkeys.sourceforge.net/selectorcheck.html&#xD;&#xA;&#xD;&#xA;But the ultimate test is to send a message to Yahoo, especially if your previous logs had things like this in them:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;postfix/smtp[17266]: connect to b.mx.mail.yahoo.com[66.196.97.250]: server refused to talk to me: 421 Message from (xx.xx.xxx.xx) temporarily deferred - 4.16.50. Please refer to http://help.yahoo.com/help/us/mail/defer/defer-06.html   (port 25)&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;After setting up domain keys you should get something like this in your logs:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA; dkfilter.out[15741]: DomainKeys signing - signed;&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;The Yahoo webmail client will say something like this underneath the senders email address:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;Yahoo! DomainKeys has confirmed that \this message was sent by root@yourdomain.com&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;1 Using JavaMail?&#xD;&#xA;&#xD;&#xA;Now change the default port JavaMail is sending on from 25, to 587 to sign outgoing messages.   i.e. if your Java app is sending out automated emails to your site&apos;s users. </s:content>
        <s:mTime>2007-12-12 23:55:39.0</s:mTime>
        <s:cTime>2007-05-14 21:14:49.0</s:cTime>
        <s:comments
             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
        <s:snipLinks>
            <rdf:Bag>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail'/>
                <rdf:li rdf:resource='#snipsnap-search'/>
                <rdf:li rdf:resource='#knowledgebase'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/Mail and DNS'/>
                <rdf:li>
                    <s:Snip rdf:about='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/dkfilter+setup'>
                        <s:attachments
                             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
                    </s:Snip>
                </rdf:li>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/mass emailing best practices'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/'/>
                <rdf:li rdf:resource='#john'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#john/2007-12-15/1'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/'/>
                <rdf:li rdf:resource='#ivan'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/mail not going through'/>
                <rdf:li rdf:resource='#snipsnap-index'/>
            </rdf:Bag>
        </s:snipLinks>
    </s:Snip>
</rdf:RDF>
