ISPConfig的加固Postfix3

加固Postfix对于ISPConfig 3

作者:JesúsCórdoba
电子邮件:j.cordoba [at] gmx [dot] net
论坛用户:pititis

版本:1.2

本教程的目标是加强ISPConfig使用的邮件服务器Postfix,以便经过身份验证的用户受信任的Internet邮件服务器。 通过此设置,您将在拒绝大量的垃圾邮件进入邮件队列之前,节省大量的系统资源,并使邮件服务器对垃圾邮件发送者和垃圾邮件僵尸网络的强大。 我们走吧。

反向DNS,(DNS PTR记录)

要设置rdns,您会发现两种情况:

- 您的ISP允许您自己更改。 看看你的控制面板。

- 您的ISP不允许您更改它。 只需发送一封电子邮件与您的请求。

询问或将您的rdns记录指向您的服务器。 ie server.example.com您可以使用命令主机检查您的rdns:
root@server / # host 149.20.4.69
69.64-27.4.20.149.in-addr.arpa domain name pointer pub2.kernel.org.

记住,dns必须传播更改。

您的域的SPF(DNS TXT记录)

SPF是一种电子邮件验证系统,旨在通过检测电子邮件欺骗(一种常见漏洞)来检测发件人的IP地址来防止垃圾邮件。

要设置spf,您需要在您的dns区域中添加TXT记录,但首先可以在此处生成记录: http : //www.mailradar.com/spf/

复制spf结果,然后转到ISPConfig - > dns - > zones - >点击你的域名 - >点击记录选项卡 - >并点击TXT

主机名 - > example.com。 点在最后!

文本 - >粘贴这里的spf结果(没有“”)。

示例: v = spf1 a mx ptr ip4:11.222.333.444 -all ...并单击保存

记住,dns必须传播更改。

Postfix main.cf

让我们添加/更改/etc/postfix/main.cf

Helo限制:

smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname

Helo限制行动:

Jan 12 01:57:08 server postfix/smtpd[4687]: NOQUEUE: reject: RCPT from unknown[186.43.77.153]: 450 4.7.1 Client host rejected: cannot find your hostname, [186.43.77.153]; from=
<[email protected]> to=<[email protected]> proto=ESMTP helo=<[186.43.77.153]>
Jan  8 00:32:22 server postfix/smtpd[17504]: NOQUEUE: reject: RCPT from 201-93-87-2.dial-up.telesp.net.br[201.93.87.2]: 504 5.5.2 <lan-32204df3031>: Helo command rejected: need fully-qualified hostname; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<lan-32204df3031>

严格rfc:

strict_rfc821_envelopes = yes

客户限制:

smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unknown_client_hostname, check_client_access mysql:/etc/postfix/mysql-virtual_client.cf

收件限制:

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unknown_recipient_domain

数据限制:

smtpd_data_restrictions = reject_unauth_pipelining

Smtpd延迟:

smtpd_delay_reject = yes

不要忘记重新加载postfix:

/etc/init.d/postfix reload

SPF检查Postfix(Debian和Ubuntu)

安装spf包:

apt-get install postfix-policyd-spf-python

要么

apt-get install postfix-policyd-spf-perl

添加到/etc/postfix/main.cf

policy-spf_time_limit = 3600s

并在smtpd_recipient_restrictions的末尾添加check_policy_service unix:private / policy-spf

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination, reject_unknown_recipient_domain, check_policy_service unix:private/policy-spf

现在编辑master.cf并在末尾添加(对于python版本):

policy-spf  unix  -       n       n       -       -       spawn
     user=nobody argv=/usr/bin/policyd-spf 

或者这个为perl版本:

policy-spf  unix  -       n       n       -       -       spawn
     user=nobody argv=/usr/sbin/postfix-policyd-spf-perl

...重新加载Postfix。

/etc/init.d/postfix reload

Spf签到行动:

Jan  4 15:50:11 server postfix/smtpd[19096]: NOQUEUE: reject: RCPT from g230068165.adsl.alicedsl.de[92.230.68.165]: 550 5.7.1 <[email protected]>: Recipient address rejected: Message rejected due to: SPF fail - not authorized. Please see http://www.openspf.org/Why?s=helo;id=paxxxxxn.com;ip=92.230.68.165;[email protected]; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=
<paxxxxxn.com>

Greylist

灰名单是防止电子邮件用户反垃圾邮件的方法。 使用灰名单的邮件传输代理(MTA)将“暂时拒绝”其不能识别的发件人的任何电子邮件。 如果邮件是合法的,始发服务器将在延迟之后再次尝试,如果有足够的时间,邮件将被接受。

安装postgrey (Debian,Ubuntu):

apt-get install postgrey

配置选项位于/ etc / default / postgrey (默认延迟为5分钟)。

编辑main.cf并添加check_policy_service inet:127.0.0.1:10023smtpd_recipient_restrictions的结尾

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination, reject_unknown_recipient_domain, check_policy_service unix:private/policy-spf,check_policy_service inet:127.0.0.1:10023

... reload postfix:

/etc/init.d/postfix reload

行动中的Greylist:

Jan 10 17:38:57 server postfix/smtpd[21302]: NOQUEUE: reject: RCPT from mailout-de.gmx.net[213.165.64.22]: 451 4.7.1 <[email protected]>: Recipient address rejected: Greylisting in effect, please come back later; from=<[email protected]> to=<[email protected]> proto=SMTP helo=<mailout-de.gmx.net>

DNSBL(基于DNS的黑名单/阻止列表)

DNSBL是通过互联网域名服务(DNS)发布的IP地址列表,作为可由DNS服务器软件使用的区域文件,或作为可以实时查询的实时DNS区域。 DNSBLs通常用于发布与垃圾邮件相关联的计算机或网络的地址; 大多数邮件服务器软件可以被配置为拒绝或标记已经从一个或多个这样的列表上列出的站点发送的消息。 这些可能包括列出用于发送垃圾邮件的僵尸计算机或其他机器的地址,列出自愿托管垃圾邮件发送者的ISP的地址,或将发送垃圾邮件的地址列入Honeypot系统。 要使用dnsbl与postix,我们使用reject_rbl_client。 只需在main.cf文件中添加一些用于查询的实时dns区域。

在我的例子中,我将使用两个非常好的名单(添加到smtpd_client_restrictions的结尾 ):

smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unknown_client_hostname, check_client_access mysql:/etc/postfix/mysql-virtual_client.cf,  reject_rbl_client cbl.abuseat.org,  reject_rbl_client b.barracudacentral.org

rbl在行动中:

Jan 12 01:52:42 server postfix/smtpd[4616]: NOQUEUE: reject: RCPT from 89.pool85-49-26.dynamic.orange.es[85.49.26.89]: 554 5.7.1 Service unavailable; Client host [85.49.26.89] blocked using cbl.abuseat.org; Blocked - see http://cbl.abuseat.org/lookup.cgi?ip=85.49.26.89; from=<[email protected]> to=<[email protected]> proto=SMTP helo=<colossus.home>
Jan 11 20:13:58 server postfix/smtpd[29591]: NOQUEUE: reject: RCPT from 93-87-122-56.dynamic.isp.telekom.rs[93.87.122.56]: 554 5.7.1 Service unavailable; Client host [93.87.122.56] blocked using b.barracudacentral.org; http://www.barracudanetworks.com/reputation/?pr=1&ip=93.87.122.56; from=
<[email protected]> to=<[email protected]> proto=ESMTP helo=

后屏幕

注意:此功能在Postfix 2.8及更高版本中可用

Postfix后屏幕后台程序提供额外的保护,防止邮件服务器超载。 一个后期处理可处理多个入站SMTP连接,并决定哪些客户端可以与Postfix SMTP服务器进程通信。 通过保持spambots,postscreen留下更多的SMTP服务器进程可用于合法的客户端,并延迟服务器过载状况的发生。

后期屏幕的主要挑战是根据单次测量做出一个即将到来的僵尸决策。 这是必要的,因为许多僵尸试图在雷达下飞行,并避免重复发送同一个站点。 一旦postscreen决定客户端不是僵尸,它会临时将客户端列入白名单,以避免合法邮件的进一步延迟。

我们将使用本教程的默认设置与异常。 在大多数情况下,这些设置都很好

首先,我们使用以下命令向main.cf添加一行:

postscreen_greet_action = enforce

第二,我们添加postscreen和一些新的服务到master.cf注意:这些设置已经存在,只是取消注释。 还可以肯定的是,行“SMTP INET ... smtpd的”,包括任何参数被注释掉了(如果有的话,参数必须移动到新的smtpd服务)。

# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
#smtp      inet  n       -       -       -       -       smtpd
#          -o ...
smtpd     pass  -       -       n       -       -       smtpd
     -o ... # Parameters moved from smtp service to the new smtpd service.(if any)
smtp      inet  n       -       n       -       1       postscreen
tlsproxy  unix  -       -       n       -       0       tlsproxy
dnsblog   unix  -       -       n       -       0       dnsblog

现在,我们重新加载postfix:

/etc/init.d/postfix reload
赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏