LoginSignup
4
1

CentOS Stream 8、CentOS Stream 9 で opendkim をインストールする手順(仮)

Last updated at Posted at 2022-06-17

CentOS Stream 8、CentOS Stream 9 に opendkim-2.11 をインストールする手順です。
正しいインストール・設定方法のドキュメントを見つけることができず、試行錯誤した結果ですので、信用しすぎないでください。
あと、各設定ファイルの内容は割愛していますので、ソフトウェアドキュメントや先達の方々の情報を参照してください。

2023年6月加筆

(新)1.CRBリポジトリの有効化

この手順を踏むと、下記1.中の libmilter, libmemcached のインストールがCRBリポジトリより行われます。

CentOS Stream 9 のリポジトリの中で有効になっているものを確認。

# dnf repolist --all
・・・
crb                         CentOS Stream 9 - CRB                       disabled
・・・

CRBリポジトリの有効化。

# dnf config-manager --set-enabled crb
# dnf repolist --all
・・・
crb                         CentOS Stream 9 - CRB                       enabled
・・・

/etc/yum.repos.d/centos.repo にCRBリポジトリの設定が追加されていることを確認すればOKです。

そして、dnfコマンドで opendkim, opendkim-tools をインストールします。

dnf --enablerepo=epel install opendkim opendkim-tools

0.前提条件

  • postfix がインストールされていること
  • dnfコマンドがEPELリポジトリを参照できること

1.opendkimのインストール

# dnf --enablerepo=epel install opendkim opendkim-tools

opendkim-tools も入れないと、opendkim-keygen コマンドがインストールされませんでした。
また、CentOS Stream 9 の場合、

・・・
Error:
Problem: conflicting requests
  - nothing provides libmilter.so.1.0()(64bit) needed by opendkim-2.11.0-0.28.el9.x86_64
  - nothing provides libmemcached.so.11()(64bit) needed by opendkim-2.11.0-0.28.el9.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

となり opendkim のインストールに libmilter.so.1.0 と libmemcached.so.11 が必要となることがわかりました。
Webサイト pkg.org で適宜 rpm パッケージを見つけてダウロードしてインストールしてください。

# cd /usr/local/src

# wget http://mirror.stream.centos.org/9-stream/CRB/x86_64/os/Packages/sendmail-milter-8.16.1-10.el9.x86_64.rpm
# dnf install sendmail-milter-8.16.1-10.el9.x86_64.rpm

# wget http://mirror.stream.centos.org/9-stream/CRB/x86_64/os/Packages/libmemcached-awesome-1.1.0-12.el9.x86_64.rpm
# dnf install libmemcached-awesome-1.1.0-12.el9.x86_64.rpm

CentOS Stream 8, 9 特有の問題は以上だと思います。2.以降は他のプラットフォームと同様の手順かと思います。

2.opendkimの設定

キーファイル(公開鍵と秘密鍵)を作成して、opendkimサービスがリードできるようにパーミッションを変更します。パーミッションの変更を忘れると、opendkimサービス起動時にパーミッションエラーになります。

# mkdir /etc/opendkim/keys/xxxxxx
# opendkim-genkey --directory=/etc/opendkim/keys/xxxxxx --domain=xxxxxx -s yyyyyy
# chown opendkim:opendkim -R /etc/opendkim/keys/xxxxxx

設定ファイルを各サイトの設定にあわせて修正します。

# vi /etc/opendkim/KeyTable   
# vi /etc/opendkim/SigningTable
# vi /etc/sysconfig/opendkim
# cp /etc/opendkim.conf /etc/opendkim.conf.org
# vi /etc/opendkim.conf

3.postfixの設定

# vi /etc/postfix/main.cf
末尾に追加
milter_default_action = accept
non_smtpd_milters = $smtpd_milters
smtpd_milters = inet:127.0.0.1:8891

4.opendkimサービスの起動とOS起動時の有効化、postfixの再起動

# systemctl start opendkim
# systemctl enable opendkim
# systemctl restart postfix

5.DNSの設定

2.で作成した公開鍵 yyyyyy.txt の内容をもとにDNSレコードを追加します。そのまま登録すれば良いわけではありませんので、適宜ダブルクォーテーションの対応など修正が必要です。

# cat /etc/opendkim/keys/xxxxxx/yyyyyy.txt

また、_adsp._domainkey というレコードも追加しました。
ADSP(Author Domain Signing Practice)は、DKIMの認証結果をどのように扱うべきかを示すポリシーを送信側で公開するもののようで、ここでは

dkim=unknown

としました。
あと、DKIMのDNS設定が適切になされているのかは、次のようなチェッカーを利用すると良いかもしれません。

https://mxtoolbox.com/dkim.aspx

6.Gmailアドレス宛にメールを送信してみる

メールのヘッダの Authentication-Results: に、

dkim=pass

が付与されればよいものと思います。

以上

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1