AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 645450
Accepted
Shirker
Shirker
Asked: 2014-11-20 03:26:02 +0800 CST2014-11-20 03:26:02 +0800 CST 2014-11-20 03:26:02 +0800 CST

告诉 Postfix 在“中继访问被拒绝”后立即关闭连接

  • 772

我在一些设置好的邮件服务器上看到过,它们在出错后立即终止连接

454 4.7.1 <[email protected]>: Relay access denied

这可能节省了大量资源和流量。而且我的 Postfix 仍然为将来的命令打开 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
  • 1 1 个回答
  • 835 Views

1 个回答

  • Voted
  1. Best Answer
    masegaloeh
    2014-11-22T20:26:34+08:002014-11-22T20:26:34+08:00

    关于这个问题,我有好消息和坏消息要告诉你。

    好消息是 Postfix 确实具有在客户端行为不端时断开连接的机制。它记录在此页面上。三个参数控制行为: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_limit1,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.

    在压力情况下,使用 1 的 smtpd_hard_error_limit 而不是默认的 20。这有助于在单个错误后断开客户端,让其他客户端有机会连接。但是,这可能会导致合法邮件出现明显延迟,例如包含一些不再活跃的用户名的邮件列表,这些用户名不会费心取消订阅。只要这种措施只是暂时使用,就不会丢失任何邮件。


    替代解决方案

    对于类似僵尸客户端的替代解决方案,您可以在 postfix 中启用 postscreen。Postscreen 将为 smtpd 进程添加一层,因此服务器应该处理合法的客户端。请参阅此处和此处的文档


    为什么我的服务器显示错误 4XX 而不是 5XX?

    Postfix 2.10 引入了一个名为smtpd_relay_restriction. 您可以阅读postconf(5)中的文档。默认情况下,此参数具有值

    smtpd_relay_restrictions = 
        permit_mynetworks 
        permit_sasl_authenticated 
        defer_unauth_destination
    

    参数defer_unauth_destination将抛出错误 4xx 而不是 5xx。

    最好的建议是将限制拆分为两个参数 smtpd_relay_restriction 和 smtpd_recipient_restriction。但是,如果您坚持保留旧配置(例如,仅在 smtpd_recipient_restriction 中),您可以将 smtpd_relay_restriction 设置为空main.cf

    smtpd_relay_restriction = 
    
    • 5

相关问题

  • Postfix 在特定端口上接受邮件

  • 让 Postfix 以两种方式处理垃圾邮件

  • Postfix 或 exim:自动/程序化和转发电子邮件设置

  • 后缀电子邮件地址

  • 什么是最好的开源电子邮件解决方案包

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve