Setting up DKIM on CentOS 7

1 minute read Published:

Why install DKIM?

While I was looking at setting up DMARC, I noticed most emails I sent, we marked with a DMARC fail, because of unalignment. This is because of the difference between the Mail From and the Header From were in different domains. To be able to probably fix this, I wanted to see if DKIM could help.

Where to start.

I found a good tutorial online which I followed.

yum install opendkim
cp /etc/opendkim.conf{,.orig}
vim /etc/opendkim.conf

The contents of the file:

Selector        kari
AutoRestart             Yes
AutoRestartRate         10/1h
LogWhy                  Yes
Syslog                  Yes
SyslogSuccess           Yes
Mode                    sv
Canonicalization        relaxed/simple
ExternalIgnoreList      refile:/etc/opendkim/TrustedHosts
InternalHosts           refile:/etc/opendkim/TrustedHosts
KeyTable                refile:/etc/opendkim/KeyTable
SigningTable            refile:/etc/opendkim/SigningTable
SignatureAlgorithm      rsa-sha256
Socket                  inet:8891@localhost
PidFile                 /var/run/opendkim/opendkim.pid
UMask                   022
UserID                  opendkim:opendkim
TemporaryDirectory      /var/tmp

mkdir /etc/opendkim/keys/tigerp.net
opendkim-genkey -D /etc/opendkim/keys/tigerp.net -d tigerp.net -s kari
chown -R opendkim: /etc/opendkim/keys/tigerp.net
vim /etc/opendkim/KeyTable
The contents of the file:

# stefan 20180817 - Use our domain and our selector
kari._domainkey.tigerp.net tigerp.net:kari:/etc/opendkim/keys/tigerp.net/kari.private

vim /etc/opendkim/SigningTable
The contents of the file:

# stefan 20180817 - Use our own domain and key
*@tigerp.net kari._domainkey.tigerp.net

vim /etc/opendkim/TrustedHosts
The contents of the file:

# stefan 20180817 - add our own hostname
kari

Add the following to the postfix main.cf

smtpd_milters           = inet:127.0.0.1:8891
non_smtpd_milters       = inet:127.0.0.1:8891
Recent posts
- full list -