{"id":5176,"date":"2014-10-15T13:32:59","date_gmt":"2014-10-15T18:32:59","guid":{"rendered":"https:\/\/secure.rosehosting.com\/blog\/?p=5176"},"modified":"2022-12-08T06:26:45","modified_gmt":"2022-12-08T12:26:45","slug":"how-to-install-and-configure-dkim-with-opendkim-and-exim-on-a-centos-7-vps","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-and-configure-dkim-with-opendkim-and-exim-on-a-centos-7-vps\/","title":{"rendered":"How to install and configure dkim with OpenDKIM and Exim on a CentOS 7 VPS"},"content":{"rendered":"
In this article we will walk you through the steps of installing and configuring dkim with OpenDKIM and Exim on a CentOS 7 SSD VPS<\/a><\/strong>.<\/p>\n You should have a working mail server<\/a> setup with Exim<\/strong> before proceeding with this tutorial. Check our guide on how to set-up a mail server with Exim and Dovecot on a CentOS 7 VPS<\/a> if you don’t have setup a mail server yet.<\/p>\n What is OpenDKIM?<\/strong><\/p>\n OpenDKIM<\/a> is an open source implementation of the DKIM (Domain Keys Identified Mail<\/strong>) sender authentication system which is an email validation system designed to detect email spoofing<\/strong> by providing a mechanism to allow receiving mail exchangers to check that incoming mail from a domain is authorized<\/strong> by that domain’s administrators. A digital signature<\/strong> included with the message can be validated<\/strong> by the recipient using the signer’s public key published in the DNS.<\/p>\n <\/p>\n <\/p>\n Before you start with the installation of OpenDKIM<\/strong>, once you’re in a <\/p>\n <\/p>\n OpenDKIM is available in the EPEL (Extra Packages for Enterprise Linux) repositry, so let’s enable EPEL repository on the CentOS VPS<\/a> using:<\/p>\n if you get a 404 not found, go at https:\/\/dl.fedoraproject.org\/pub\/epel\/7\/x86_64\/Packages\/e\/<\/a> and install the latest next, check if EPEL has been enabled on your system using:<\/p>\n <\/p>\n Once EPEL has been enabled on your linux server<\/a>, install OpenDKIM using the command below:<\/p>\n and proceed with configuring it by renaming its default configuration to something like To learn more about <\/p>\n Now generate a set of keys for your once the keys are generated, add next, edit and add your domain and your hostname as trusted hosts in assuming the domain in question is ‘mydomain.com’ and server’s hostname is set to ‘host.mydomain.com’<\/em><\/p>\n finally, edit your you can verify if your dkim TXT record is valid using <\/p>\n Now set-up Exim to use OpenDKIM<\/strong> for signing the emails by editing restart Exim and Opendkim for the changes to take effect using:<\/p>\n <\/p>\n Of course you don\u2019t have to do any of this if you use one of our Linux VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to install and configure OpenDKIM with Exim<\/strong>. They are available 24×7 and will take care of your request immediately.<\/p>\n PS<\/span>.<\/strong> If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" In this article we will walk you through the steps of installing and configuring dkim with OpenDKIM and Exim on … <\/p>\nUPDATE THE SYSTEM<\/b><\/h4>\n
ssh<\/code> to your server and initiate a
screen<\/code> session using the command below:<\/p>\n
## screen -U -S exim-opendkim<\/pre>\n
screen<\/code> session, update your CentOS 7 VPS<\/a> using
yum<\/code> as in:<\/p>\n
## yum update<\/pre>\n
INSTALL SOME PACKAGES<\/b><\/h4>\n
## yum install curl wget vim openssl man<\/pre>\n
ENABLE EPEL REPOSITORY<\/b><\/h4>\n
## yum install http:\/\/dl.fedoraproject.org\/pub\/epel\/7\/x86_64\/e\/epel-release-7-2.noarch.rpm<\/pre>\n
epel-release<\/code> rpm package available.<\/em><\/p>\n
## yum repolist<\/pre>\n
INSTALL OPENDKIM<\/b><\/h4>\n
## yum install opendkim<\/pre>\n
\/etc\/opendkim.conf.orig<\/code> and adding the following to
\/etc\/opendkim.conf<\/code><\/p>\n
## mv \/etc\/opendkim.conf{,.orig}\r\n## vim \/etc\/opendkim.conf<\/pre>\n
AutoRestart Yes\r\nAutoRestartRate 10\/1h\r\nLogWhy Yes\r\nSyslog Yes\r\nSyslogSuccess Yes\r\nMode sv\r\nCanonicalization relaxed\/simple\r\nExternalIgnoreList refile:\/etc\/opendkim\/TrustedHosts\r\nInternalHosts refile:\/etc\/opendkim\/TrustedHosts\r\nKeyTable refile:\/etc\/opendkim\/KeyTable\r\nSigningTable refile:\/etc\/opendkim\/SigningTable\r\nSignatureAlgorithm rsa-sha256\r\nSocket inet:8891@localhost\r\nPidFile \/var\/run\/opendkim\/opendkim.pid\r\nUMask 022\r\nUserID opendkim:opendkim\r\nTemporaryDirectory \/var\/tmp<\/pre>\n
opendkim.conf<\/code> you can check
man opendkim.conf<\/code>.<\/p>\n
SET-UP DKIM PUBLIC\/PRIVATE KEYS<\/b><\/h4>\n
mydomain.com<\/code> domain name using the commands below:<\/p>\n
## mkdir \/etc\/opendkim\/keys\/mydomain.com\r\n## opendkim-genkey -D \/etc\/opendkim\/keys\/mydomain.com\/ -d mydomain.com -s default\r\n## chown -R opendkim: \/etc\/opendkim\/keys\/mydomain.com\r\n## mv \/etc\/opendkim\/keys\/mydomain.com\/default.private \/etc\/opendkim\/keys\/mydomain.com\/default<\/pre>\n
mydomain.com<\/code> to OpenDKIM\u2019s key table by adding the following record in
\/etc\/opendkim\/KeyTable<\/code><\/p>\n
default._domainkey.mydomain.com mydomain.com:default:\/etc\/opendkim\/keys\/mydomain.com\/default<\/pre>\n
\/etc\/opendkim\/SigningTable<\/code> and add the following record to OpenDKIM\u2019s signing table:<\/p>\n
*@mydomain.com default._domainkey.mydomain.com<\/pre>\n
\/etc\/opendkim\/TrustedHosts<\/code>:<\/p>\n
127.0.0.1\r\nmydomain.com\r\nhost.mydomain.com<\/pre>\n
mydomain.com<\/code> DNS zone and add the TXT record from
\/etc\/opendkim\/keys\/mydomain.com\/default.txt<\/code><\/p>\n
default._domainkey IN TXT ( \"v=DKIM1; k=rsa; \"\r\n \"p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDApHRr7ZmXRaAB+RQRbP4VdMwIrIHIP18KFtXRsv\/xpWc0Gix6ZXN13fcG03KNGKZo2PY+csPkGC5quDnH5V0JEhDZ78KcDWFsU6u4fr9ktVAdt6P7jWXjcyqdHOZ8+YN4cAeU4lRFNgQvdupIcByYwzPYMgBFHfJm9014HvRqhwIDAQAB\" ) ; ----- DKIM key default for mydomain.com<\/pre>\n
dig<\/code> for example:<\/p>\n
## dig +short default._domainkey.mydomain.com TXT\r\n\r\n\"v=DKIM1\\; k=rsa\\; \" \"p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDApHRr7ZmXRaAB+RQRbP4VdMwIrIHIP18KFtXRsv\/xpWc0Gix6ZXN13fcG03KNGKZo2PY+csPkGC5quDnH5V0JEhDZ78KcDWFsU6u4fr9ktVAdt6P7jWXjcyqdHOZ8+YN4cAeU4lRFNgQvdupIcByYwzPYMgBFHfJm9014HvRqhwIDAQAB\"<\/pre>\n
CONFIGURE EXIM<\/b><\/h4>\n
\/etc\/exim\/exim.conf<\/code> and adding the following to the
remote_smtp<\/code> transport:<\/p>\n
remote_smtp:\r\n driver = smtp\r\n dkim_domain = $sender_address_domain\r\n dkim_selector = default\r\n dkim_private_key = ${if exists{\/etc\/opendkim\/keys\/$sender_address_domain\/default}{\/etc\/opendkim\/keys\/$sender_address_domain\/default}{0}}\r\n dkim_canon = relaxed\r\n dkim_strict = 0<\/pre>\n
## systemctl restart exim\r\n## systemctl status exim\r\n\r\n## systemctl restart opendkim\r\n## systemctl status opendkim\r\n## systemctl enable opendkim<\/pre>\n
LET US DO THIS FOR YOU?<\/b><\/h4>\n