Glen Pitt-Pladdy :: BlogDKIM & Postfix revisited with opendkim | |||
A few years back I wrote a popular Debian orientated post on getting DKIM & SPF working with Postfix in a multi-domain, multi-key setup. Since then things have moved on. Packages used are no longer in Wheezy, old style DK seems to be safely gone now (no need to sign to avoid legacy setups rejecting your mail) and I'm building a new virtualised mail server I can migrate around or easily recover in failure scenarios. This is more or less the steps I'm following to get things working with the new opendkim (fork of dkim-filter) packages. There is no need to change the SPF aspects of the last post, so this is purely DKIM. I'm assuming anyone who finds their way to this page knows what DKIM is and the benefits of it even if beyond the big players and a few small scale mail servers, nobody else seems to care that much even if DKIM and SPF massively reduce SPAM, Phishing and other mail related abuse. Notes on chroot in PostfixThe use of chroot in Postfix (at least on Debian and derivatives which is what I am mostly using) seems to have a history of changing. At this point I'm basing this on the defaults of my fresh install of Wheezy where broadly queue management and final-destination (on the local machine) delivery are not chroot, and everything public facing and more likely to be attacked (eg. smtpd) is. If your configuration differs then things like paths of milter sockets may need changing to match where your Postfix services can access them or will be looking for them. What's changed?Since opendkim is a fork of dkim-filter used previously, much of the basic things remain the same, although configuration directives have changed names, in some cases subtly changed function, and some file formats are changed. I'm also taking the opportunity to make things a bit tidier and easier to manage in the long term. opendkim ConfigurationFor the purposes of simplicity, I'm using a selector of mailservername, but if you have a more complex setup or other reasons to do otherwise then adapt the config as neccessary. Aside from the obvious stuff (install opendkim and opendkim-tools), like before we need to generate some keys to use:
# mkdir -p /etc/mail/dkim/keys/domain1 Repeat this for each domain this server handles. Then we need to create some extra configuration to handle things neatly with multiple domains. First up we need to configure what keys are used. I created /etc/opendkim-KeyTable.conf but this is an arbitrary name since we will tell opendkim what file to find this config:
domain1identifier domain1:mailservername:/etc/mail/dkim/keys/domain1/mailservername.private This maps an identifier label onto 3 parameters:
Next we need to tell opendkim when to use which configuration. I created /etc/opendkim-SigningTable.conf which again is an arbitrary name we will configure later:
*@domain1 domain1identifier Now we pull it all together by updating the /etc/opendkim.conf and adding the relevant config. The default shipped config is benign so we can simply add to the file:
Socket inet:8891@localhost Things to note here:
Finally restart opendkim to bring all the change into operation: # service opendkim restart Postfix ConfigurationIn /etc/postfix/main.cf add the config to use the milter socket:
smtpd_milters = Then restart Postfix and it should start signing mails. DNS ConfigurationAt this point the rest of the world needs to know what to do with mail from the server and how to validate it. For this we need to add TXT records to each of the domains we configured for DKIM. The selector record is the one contained in the .txt file created with each key above: mailservername._domainkey IN TXT "v=DKIM1; k=rsa; p=MIGf.... Additionally we need to set our policy. This is a bit of a messy area as the "new" standard is ADSP, but there are a bunch of systems still on legacy Domainkeys style approaches. To avoid problems I personally set the legacy record to non-production, but the ADSP record to full enforcement:
_domainkey IN TXT "t=y;o=~" At that point you should have a fully working opendkim setup with Postfix.
|
|||
This is a bunch of random thoughts, ideas and other nonsense, and is not intended to be taken seriously. I'm experimenting and mostly have no idea what I am doing with most of this so it should be taken with cuation and at your own risk. Intrustive technologies are minimised where possible. For the purposes of reducing abuse and other risks hCaptcha is used and has it's own policies linked from the widget.
Copyright Glen Pitt-Pladdy 2008-2023
|