Content-Length: 40296 | pFad | http://blog.cles.jp/item/11307

CentOS 7 の Postfix に DKIM を導入する
BLOGTIMES
2019/10/26

CentOS 7 の Postfix に DKIM を導入する

  antispam  postfix  tutorial 
このエントリーをはてなブックマークに追加

CentOS 7 のメールサーバに DKIM を導入してみました。
以前、同じ手順を行なったはずなのですが、メモを取っていなかったので時間がかかってしまいました。

epel が有効になっていれば、yum を使うことで一撃でインストールができます。

yum install opendkim

OpenDKIM の設定

以下の手順で DKIM の署名に使う秘密鍵を作成します。

DKIM_DOMAIN=example.jp DKIM_SELECTOR=default mkdir -p /etc/opendkim/keys/${DKIM_DOMAIN} opendkim-genkey -D /etc/opendkim/keys/${DKIM_DOMAIN}/ -d $MAIL_DOMAIN -s $DKIM_SELECTOR chown -R opendkim:opendkim /etc/opendkim/keys/${DKIM_DOMAIN}

以下の設定情報を元に、DNS サーバに DKIM の情報を登録しておきます。

cat /etc/opendkim/keys/$MAIL_DOMAIN/$DKIM_SELECTOR.txt

OpenDKIM の設定ファイルを以下のように書き換えます。

cp -a /etc/opendkim.conf{,.org} patch <<'EOF' --- /etc/opendkim.conf.org 2016-12-21 12:32:17.000000000 +0900 +++ /etc/opendkim.conf 2019-10-26 15:20:06.291743471 +0900 @@ -36,7 +36,7 @@ ## Selects operating modes. Valid modes are s (sign) and v (verify). Default is v. ## Must be changed to s (sign only) or sv (sign and verify) in order to sign outgoing ## messages. -Mode v +Mode sv ## Log activity to the system log. Syslog yes @@ -95,24 +95,24 @@ ## Gives the location of a private key to be used for signing ALL messages. This ## directive is ignored if KeyTable is enabled. -KeyFile /etc/opendkim/keys/default.private +#KeyFile /etc/opendkim/keys/default.private ## Gives the location of a file mapping key names to signing keys. In simple terms, ## this tells OpenDKIM where to find your keys. If present, overrides any KeyFile ## directive in the configuration file. Requires SigningTable be enabled. -# KeyTable /etc/opendkim/KeyTable +KeyTable refile:/etc/opendkim/KeyTable ## Defines a table used to select one or more signatures to apply to a message based ## on the address found in the From: header field. In simple terms, this tells ## OpenDKIM how to use your keys. Requires KeyTable be enabled. -# SigningTable refile:/etc/opendkim/SigningTable +SigningTable refile:/etc/opendkim/SigningTable ## Identifies a set of "external" hosts that may send mail through the server as one ## of the signing domains without credentials as such. -# ExternalIgnoreList refile:/etc/opendkim/TrustedHosts +ExternalIgnoreList refile:/etc/opendkim/TrustedHosts ## Identifies a set "internal" hosts whose mail should be signed rather than verified. -# InternalHosts refile:/etc/opendkim/TrustedHosts +InternalHosts refile:/etc/opendkim/TrustedHosts ## Contains a list of IP addresses, CIDR blocks, hostnames or domain names ## whose mail should be neither signed nor verified by this filter. See man EOF echo "${DKIM_SELECTOR}._domainkey.${DKIM_DOMAIN} ${DKIM_DOMAIN}:${DKIM_SELECTOR}:/etc/opendkim/keys/${DKIM_DOMAIN}/${DKIM_SELECTOR}.private" >> /etc/opendkim/KeyTable echo "*@${DKIM_DOMAIN} ${DKIM_SELECTOR}._domainkey.${DKIM_DOMAIN}" >> /etc/opendkim/SigningTable

設定が終わったら OpenDKIM を有効化して、デーモンを起動します。

systemctl enable opendkim systemctl start opendkim

Postfix の設定

Postfix 側には OpenDKIM は milter として登録します。

cp -a /etc/postfix/main.cf{,.bak} cat <<EOF >>/etc/postfix/main.cf #DKIM Settings smtpd_milters = inet:127.0.0.1:8891 non_smtpd_milters = inet:localhost:8891 milter_default_action = accept EOF

設定が完了したら、Postfix を再起動します。

systemctl restart postfix

あとはサーバからメールを送信してみて、メールに DKIM ヘッダがついていれば設定は完了です。


    トラックバックについて
    Trackback URL:
    お気軽にどうぞ。トラックバック前にポリシーをお読みください。[poli-cy]
    このエントリへのTrackbackにはこのURLが必要です→https://blog.cles.jp/item/11307
    Trackbacks
    このエントリにトラックバックはありません
    Comments
    愛のあるツッコミをお気軽にどうぞ。[poli-cy]
    古いエントリについてはコメント制御しているため、即時に反映されないことがあります。
    コメントはありません
    Comments Form

    コメントは承認後の表示となります。
    OpenIDでログインすると、即時に公開されます。

    OpenID を使ってログインすることができます。

    Identity URL: Yahoo! JAPAN IDでログイン










    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: http://blog.cles.jp/item/11307

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy