opendmarcインストール
[root@ns etc]# dnf install opendmarc opendmarc-tools
DNSへテキストレコードを追加
_dmarc IN TXT "v=DMARC1; p=reject; rua=mailto:uketori@example.net"
p=rejectとポリシーについては個人サイトのため最初からreject要求での設定運用としている。
設定ファイルの確認と修正
私の場合、opendkim同様出来る限りデフォルトのままで動作させたいので必要最低限の修正に留めた。
そんなわけで修正ヶ所はわずか2ヶ所です。
MTAはsendmail、milterとはunixソケットでの接続としています。
root@ns:/etc# cat opendmarc.conf
## opendmarc.conf -- configuration file for OpenDMARC filter
##
## Copyright (c) 2012-2015, 2018, 2021, The Trusted Domain Project.
## All rights reserved.
## DEPRECATED CONFIGURATION OPTIONS
##
## The following configuration options are no longer valid. They should be
## removed from your existing configuration file to prevent potential issues.
## Failure to do so may result in opendmarc being unable to start.
##
## Renamed in 1.3.0:
## ForensicReports became FailureReports
## ForensicReportsBcc became FailureReportsBcc
## ForensicReportsOnNone became FailureReportsOnNone
## ForensicReportsSentBy became FailureReportsSentBy
## CONFIGURATION OPTIONS
## AuthservID (string)
## defaults to MTA name
##
## Sets the "authserv-id" to use when generating the Authentication-Results:
## header field after verifying a message. If the string "HOSTNAME" is
## provided, the name of the host running the filter (as returned by the
## gethostname(3) function) will be used.
#
# AuthservID name
AuthservID mail.example.net
↑運用サーバーのホスト名に変更します。
〜〜〜 省略 〜〜〜
## IgnoreHosts path
## default (internal)
##
## Specifies the path to a file that contains a list of hostnames, IP
## addresses, and/or CIDR expressions identifying hosts whose SMTP
## connections are to be ignored by the filter. If not specified, defaults
## to "127.0.0.1" only.
#
# IgnoreHosts /etc/opendmarc/ignore.hosts
IgnoreHosts /etc/opendmarc/ignore.hosts
↑コメントをはずしignore.hostsファイルにメール送信PCの内部ネットワークアドレスを追記します。
〜〜〜 省略 〜〜〜
## UserID user[:group]
## default (none)
##
## Attempts to become the specified userid before starting operations.
## The process will be assigned all of the groups and primary group ID of
## the named userid unless an alternate group is specified.
#
UserID opendmarc:mail
sendmail.cf 書き換え
sendmail.mcにopendmarcのインプットメールフィルターを追加します。
フィルターのインプット順は検証の優先順位からopendkimの次とする。
INPUT_MAIL_FILTER(`opendkim', `S=local:/var/run/opendkim/opendkim.sock, F=, T=R:2m')dnl
INPUT_MAIL_FILTER(`opendmrac', `S=local:/var/run/opendmarc/opendmarc.sock, F=, T=R:2m')dnl
INPUT_MAIL_FILTER(`spamassassin', `S=local:/var/run/spamass-milter/spamass-milter.sock, F=, T=C:15m;S:4m;R:4m;E:10m')dnl
INPUT_MAIL_FILTER(`clmilter', `S=local:/var/run/clamav-milter/clamav-milter.socket, F=, T=S:4m;R:4m')dnl
define(`confINPUT_MAIL_FILTERS', `opendkim,opendmarc,spamassassin,clmilter')dnl
DNS の確認
[root@ns etc]# dig _dmarc.example.net txt
; <<>> DiG 9.18.47 <<>> _dmarc.example.net txt
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21171
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;_dmarc.example.net. IN TXT
;; ANSWER SECTION:
_dmarc.example.net. 86400 IN TXT "v=DMARC1; p=reject; rua=mailto:uketori@example.net"
;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Sat May 09 18:47:53 JST 2026
;; MSG SIZE rcvd: 112
セカンダリーDNSも確認する
[root@ns etc]# dig ns2.example.net +short _dmarc.example.net txt
233.144.122.77
"v=DMARC1; p=reject; rua=mailto:uketori@example.net"
しっかり返してくれました。転送OKですね。なお、DNSさわったときはシリアルアップも忘れずにね。
opendmarcを自動起動にする
[root@ns etc]# systemctl enable opendmarc
導入後記
opendmarcの動作はさせましたが検証レポートの送信はまだ未導入です。私のメール利用ではgmail利用者への送信でレポートが返ってくる程度ですね。
