2008年3月23日 星期日

阻擋垃圾郵件

以前會使用 ORDB 來阻擋一些垃圾郵件,換新機器後,這些設定都還原了(而且 ORDB 也已經宣佈解散囉)。果然,垃圾郵件如雪片般飛來,每天都有 300 封左右,砍不勝砍。今天又砍了快 600 封,非常浪費時間,決定把阻擋垃圾郵件的機制重建起來。


第一個作法,就和過去使用 ORDB 作法一樣,讓 sendmail 在收信時參考網路上的 Open Relay 黑名單,拒收使用 Open Relay 的來信,這已經可以擋掉大半了。作法是編輯 /etc/mail/sendmail.mc,在「MAILER(smtp)dnl」之前加入以下資訊:



FEATURE(`dnsbl',`dnsbl.sorbs.net',`550 5.7.1 Mail from $&{client_addr} rejected based on external blacklist - See also http://dnsbl.sorbs.net/')dnl
FEATURE(`dnsbl',`sbl.spamhaus.org',`550 5.7.1 Mail from $&{client_addr} rejected based on external blacklist - See also http://sbl.spamhaus.org/')dnl
FEATURE(`dnsbl',`xbl.spamhaus.org',`550 5.7.1 Mail from $&{client_addr} rejected based on external blacklist - See also http://xbl.spamhaus.org/')dnl
FEATURE(`dnsbl',`DNSBL.SORBS.NET',`550 5.7.1 Mail from $&{client_addr} rejected based on external blacklist - See also http://DNSBL.SORBS.NET/')dnl
FEATURE(`dnsbl',`blackholes.mail-abuse.org',`550 5.7.1 Mail from $& {client_addr} rejected based on external blacklist - See also http://blackholes.mail-abuse.org/')dnl
FEATURE(`dnsbl',`dialups.mail-abuse.org',`550 5.7.1 Mail from $&{client_addr} rejected based on external blacklist - See also http://dialups.mail-abues.org/')dnl
FEATURE(`dnsbl',`relays.mail-abuse.org',`550 5.7.1 Mail from $&{client_addr} rejected based on external blacklist - See also http://relays.mail-abuse.org/')dnl
FEATURE(`dnsbl',`dul.maps.vix.com',`550 5.7.1 Mail from $&{client_addr} rejected based on external blacklist - See also http://dul.maps.vix.com/')dnl
FEATURE(`dnsbl',`dynablock.njabl.org',`550 5.7.1 Mail from $&{client_addr} rejected based on external blacklist - See also http://dynablock.njabl.org/')dnl
FEATURE(`dnsbl',`dsbl.dnsbl.net.au',`550 5.7.1 Mail from $&{client_addr} rejected based on external blacklist - See also http://dnsbl.dnsbl.net.au/')dnl
FEATURE(`dnsbl',`ipwhois.rfc- ignorant.org',`550 5.7.1 Mail from $& {client_addr} rejected based on external blacklist - See also http://www.ordb.org/')dnl
FEATURE(`dnsbl',`bl.spamcop.net',`550 5.7.1 Mail from $&{client_addr} rejected based on external blacklist - See also http://bl.spamcop.net/')dnl
FEATURE(`dnsbl',`list.dsbl.org',`550 5.7.1 Mail from $&{client_addr} rejected based on external blacklist - See also http://list.dsbl.org/')dnl



然後敲「make」,產生新的 sendmail.cf,再重啟 sendmail 「service sendmail restart」即可。


這樣還不足夠,因為仍有許多 MTA 雖不是 Open Relay,但是專門寄出垃圾郵件。於是參考了這份文件,嚐試著把 SpamAssassin 和 milter-greylist 架設起來,看能不能如文章中所說得:「怕你會無聊,因為已經沒有可殺的 spam 了」。


最後再參考這個網站,增加 SpamAssassin 的 rule,就大功告成囉,接下來就是驗收成果啦。

沒有留言:

張貼留言