「メールサーバー」カテゴリーアーカイブ

新サーバにDKIMproxy導入でgoogle先生に叱られた2

 

gmailでのみ”no key”となるので、まず最初に検索ワード”gmail DKIM”を検索しました。

すると以下のサイトが怪しそう

http://support.google.com/a/bin/answer.py?hl=ja&answer=174124

以下引用

———————————————————————————————

ドメイン キーを使用したメールの署名を開始するには:

  1. Google Apps 管理者用コントロール パネルにログインします。
    URL は https://www.google.com/a/cpanel/primay-domain-name です。
  2. 「primary-domain-name」の部分は Google Apps のお申し込みに使用したドメイン名に置き換えてください。
  3. ページ上部のメニューから [高度なツール] を選択します。
  4. [メールを認証] セクションで、[メール認証(DKIM)を設定] をクリックします。
  5. ドメイン キーを使用して署名するメールのドメインを選択します。
    このページには、選択したドメインのドメイン キーのステータスが表示されます。
  6. [認証を開始] をクリックします。

———————————————————————————————–

まずGoogle Appsのアカウントを取得する必要があるようです。

アカウントを取得し、管理者用コントロール パネルから 高度なツール⇒メール認証と

たどり dnsサーバの google._domainkey txtフィールドを取得します。

私のgoogle._domainkeyは以下でした。

———————————————————————————————–

DNS ホストの名前(TXT レコード名):
google._domainkey
TXT レコード値:
v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI5xWmuPFeKPcYtThrJ
UwuxsKQwD/kvN13agXAUsMQb/Ieqq/+l3NCJodJXHUD78gZ0r43ueksQ46iFvvgUksNf2/Euhqj1EK
j3QatLO3kjm4mMNbAbDABfs/Cn+lPJudhPRKT7WJlW6DFf/TeILtxSIndhid+4X7i8z0o6J1bywIDAQAB
—————————————————————————————————————-
しかしprivate.keyがありませんので、自鯖でこの公開キーで署名をつけることはできません。

 

dnsサーバにこのキーがあると、gmailで自鯖のDKIM署名を有効にしてくれるのではないかと

 

一縷の望みを持って、自鯖からgmail宛にメールを送ってみました。

 

結果は、

 

Authentication-Results: mx.google.com;
spf=pass (google.com: domain of yoshio@hstech.jp designates 219.105.37.34 as permitted sender) smtp.mail=yoshio@hstech.jp;
dkim=neutral (no key) header.i=@
予想はしてましたが、署名は有効になりません。
Google Appsで自ドメイン(hstech.jp)を有効にしてからウェブからメールを送ると
—————————————————————————————————————————-
Delivered-To: hstech99@gmail.com
Received: by 10.64.64.225 with SMTP id r1csp55755ies;
Sun, 17 Feb 2013 15:08:43 -0800 (PST)
X-Received: by 10.50.100.193 with SMTP id fa1mr2568987igb.59.1361142523676;
Sun, 17 Feb 2013 15:08:43 -0800 (PST)
Return-Path: <yoshio@hstech.jp> Google Appsから自メールアドレスでメールを送れる
Received: from mail-ie0-x243.google.com (ie-in-x0243.1e100.net [2607:f8b0:4001:c03::243])IPv6だ!
by mx.google.com with ESMTPS id b8si7949992igc.57.2013.02.17.15.08.42
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
Sun, 17 Feb 2013 15:08:42 -0800 (PST)
Received-SPF: softfail (google.com: domain of transitioning yoshio@hstech.jp does not designate 2607:f8b0:4001:c03::243 as permitted sender) client-ip=2607:f8b0:4001:c03::243;
Authentication-Results: mx.google.com;自鯖ではないので当然SPFはpermitted senderではありません、google鯖をmxで指定して”メールはgoogleで”ということでしょう。
spf=softfail (google.com: domain of transitioning yoshio@hstech.jp does not designate 2607:f8b0:4001:c03::243 as permitted sender) smtp.mail=yoshio@hstech.jp;
dkim=pass header.i=@hstech.jp passだがあまりうれしくない(笑) 
Received: by mail-ie0-x243.google.com with SMTP id c11so3242111ieb.10
for <hstech99@gmail.com>; Sun, 17 Feb 2013 15:08:42 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;   以下略
————————————————————————————————————–

 

dkim=passとしたければ、google鯖からメールを送る必要があるようです。

 

マイナーな自鯖は使うなということでしょうか?なんだか複雑!!

 

 

前記事

 

新サーバにDKIMproxy導入でgoogle先生に叱られた

 

新サーバにDKIMproxy導入でgoogle先生に叱られた

DKIMproxy導入記録です。前記事は。

DKIMproxy導入覚書-はまり処満載で撃沈寸前!その1

DKIMproxy導入覚書-はまり処満載で撃沈寸前!その2

DKIMproxy導入覚書-はまり処満載で撃沈寸前!その3

送信ドメイン認証導入総括

今回新サーバに導入の覚書です。

上記手順でインストールは問題なく動作確認もsa-test@sendmail.netへの送信テストの結果は以下

———————————————————————————————————–

sendmail.net Sender Authentication Auto-Responder $Revision: 1.19 $

This
service runs at <sa-test@sendmail.net> and allows
remote users
to perform a simple, automated test to see if different
Sender
Authentication schemes are working.  Mail sent to this service
is
checked by our Sender Authentication filters for any valid
credentials or
signatures.  A script receives the message, checks
for a special header with
the results of the tests, and composes
this response message based on what it
finds.  This response is also
signed with DomainKeys Identified Mail
(DKIM).

Please note that the DKIM filter signing this reply message
conforms
to the latest IETF standard version, and thus may not be successfully
verified by older implementations.  If you are using dkim-filter
from
Sendmail, Inc., upgrade to OpenDKIM to be compatible with the
most
recent version of DKIM.

Note that DomainKeys has been removed in
favor of DKIM.  Sites still
using DomainKeys should upgrade to DKIM
ASAP.

We hope this service has been helpful to you.

Authentication
System:       DomainKeys Identified Mail (DKIM)
Result:      DKIM signature confirmed GOOD
Description:              Signature
verified, message arrived intact
Reporting host:
services.sendmail.com
More information:         http://dkim.org/
Sendmail milter:          http://opendkim.org/

Authentication
System:       Sender ID
Result:                   SID data confirmed GOOD
Description:              Sending host is authorized for
sending domain
Reporting host:           services.sendmail.com
More
information:         http://www.microsoft.com/senderid

Sendmail milter:          https://sourceforge.net/projects/sid-milter/

Authentication
System:       Sender Permitted From (SPF)
Result:                   SPF
data confirmed GOOD
Description:              Sending host is authorized
for sending domain
Reporting host:           services.sendmail.com

More information:         http://openspf.org/
————————————————————————————————————

と問題なくyahoo.co.jp宛のメールも迷惑メールには振り分けられるもののDKIM及びDomainKey認証の結果は

以下のように問題ありませんでした。

————————————————————————————————————–

抜粋一部伏字

From yoshio Fri Feb 15 15:23:32 2013

X-Apparently-To: **********@yahoo.co.jp via 183.79.100.191; Fri, 15 Feb 2013 15:39:09 +0900
Return-Path: <yoshio@hstech.jp>
X-YahooFilteredBulk: 219.105.37.34
X-Originating-IP: [219.105.37.34]
Received-SPF: pass (dns.hstech-net.com: domain of yoshio@hstech.jp designates 219.105.37.34 as permitted sender) receiver=dns.hstech-net.com; client-ip=219.105.37.34; envelope-from=yoshio@hstech.jp;
Authentication-Results: mta536.mail.kks.yahoo.co.jp from=hstech.jp; domainkeys=pass (ok); dkim=pass (ok) header.i=@hstech.jp
Received: from 219.105.37.34 (EHLO dns.hstech-net.com) (219.105.37.34) by mta536.mail.kks.yahoo.co.jp with SMTP; Fri, 15 Feb 2013 15:39:09 +0900
Received: from dns.hstech-net.com (dns.hstech-net.com [127.0.0.1]) by dns.hstech-net.com (Postfix) with ESMTP id 18EF45C0B3F for <ikuko_kimura@yahoo.co.jp>; Fri, 15 Feb 2013 15:23:36 +0900 (JST)
DKIM-Signature: v=1; a=rsa-SHA256; c=relaxed; d=hstech.jp; h=message-id :from:to:subject:date:mime-version:content-type :content-transfer-encoding; s=hstech; bh=cm3wifXTQb1BDJmgLrqwHaa Kt7jTusy9rHJ3pkuNlJs=; b=PKkorais8kG257bvNjob63kDv8RAyiuoOu/10/3 EIrbGQr9PTfpd6vPGptkudE+9tfM+6ZXz7bXA+g3Ukyx6OxWr6uQpz45mGYoyJ3l rj8++uXS0V7He26KHkw7FjvV7hXIs+TKPfMrSz9VdOELIiWC0poJNqt0ecuP7SLe jmU0=
DomainKey-Signature: a=rsa-SHA1; c=nofws; d=hstech.jp; h=message-id:from :to:subject:date:mime-version:content-type :content-transfer-encoding; q=dns; s=hstech; b=Am5JobuxbZDZVG6Il 6ywnf8z208bZ4fhMnlnf4lfWt3rZPG6lU6EfIspXxkzAWg60Dg4S3NHp3s0LcSjD N13VIFJyLUo5slPTO0ial/81aHdJlcDhzOhhNMgiKayjjWx/Vk6pPyhlgMPUA3CT U6hIlLojIly371xsyPBu+/Fo6w=
Received: from hstechPC1 (unknown [192.168.120.100]) by dns.hstech-net.com (Postfix) with ESMTPA id 0869E5C0B3E for <********@yahoo.co.jp>; Fri, 15 Feb 2013 15:23:36 +0900 (JST)
Message-ID: <C40F24C9FBA74AA2A816EA703FDDE9D9@hstechPC1>
From:
“yoshio” <yoshio@hstech.jp>

以下略

————————————————————————————————————————————————————————-

次に前回問題なかったgmail宛にテストメールを送信しヘッダー情報を確認しました。

すると前回旧サーバでDKIM署名のテストをしたときの結果と異なりました。

前回のAuthentication-Results結果
Authentication-Results: mx.google.com; spf=pass (google.com: domain of yoshio@hstech.net designates 219.105.37.35 as permitted sender) smtp.mail=yoshio@hstech.net

今回のAuthentication-Results結果

Authentication-Results: mx.google.com; spf=pass (google.com: domain of yoshio@hstech.jp designates 219.105.37.34 as permitted sender) smtp.mail=yoshio@hstech.jp;
dkim=neutral (no key) header.i=@ と叱られた

ぬ!no keyってなんじゃい!とここからgoogle先生に教えを請いました。以下次回

新サーバPostfixにS25Rスパム対策を導入

S25Rスパム対策は、現メールサーバに導入し高いスパム阻止効果を上げています。

Dovecot+Postfixの新サーバにも導入しました。その覚書です。

上記サイトのPostfixでの設定方法を参考にwhite_list、rejections、helo_restrictions三つのファイルを作成します。

今回white_listは上記サイト様のものがすばらしいので(更新もされているようです)簡単なphpスクリプトで

月一回取り込ませていただく事としました。(感謝!)

以下の簡単なスクリプトをcronで月一回実行させます。

<?php

$url=”http://www.gabacho-net.jp/anti-spam/white-list.txt“;

$white_list=”/home/****/white_list”; ユーザーディレクトリの適当な場所に保存

$read=@fopen($url,”r”);

$write=@fopen($white_list,”w”);

while($line=@fgets($read,1024)){

fputs($write_fp,$line);

}

fclose($read);

fclose($write);

?>

ユーザーディレクトリに保存したwhite_listを/etc/postfix/white_listへリンク

 /etc/postfix/main.cfに追加設定

heloが必要

smtpd_helo_required = yes

HELO コマンドの送信制限

smtpd_helo_restrictions =
permit_mynetworks,
reject_invalid_hostname,
check_helo_access regexp:/etc/postfix/helo_restrictions

差出人アドレスの制限

smtpd_sender_restrictions =
permit_mynetworks,
reject_non_fqdn_sender,

reject_unknown_sender_domain

ホワイトリストは許可

smtpd_client_restrictions =
permit_mynetworks,
check_client_access regexp:/etc/postfix/white_list,
check_client_access regexp:/etc/postfix/rejections

以上で設定完了です。

拒絶ログソーティングスクリプト も大変便利なので使用します。

次はいよいよDKIMproxyです。前回大変だったので心配です。

Dovecot+Postfixでメールサーバ構築

Postfix+Cyrusでメールサーバを運用しておりましたが、新メールサーバのDevecotを使っての

構築テストです。Version 2.0.21

Dovecotをsslを使用しない設定で起動させると以下のエラーを吐く

doveconf: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:93: protocol { ssl_listen } has been replaced by service { inet_listener { address } }

/etc/dovecot/dovecot.conf

”ssl_listen = *”をコメントアウトすると起動しました。特に他の設定いじらなくても良いようです。

/etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir

これでpop3受信の確認が出来ました

しかし・・・saslauthデーモンを起動させたとたん

Jan 27 18:07:20 dns postfix/smtpd[23217]: connect from unknown[113.78.39.85]
Jan 27 18:07:23 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:24 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:25 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:26 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:27 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:28 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:29 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:29 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:30 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:31 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:35 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:39 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:43 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:47 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:51 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:55 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:07:59 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:08:03 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:08:07 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:08:10 dns postfix/smtpd[23217]: warning: unknown[113.78.39.85]: SASL LOGIN authentication failed: authentication failure
Jan 27 18:08:12 dns postfix/smtpd[23217]: too many errors after AUTH from unknown[113.78.39.85]
Jan 27 18:08:12 dns postfix/smtpd[23217]: disconnect from unknown[113.78.39.85]
Jan 27 18:11:32 dns postfix/anvil[23218]: statistics: max connection rate 1/60s for (smtp:113.78.39.85) at Jan 27 18:07:20
Jan 27 18:11:32 dns postfix/anvil[23218]: statistics: max connection count 1 for (smtp:113.78.39.85) at Jan 27 18:07:20
Jan 27 18:11:32 dns postfix/anvil[23218]: statistics: max cache size 1 at Jan 27 18:07:20

またもや中国からのアクセスです。いやになりますね。

送信ドメイン認証導入総括

そもそもDKIMの導入メリットとは何でしょうか?

2012年5月に総務省が取りまとめた、ISP4社(YAHOO!、ビッグローブ、IIJ、ニフティ)の

DKIM=passとなったメールの割合は25%です。

http://www.soumu.go.jp/main_sosiki/joho_tsusin/d_syohi/pdf/120726_3.pdf

DKIM署名をしているISPでもこの割合ですので他のISPではもっと下がるでしょう。

この程度の普及率では、DKIM=pass以外のメールを拒否したり迷惑メールとすることは

とても出来ません。

では何の為?といわれたらDKIM認証が通らないメールはSPAM扱いですよ~っというISPが

今後増えてこないとも限りませんのでそのための対策です。

自メールサーバーは、DKIMでフィルタリングするつもりは毛頭ありません。

数年前からS25Rというスパム対策をしていてこれが高い効果を得ております。

これは送信元のメールサーバのアドレスからメールサーバがエンドユーザー回線(動的IP)から

発信しているか判断し450を返すという仕組みで⇒S25Rインタビュー記事

これを導入してから高いspamメールフィルタ効果を得ております。

こちらもご覧になってみてください。送信ドメイン認証はスパムに勝てないだろう

最後にyahoo.co.jpあてに送ったメールのヘッダーを記して終了します。

ヤフー宛メールのヘッダー(DKIM署名付けても迷惑メール扱いです笑)

From =?iso-2022-jp?B?GyRCI0gjUyVGJUMlLxsoQiAbJEJMWkI8GyhC?= Mon Dec 3 22:53:43 2012
X-Apparently-To:ikuko_kimura@yahoo.co.jp via 183.79.100.204; Mon, 03 Dec 2012 22:53:47 +0900
Return-Path:<yoshio@hstech.net>
X-YahooFilteredBulk:219.105.37.35
Originating-IP:[219.105.37.35]
Received-SPF:pass (dns2.hstech-net.com: domain of yoshio@hstech.net designates 219.105.37.35 as permitted sender) 
receiver=dns2.hstech-net.com; client-ip=219.105.37.35; envelope-from=yoshio@hstech.net;
Authentication-Results:mta505.mail.kks.yahoo.co.jp from=hstech.net; domainkeys=pass (ok); dkim=pass (ok) header.i=@hstech.net
Received:from 219.105.37.35 (EHLO dns2.hstech-net.com) (219.105.37.35) by mta505.mail.kks.yahoo.co.jp with SMTP; Mon, 03 Dec 2012 22:53:46 +0900
Received:from dns2.hstech-net.com (localhost [127.0.0.1]) by dns2.hstech-net.com (Postfix) with ESMTP id 5EB706203FA for <ikuko_kimura@yahoo.co.jp>; Mon, 3 Dec 2012 22:53:48 +0900 (JST)>
DKIM-Signature:=1; a=rsa-SHA256; c=relaxed; d=hstech.net; h=message-id :from:to:subject:date:mime-version:content-type :content-transfer-encoding; s=hstech; bh=cm3wifXTQb1BDJmgLrqwHaa Kt7jTusy9rHJ3pkuNlJs=; b=BF8VIXEciEo2HIIImrwQsbLKwuW40OV1McyGZrJ 9AjPMIyPq1gSPruzvF8g4Edh1m8ZOlJoeynXIlsCmoq1RIY1dvZSZHDXFRHH8qmS LgSNhg/z8eLqWZhneS75mGNNc1HC74NOd96JgLjiBP/V+kSsl72zXdCbSWE7Of2Z E73U=
DomainKey-Signature:a=rsa-SHA1; c=nofws; d=hstech.net; h=message-id :from:to:subject:date:mime-version:content-type :content-transfer-encoding; q=dns; s=hstech; b=UY4o/qSUkaQLAfMtn PtvnHwHzCiNkkYC2uTKB5HeMEJddRjYe4ctqASTr9BoCy7qkH1q6zyp/VMJGsJxW yJqADBiDvZOcit/UyBO439/wJgkVYbJu58H4dqNIs6JeuGlAZgI8MfR+XS0OP8nn w3/mpwlyjDHZ4RPieRw0EaBz+w=
Received:
from hstechPC1 (unknown [192.168.120.101]) by dns2.hstech-net.com (Postfix) with ESMTP id 49EBF6203DA for <ikuko_kimura@yahoo.co.jp>; Mon, 3 Dec 2012 22:53:48 +0900 (JST)
Message-ID:DDEA1A44372E4F12B8A8CCB8553D6E96@hstechPC1>
From:=?iso-2022-jp?B?GyRCI0gjUyVGJUMlLxsoQiAbJEJMWkI8GyhC?= yoshio@hstech.net

 

DKIMproxy導入覚書-はまり処満載で撃沈寸前!その3

いよいよ署名を付けてみます。

他の設定は済んでいるので、postfixのmaster.cfに記述するだけです。

参考サイト: http://dkimproxy.sourceforge.net/postfix-outbound-howto.html
sasl-authで587番ポートを使用しているのでこのポートに来たメールのみ署名をします。

# # modify the default submission service to specify a content filter

# and restrict it to local clients and SASL authenticated clients only #

submission  inet  n     -       n       -       -       smtpd

-o smtpd_etrn_restrictions=reject

-o smtpd_sasl_auth_enable=yes

-o content_filter=dksign:[127.0.0.1]:10027

-o receive_override_options=no_address_mappings

-o smtpd_client_restrictions=permit_sasl_authenticated,reject

マイネットワーク以外からの送信が出来ないのでこの行を追加しました。

-o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject

#

# specify the location of the DKIM signing proxy

# Note: we allow "4" simultaneous deliveries here; high-volume sites may

#   want a number higher than 4.

# Note: the smtp_discard_ehlo_keywords option requires Postfix 2.2 or

#   better. Leave it off if your version does not support it.

#

dksign    unix  -       -       n       -       4       smtp

-o smtp_send_xforward_command=yes

-o smtp_discard_ehlo_keywords=8bitmime,starttls

#

# service for accepting messages FROM the DKIM signing proxy

#

127.0.0.1:10028 inet  n  -      n       -       10      smtpd

-o content_filter=

-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks

-o smtpd_helo_restrictions=

-o smtpd_client_restrictions=

-o smtpd_sender_restrictions=

-o smtpd_recipient_restrictions=permit_mynetworks,reject

-o mynetworks=127.0.0.0/8

-o smtpd_authorized_xforward_hosts=127.0.0.0/8

さていよいよ送信テストです。sa-test@sendmail.net へメールを送信します。

程なく返信メールが来ました、さて結果は、

sendmail.net Sender Authentication Auto-Responder $Revision: 1.19 $
This service runs at <sa-test@sendmail.net> and allows remote users

to perform a simple, automated test to see if different Sender

Authentication schemes are working.  Mail sent to this service

is checked by our Sender Authentication filters for any valid

credentials or signatures.  A script receives the message, checks

for a special header with the results of the tests, and composes

this response message based on what it finds.  This response is also

signed with DomainKeys Identified Mail (DKIM).
Please note that the DKIM filter signing this reply message conforms

to the latest IETF standard version, and thus may not be successfully

verified by older implementations.  If you are using dkim-filter from

Sendmail, Inc., upgrade to OpenDKIM to be compatible with the most

recent version of DKIM.
Note that DomainKeys has been removed in favor of DKIM.  Sites still

using DomainKeys should upgrade to DKIM ASAP.
We hope this service has been helpful to you.
Authentication System:       DomainKeys Identified Mail (DKIM)

Result:                   DKIM signature confirmed GOOD 
Description:              Signature verified, message arrived intact

Reporting host:           services.sendmail.com

More information:         http://dkim.org/

Sendmail milter:          http://opendkim.org/
Authentication System:       Sender ID

Result:                   SID data confirmed GOOD

Description:              Sending host is authorized for sending domain

Reporting host:           services.sendmail.com

More information:         http://www.microsoft.com/senderid

Sendmail milter:          https://sourceforge.net/projects/sid-milter/
Authentication System:       Sender Permitted From (SPF)

Result:                   SPF data confirmed GOOD

Description:              Sending host is authorized for sending domain

Reporting host:           services.sendmail.com

More information:         http://openspf.org/

あれっ!

DKIM signature confirmed GOOD

ということは、DNSのドメインキーレコードは正常ということになりますね???

ためしにこちらのサイトで再検証してみました。

http://dkimcore.org/tools/dkimrecordcheck.html

結果は This is a valid DKIM key record

DNSの設定はこのままで良さそうです???あの一日はなんだったんだろう

 

DKIMproxy導入覚書-はまり処満載で撃沈寸前!その2

DKIMproxyオフィシャルサイト

秘密鍵・公開鍵を作成したので、DNSゾーンファイルを編集します。

ポリシーレコード、セレクターレコード、2つのレコードを追加

ポリシーレコード、

_policy._domainkey.hstech.  600 IN  TXT "t=y; o=~; r=yoshio@hstech.net"
hstech._domainkey.hstech.net.   600 IN  TXT "t=y; k=rsa; p=公開鍵"

下記サイトでポリシレコードのチェックをします。
http://domainkeys.sourceforge.net/policycheck.html
結果は

 Testing hstech.net
Policy TXT=t=y;o=~;n=;r=yoshio@hstech.net;This policy record appears valid.

OKのようです。
次に下記サイトでセレクターレコードのチェックをします。
http://domainkeys.sourceforge.net/selectorcheck.html
結果は

hstech._domainkey.hstech.net
TXT Record length = 229
p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCXxC8mmzt/x8VFnbzPWH1dSw/FU5qoIafLdCAqt

...aP8T1NhBvthFpKQku3gcTs72xZrj0h/I0dmzoFyI+f/emJ7VHuFPfYIyi8dwAc+Qq2vrJmKPYey3vL4q

...Im1SEyYWB4fzUdU9CynjOBeT+RziZcHIroQuQeWVXToqxuzAhaJQIDAQAB;k=rsa;t=y;

This selector is in error: Tag 'p': Invalid public key has no modulus

む!なんじゃいノーモデュラスって????

検索してみましたが思うような答えが見つかりません。

オフィシャルサイトの指示通り

Generate a private/public key pair using OpenSSL:

openssl genrsa -out private.key 1024
openssl rsa -in private.key -pubout -out public.key

と鍵を再作成しても結果は同じでした。
ここで1日はまりました。とりあえずDKIMproxyを動作させて、吐かれるエラーメッセージ等から
解決策を探ろうと思い、DKIMproxyの設定をすることにしました。
変更箇所は太字部分のみ

/usr/local/dkimproxy/etc/dkimproxy_in.conf
# specify what address/port DKIMproxy should listen on

listen    127.0.0.1:10025

# specify what address/port DKIMproxy forwards mail to

relay     127.0.0.1:10026
/usr/local/dkimproxy/etc/dkimproxy_out.conf

# specify what address/port DKIMproxy should listen on listen    127.0.0.1:10027

# specify what address/port DKIMproxy forwards mail to relay     127.0.0.1:10028

# specify what domains DKIMproxy can sign for (comma-separated, no spaces)

domain    hstech.net,parts-recycle.net,hair-saloon.net

# specify what signatures to add simple

signature dkim(c=relaxed,a=rsa-SHA256)

signature domainkeys(c=nofws,a=rsa-SHA1)

# specify location of the private key

keyfile   /usr/local/dkimproxy/private.key

# specify the selector (i.e. the name of the key record put in DNS)

selector  hstech 
# control how many processes DKIMproxy uses

#  - more information on these options (and others) can be found by

#    running `perldoc Net::Server::PreFork'. #min_servers 5 #min_spare_servers 2

DKIMproxyの解凍ディレクトリから起動ファイルを/etc/rc.d/init.d/にリネームしてコピー

sample-dkim-init-script.sh ⇒ /etc/rc.d/init.d/dkimproxy

これでDKIMproxyの設定は終了

次に以下のサイトを参照しpostfixのmaster.cfを変更します。

http://dkimproxy.sourceforge.net/postfix-inbound-howto.html

これで受け取ったメールの検証が出来ます。

ためしにDKIM署名をしているgmailとしていないplalaのメールのヘッダーを比較してみます

gmailヘッダー(抜粋)

Return-Path: <hstech99@gmail.com>

Received: from dns2.hstech-net.com ([unix socket])

by dns2.hstech-net.com (Cyrus v2.2.13p1-Invoca-RPM-2.2.13p1-4vl4) with LMTPA;

Fri, 30 Nov 2012 14:25:24 +0900

X-Sieve: CMU Sieve 2.2

Received: from dns2.hstech-net.com (localhost [127.0.0.1])

by dns2.hstech-net.com (Postfix) with ESMTP id 735426203F6

for <yoshio@hstech.net>; Fri, 30 Nov 2012 14:25:24 +0900 (JST)

Authentication-Results: dns2.hstech-net.com; dkim=pass header.i=@gmail.com 
X-DKIM-Authentication-Results: pass 

Received: from mail-ie0-f176.google.com (mail-ie0-f176.google.com [209.85.223.176])

by dns2.hstech-net.com (Postfix) with ESMTP

for <yoshio@hstech.net>; Fri, 30 Nov 2012 14:25:24 +0900 (JST)

Received: by mail-ie0-f176.google.com with SMTP id 13so124242iea.7

for <yoshio@hstech.net>; Thu, 29 Nov 2012 21:25:23 -0800 (PST)

DKIM-Signature: 略

検証結果=pass が確認できます。

plalaヘッダー(大部分略)

Return-Path: <hskimura@blue.plala.or.jp>

Received: from dns2.hstech-net.com ([unix socket])

by dns2.hstech-net.com (Cyrus v2.2.13p1-Invoca-RPM-2.2.13p1-4vl4) with LMTPA;

Sat, 01 Dec 2012 09:37:55 +0900

X-Sieve: CMU Sieve 2.2

Received: from dns2.hstech-net.com (localhost [127.0.0.1])

by dns2.hstech-net.com (Postfix) with ESMTP id 581816203D7

for <yoshio@hstech.net>; Sat,  1 Dec 2012 09:37:55 +0900 (JST)

Authentication-Results: dns2.hstech-net.com;

X-DKIM-Authentication-Results: none

これで受信メールの検証確認が出来ました。

次はいよいよ署名を付ける設定です。でもまだまだ先は長いかも・・・・・

DKIMproxy導入覚書-はまり処満載で撃沈寸前!その1

DKIM(DomainKeys Identified Mail)は迷惑メール対策の技術の一つでで自ドメインでの導入記録です。

DKIMとは 参照:dkim.jp FAQ こちらに詳しい説明があります。

財団法人日本インターネット協会 技術解説DKIM

・まずは使用ソフトウェアの選択

総合的に判断してDKIMproxyを使用することとしました。

こちらのサイトを参考にインストールをしましたがはまりどころ満載で恥を承知で公開します。

Mail-DKIM and DKIMproxy 日本語化がほとんど進んでいないので苦労しました。

Downloadページの指示に従い以下のperlモジュールをインストールします。以下

Mail::DKIM requires the following Perl modules:

適当訳-Mail::DKIMは以下ののパールモジュールを必要としています

  • Crypt::OpenSSL::RSA
  • Digest::SHA
  • Mail::Address
  • MIME::Base64
  • Net::DNS

 

DKIMproxy is written in Perl. It requires the Mail::DKIM module, found on this page, as well as the following Perl modules:

適当訳-DKIMproxyはPerlで書かれています。それにMail :: DKIMのモジュールと同様に、以下のPerlモジュールが必要です

  • Net::Server (use the latest version, if possible)
  • Error

CPANのご厄介になるわけですがこちらのサイトが参考なります。CPAN初級

書くと簡単ですが、依存関係で色々エラーが出てここまで結構時間がかかりました。

Download the Mail-DKIM Perl module:

Version 0.39 [CPAN].

これでやっとMail-DKIMのインストールに到りました、続いてDKIMproxyです。

Download the current version of DKIMproxy:Version 1.4.1 [SourceForge].

ダウンロードしたら適当なディレクトリに解凍します。(インストール先は指定できるので)

tar xzf dkimproxy-1.3.tar.gz

cd /path/dkimproxy-1.3 解凍したdkimproxyに移動

./configure –prefix=/usr/local/dkimproxy

make install

dkimproxyのインストールはこれで完了です  参考サイト

・次に鍵の作成です。

# cd /usr/local/dkimproxy

# openssl genrsa -out private.key 1024

# openssl rsa -in private.key -pubout -out public.key

これでprivate.keyとpublic.keyが作成されます。

順調に見えますがここまで1日半ぐらいかかってます。以下次回

 

 

スパムメール対策

メールlogに以下のようなものがずらり(一部加工してあります。)

Oct  7 08:53:08 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<il-dana@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:08 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<nisimura@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:08 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<saiga@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:09 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<s-eriko@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:09 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<sioux@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:09 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<totarou@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:09 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<ugao@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:09 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<kikk@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:10 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<a.andrew-t@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:10 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<ab-kom@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:10 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<against@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:11 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<akky@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:12 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<andrew-t@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:13 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<aquaniya@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:15 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<b_chan@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:16 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<canndoh@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:17 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<canondcs@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

Oct  7 08:53:18 dns2 postfix/smtpd[2463]: NOQUEUE: reject: RCPT from unknown[111.142.86.207]: * *****: ***** from=<mizuki_brothmiho7g@softbank.ne.jp> to=<corn7546@netjoy.ne.jp> proto=SMTP helo=<111.142.86.207>

このアドレスを調べたところ

国家: 中国     都市: Beijing 部門: CHINA RAILWAY Internet(CRNET)

/16でまとめてフィルタリング、111.142.0.0/16

wordpressにもスパム書き込みがあったのでこのアドレス(220.161.102.33)を調べたら

福建CHINANET-FJ用户 【中国】これもまとめて/16でフィルタリングほとんどのスパムは中国ですね。

話は変わりますが今日の散歩の写真です