我已经看到了一些良好的安装邮件服务器,他们错误后立即终止连接
454 4.7.1 <[email protected]>: Relay access denied
这可能会节省大量的资源和stream量。 而我的后缀仍然保持SMTP会话打开未来的命令,其中,可能只会是垃圾邮件。
在发送给垃圾邮件发送者这个错误之后,我怎么能告诉Postfix终止会话(就像那些智能服务器一样)?
后缀版本2.10.1
输出postconf -n
[root@mail ~]# postconf -n config_directory = /etc/postfix header_checks = pcre:/etc/postfix/header_check inet_protocols = ipv4 local_recipient_maps = mydestination = example.com, $myhostname, localhost.$myhostname, $mydomain, localhost.$mydomain mydomain = example.com myhostname = mail.example.com mynetworks = 127.0.0.0/8 10.0.0.0/16 myorigin = example.com relay_domains = example.com smtpd_banner = $myhostname ESMTP smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination, reject_invalid_hostname, reject_unauth_pipelining, reject_non_fqdn_sender, reject_unknown_recipient_domain, reject_unknown_sender_domain, check_sender_access hash:/etc/postfix/access smtpd_sender_restrictions = check_recipient_access hash:/etc/postfix/recipients, reject_non_fqdn_sender, reject_rhsbl_sender blackhole.securitysage.com, reject_unknown_sender_domain transport_maps = hash:/etc/postfix/transport
对于这个问题,我有好消息和坏消息。
好消息是,当客户端行为不当时,Postfix的确有一种机制来断开连接。 它被logging在这个页面上 。 三个参数控制行为: smtpd_soft_error_limit , smtpd_hard_error_limit , smtpd_error_sleep_time 。 这个伪代码将说明它是如何工作的。
While smtpd get connection from client error_counter = 0 if there ERROR* in SMTP transaction error_counter = error_counter + 1 if error_counter > $smtpd_soft_error_limit show the error message with delay $smtpd_soft_error_delay else if error_counter > $smtpd_hard_error_limit DISCONNECT client else show the error message IMMEDIATELY if one message transfered successfully error_counter = 0 //reset the counter
注意:在后缀术语中,当客户端请求被无法识别或未实现,客户端请求违反访问限制或发生其他错误时,会触发ERROR* 。
看看,如果我们将smtpd_hard_error_limit设置为1,错误发生后,postfix将高兴地断开客户端。
坏消息是我们无法过滤触发smtpd_hard_error_limit的错误。 您打算将此断开行为限制为“ Relay Access Denied错误无法执行。 将smtpd_hard_error_limit设置为1后,每个错误都会如此
Recipient access rejected, user not Found
要么
Sender address rejected: Domain not found;
将导致客户端断开连接。 当smtpd_hard_error_limit = 1时,后缀文档会说明一些效果。
在压力条件下,使用smtpd_hard_error_limit为1而不是默认值20.这有助于在发生单个错误后断开客户端连接,让其他客户端有机会连接。 但是,这可能会导致合法邮件严重延迟,例如邮件列表中包含一些不再活跃的用户名,而这些用户名并不会退订。 只要这个措施只是暂时使用,不应该丢失邮件。
对于僵尸客户端的替代解决scheme,您可以在后缀中启用postscreen 。 Postscreen将添加一层到smtpd进程,所以服务器应该处理合法的客户端。 在这里和这里查看文档
Postfix 2.10引入了一个名为smtpd_relay_restriction参数。 您可以阅读postconf(5)中的文档。 默认情况下,这个参数有值
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
参数defer_unauth_destination会抛出错误4xx而不是5xx。
最好的build议是将限制分为两个参数smtpd_relay_restriction和smtpd_recipient_restriction。 但是,如果你坚持保持旧的configuration(例如只在smtpd_recipient_restriction),你可以在main.cf设置smtpd_relay_restriction为空
smtpd_relay_restriction =