新サーバ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

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

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日半ぐらいかかってます。以下次回