Home page
ENGLISH
JAPANESE
Counter
Last update : 2022/04/24

milter-blockdomain

  1.  概要
  2.  著作権、ライセンス
  3.  ダウンロード
  4.  導入手順
  5.  ブロック・ドメイン・リストの準備
  6.  milter-blockdomain の起動

1. 概要

milter-blockdomain は、C言語で作成され、受信をブロックしたい数千のドメインを正規表現ではなく平易なテキストで管理する milter です。

milter-blockdomain と milter-greylist を併用するのが実用的な使い方です。
milter-greylist で、逆引きできないIPアドレス、不正なHELO/EHLO、GeoIP、正規表現による広範囲・汎用的なルール、S25R を処理します。
milter-blockdomain で、milter-greylist を通過した受信を希望しないドメインをブロックするように処理します。
milter-regex も、活用することもできます。

等価な記述方法
milter-blockdomain
example.com
milter-greylist
racl blacklist domain example.com
racl blacklist helo /^(.+\.)?example\.com$/
racl blacklist from /@(.+\.)?example\.com>$/
milter-regex
connect /^(.+\.)?example\.com$/ie // and envrcpt /^<.*>$/
helo    /^(.+\.)?example\.com$/ie    and envrcpt /^<.*>$/
envfrom /@(.+\.)?example\.com>$/ie   and envrcpt /^<.*>$/

2. 著作権、ライセンス

このソフトウエア ( milter-blockdomain ) の著作権は、阿部孝夫が保有しています。
ライセンスは、GNUパブリック・ライセンス(GPLv3、または、それより新しい版)です。
ライセンスのもとで、どなたでも、個人利用/商用利用を問わず、ご自由にご活用いただけます。


3. ダウンロード

GitHub   https://github.com/t2750xurb/milter-blockdomain


4. 導入手順

各種ファイルのパスを決めます。パスは、自由に決定できます。

File or DirPathパスを指定する関連ファイル
Exec file/usr/local/sbin/milter-blockdomain起動スクリプト ( ex. /etc/rc.d/rc.milter-blockdomain )
Config file/etc/mail/milter-blockdomain.conf起動スクリプト ( ex. /etc/rc.d/rc.milter-blockdomain )
Socket file/var/spool/milter/milter-blockdomain.sock設定ファイル ( Keyword: socket )
sendmail.mc ( Keyword: INPUT_MAIL_FILTER )
PID file/var/run/milter-blockdomain.pid設定ファイル ( Keyword: pidFile )
Domain list files/var/lib/milter-blockdomain/*設定ファイル ( Keyword: whitelist, blacklist, greylist )

実行モジュールの生成とディレクトリを作成します。

$ cd /tmp

$ tar jxf milter-blockdomain-M.NN.tar.bz2

$ cd milter-blockdomain-M.NN

$ ./configure --sysconfdir=/etc/mail

$ make

$ su
Password: **********

# make install

# mkdir /var/lib/milter-blockdomain

# mkdir /var/spool/milter

# chown smmsp:smmsp /var/spool/milter

# chmod o-rwx /var/spool/milter

sendmail.mc に "INPUT_MAIL_FILTER" を 追記します。

INPUT_MAIL_FILTER(`milter-blockdomain',`S=local:/var/spool/milter/milter-blockdomain.sock, F=, T=S:1m;R:1m')dnl

sendmail.mc から sendmail.cf を生成します。

Save current sendmail.cf as a backup.
# cp -p /etc/mail/sendmail.cf /etc/mail/sendmail.cf-yyyymmdd-hhmm

Change working directory
# cd /usr/share/sendmail/cf/cf

Generate sendmail.cf from sendmail.mc
# m4 /etc/mail/sendmail.mc | cat -s > /etc/mail/sendmail.cf

5. ブロック・ドメイン・リストの準備

ブロック・ドメイン・リストがなければ、空のファイルを作成します。

$ touch /var/lib/milter-blockdomain/xxxxxxxxxx.txt

6. milter-blockdomain の起動

milter-blockdomain [-c config-file-path] [-d] [-s] [-t Interval] [-v]

-c
Specify the config file path, if the config file is other than /etc/mail/milter-blockdomain.conf.
-d
Debug mode, Non-daemon.
-s
Output Statistics count to syslog hourly. Default: Daily.
-t
Minimum domain list file update check interval. ( Seconds )
-v
Display version number.
# /usr/local/sbin/milter-blockdomain

If the config file is other than /etc/mail/milter-blockdomain.conf
# /usr/local/sbin/milter-blockdomain -c config-file-path

連絡先、バグ・レポート

email   or   email

設定ファイルのサンプル
# milter-blockdomain.conf

########################################
# user
# Mandatory, No default

user    smmsp

########################################
# socket
# Mandatory, No default
# Correspond with INPUT_MAIL_FILTER of sendmail.mc

socket  /var/spool/milter/milter-blockdomain.sock

########################################
# pidFile
# Mandatory, No default

pidFile /var/run/milter-blockdomain.pid

########################################
# checkConnect, checkHelo, checkEnvFrom, checkEnvRcpt
# 0 : Not checked
# 1 : Checked  ( Default )

checkConnect = 1
checkMacro_  = 1
checkHelo    = 1
checkEnvFrom = 1
checkEnvRcpt = 0

########################################
# checkOnAndAfter
# 0 : Check on and after connect
# 1 : Check on and after helo
# 2 : Check on and after envfrom
# 3 : Check on and after envrcpt ( Default )
# 4 : Check on and after header

checkOnAndAfter = 3

########################################
# Message

messageTempfail "Refused connection temporarily. Be patient."
messageReject   "Refused connection by site policy."

########################################
# Syslog facility name
# daemon, mail, user, local0 to local7

syslogFacility  = mail

########################################
# Syslog priority debug
# 0 : Do not write syslog priority=debug ( Default )
# 1 : Write syslog priority=debug

syslogDebug  = 0

########################################
# Subdomain
# 0 : Exact domain matching
# 1 : Subdomain matching ( Domain boundary )  ( Default )

Subdomain = 1

########################################
# whitelist, blacklist, greylist
# Max 8 files
# First match determine the result, accpet/reject/tempfail.
# Insensitive lower/upper case letter.

whitelist /var/lib/milter-blockdomain/whitelist.txt
blacklist /var/lib/milter-blockdomain/blacklist.txt
greylist  /var/lib/milter-blockdomain/greylist.txt

########################################
# DO NOT USE THIS PARAMETER
# testMode
# 0 : Check ( Default )
# 1 : Logging only ( Alway "Not listed" result )

#testMode = 0

########################################
# DO NOT USE THESE PARAMETERS
# debugConfigFunction, debugCheckFunction
# 0 : Disable debug log ( Default )
# 1 : Enable debug log

#debugConfigFunction = 0
#debugCheckFunction  = 0

参考ウェブサイト
この milter-blockdomain で使える ブロック・ドメイン・リスト
http://www.fitserv.jp/blockdomain/
milter-greylist
http://hcpnet.free.fr/milter-greylist/
milter-regex
http://www.benzedrine.cx/milter-regex.html
milter-geoip
http://flatray.com/geoip/sendmail-milter.html
S25R スパム対策方式( Selective SMTP Rejection:選択的SMTP拒絶)
http://www.gabacho-net.jp/anti-spam/
http://www.fitserv.co.jp/ http://www.fitserv.jp/blockdomain/

Copyright (C) 2016, Takao Abe. All rights reserved.

Another HTML-lint     W3C HTML Validator     W3C CSS Validator


ChangeLog
2022/04/241.05 GitHub https://github.com/t2750xurb/milter-blockdomain
[Enhancement] Command line option -t
Minimum interval of checking domain list file update.
[Enhancement] Statistics information to syslog daily.
Command line option -s for hourly statistics info.
[Add] README.md
2018/01/201.04 [Change] Return previous TEMPFAIL or REJECT check result in the SMTP session preferentially.
Add debug log when the mlfi_xxxx's return.
milter-blockdomain.c
[Change] Change leaf node anchors have every two characters of the beginning of the domain node name, from they have every one character of the beginning of the domain node name.
milter-blockdomain.h blkdom_check.c blkdom_config.c
[Change] Add following statistics information, Node/Leaf count, Node/Leaf average chain length.
milter-blockdomain.h - domainListType
blkdom_config.c - statDomainList, LoadDomainList
2017/12/231.03 [Bug fix] Avoid multiple reloading domain lists in race conditions.
2016/11/031.02 [Bug fix] Lost the first entry of unsorted domain list.
2016/07/021.01 Support GNU build procedure, ./configure, make, and make intall.
Conf file new keyword 'syslogDebug'. Optional writing syslog priority=debug.
Conf file new keyword 'checkMacro_'. Check value of the sendmail macro '_'.
Return SMFIS_CONTINUE when smfi_getpriv returns NULL for the private data pointer.
2016/06/051.00 Published