Using Opendkim with postfix on Debian Buster

Just writing down notes in case I need to do this again.

I have postfix running already, and wanted to add dkim. I serve mail for two domains, which calls for a setup slightly more complicated than the default.

To get dkim working, I followed opendkim on Debian Wiki. It mostly worked, but I had to tweak it a bit, explanations follow:

First, systemd complained so I modified the path to the pid file from /var/run/… to /run/..

Then I had problems with the default socket placement. This article helped fix my problem.

I added the keys to my dns.

Now I have verified it works sending to gmail.

Here is the setup:

/etc/dkimkeys/keytable:
mail._domainkey.pauldreik.se pauldreik.se:mail2020:/etc/dkimkeys/2020.private
mail._domainkey.dreik.se dreik.se:mail2020:/etc/dkimkeys/2020.private

/etc/dkimkeys/signingtable:
*@pauldreik.se mail._domainkey.pauldreik.se
*@dreik.se mail._domainkey.dreik.se

/etc/dkimkeys/trustedhosts:
127.0.0.1

And the parts that needed modification of /etc/opendkim.conf:

Socket                  local:/var/spool/postfix/var/run/opendkim/opendkim.sock
PidFile               /run/opendkim/opendkim.pid
KeyTable file:/etc/dkimkeys/keytable
SigningTable refile:/etc/dkimkeys/signingtable
InternalHosts refile:/etc/dkimkeys/trustedhosts

And additions to /etc/postfix/main.cf:

smtpd_milters = unix:/var/run/opendkim/opendkim.sock
non_smtpd_milters = $smtpd_milters

I added dns records for mail2020._domainkey to both my domains, as txt records.