Postfix 拒绝所有传入电子邮件

Postfix 拒绝所有传入电子邮件

我的电子邮件服务器到目前为止运行良好,但由于未知原因,可能是在设置强制 TLS 连接后,我不再能够接收电子邮件;不过,我在 TLS 配置期间确实对其进行了测试,而且我很确定它当时运行正常。发送仍然有效,连接和使用 Roundcube 也是如此。

我尝试清理我的 master.cf 和 main.cf 但无济于事,而且我不明白发生了什么。

最让我烦恼的是,postfix 使用的限制列表似乎是中继的限制列表,而不是收件人的限制列表,我无法理解为什么它不使用收件人的限制列表。

Postfix version: 2.11.3

日志文件(启用调试):

Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: generic_checks: name=reject_unknown_sender_domain status=0
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: >>> END Sender address RESTRICTIONS <<<
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: >>> START Recipient address RESTRICTIONS <<<
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: generic_checks: name=permit_mynetworks
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: permit_mynetworks: mail-il1-f172.google.com 209.85.166.172
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: match_hostname: mail-il1-f172.google.com ~? 127.0.0.0/8
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: match_hostaddr: 209.85.166.172 ~? 127.0.0.0/8
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: match_hostname: mail-il1-f172.google.com ~? [::ffff:127.0.0.0]/104
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: match_hostaddr: 209.85.166.172 ~? [::ffff:127.0.0.0]/104
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: match_hostname: mail-il1-f172.google.com ~? [::1]/128
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: match_hostaddr: 209.85.166.172 ~? [::1]/128
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: match_hostname: mail-il1-f172.google.com ~? 88.191.5.85/32
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: match_hostaddr: 209.85.166.172 ~? 88.191.5.85/32
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: match_list_match: mail-il1-f172.google.com: no match
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: match_list_match: 209.85.166.172: no match
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: generic_checks: name=permit_mynetworks status=0
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: generic_checks: name=reject_unauth_destination
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: reject_unauth_destination: [email protected]
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: permit_auth_destination: [email protected]
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: ctable_locate: move existing entry key [email protected]
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: generic_checks: name=reject_unauth_destination status=0
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: generic_checks: name=permit_sasl_authenticated
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: generic_checks: name=permit_sasl_authenticated status=0
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: generic_checks: name=reject
## ERROR HERE ## Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: NOQUEUE: reject: RCPT from mail-il1-f172.google.com[209.85.166.172]: 554 5.7.1 <[email protected]>: Recipient address rejected: Access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<mail-il1-f172.google.com>
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: generic_checks: name=reject status=2
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: >>> END Recipient address RESTRICTIONS <<<
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: report recipient to all milters (flags=0x1)
Nov 13 00:08:01 sd-123 postfix/smtpd[6005]: > mail-il1-f172.google.com[209.85.166.172]: 554 5.7.1 <[email protected]>: Recipient address rejected: Access denied

以下是 的输出postconf -nf

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
debug_peer_list = 209.85.166.0/24
html_directory = /usr/share/doc/postfix/html
inet_interfaces = all
inet_protocols = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 1280000000
milter_connect_macros = i j {daemon_name} v {if_name} _
milter_default_action = accept
milter_protocol = 6
mydestination = myaddress.com mail.myaddress.com, sd-123.hoster.com,
    localhost.hoster.com, localhost
myhostname = myaddress.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 some.ip.addr/32
myorigin = /etc/mailname
non_smtpd_milters = unix:/opendkim/opendkim.sock,unix:/opendmarc/opendmarc.sock
policyd-spf_time_limit = 3600
readme_directory = /usr/share/doc/postfix
recipient_delimiter = +
relayhost =
smtp_tls_CAfile = /etc/letsencrypt/live/myaddress.com/fullchain.pem
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_milters =
    unix:/spamass/spamass.sock,unix:/opendkim/opendkim.sock,unix:/opendmarc/opendmarc.sock
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks,
    check_policy_service unix:private/policyd-spf, reject_unauth_pipelining,
    reject_invalid_hostname, reject_non_fqdn_sender,
    reject_unknown_sender_domain, reject_non_fqdn_recipient,
    reject_unknown_recipient_domain, reject_rbl_client bl.spamcop.net,
    reject_rbl_client zen.spamhaus.org, reject_rbl_client dnsbl.sorbs.net,
    reject_unauth_destination, permit
smtpd_relay_restrictions = permit_mynetworks, reject_unauth_destination,
    permit_sasl_authenticated, reject
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated,
    permit_tls_clientcerts, reject_non_fqdn_sender, reject_unknown_sender_domain
smtpd_tls_CAfile = /etc/letsencrypt/live/myaddress.com/fullchain.pem
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/letsencrypt/live/myaddress.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/myaddress.com/privkey.pem
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3
smtpd_tls_protocols = !SSLv2,!SSLv3
smtpd_tls_security_level = encrypt
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
virtual_alias_maps =
    mysql:/etc/postfix/mysql-virtual-alias-maps.cf,mysql:/etc/postfix/mysql-email2email.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp

输出postconf -Mf

smtp       inet  n       -       -       -       -       smtpd
submission inet  n       -       -       -       -       smtpd
    -o syslog_name=postfix/submission
    -o smtpd_tls_security_level=encrypt
    -o smtpd_sasl_auth_enable=yes
    -o smtpd_sasl_type=dovecot
    -o smtpd_sasl_path=private/auth
    -o smtpd_sasl_security_options=noanonymous
    -o smtpd_sender_login_maps=mysql:/etc/postfix/mysql-email2email.cf
    -o smtpd_sender_restrictions=permit_mynetworks,permit_sasl_authenticated,permit_tls_clientcerts,reject_non_fqdn_sender,reject_unknown_sender_domain
    -o smtpd_sasl_local_domain=$myhostname
pickup     unix  n       -       -       60      1       pickup
cleanup    unix  n       -       -       -       0       cleanup
qmgr       unix  n       -       n       300     1       qmgr
tlsmgr     unix  -       -       -       1000?   1       tlsmgr
rewrite    unix  -       -       -       -       -       trivial-rewrite
bounce     unix  -       -       -       -       0       bounce
defer      unix  -       -       -       -       0       bounce
trace      unix  -       -       -       -       0       bounce
verify     unix  -       -       -       -       1       verify
flush      unix  n       -       -       1000?   0       flush
proxymap   unix  -       -       n       -       -       proxymap
proxywrite unix  -       -       n       -       1       proxymap
smtp       unix  -       -       -       -       -       smtp
relay      unix  -       -       -       -       -       smtp
showq      unix  n       -       -       -       -       showq
error      unix  -       -       -       -       -       error
retry      unix  -       -       -       -       -       error
discard    unix  -       -       -       -       -       discard
local      unix  -       n       n       -       -       local
virtual    unix  -       n       n       -       -       virtual
lmtp       unix  -       -       -       -       -       lmtp
anvil      unix  -       -       -       -       1       anvil
scache     unix  -       -       -       -       1       scache
maildrop   unix  -       n       n       -       -       pipe flags=DRhu
    user=vmail argv=/usr/bin/maildrop -d ${recipient}
uucp       unix  -       n       n       -       -       pipe flags=Fqhu
    user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail     unix  -       n       n       -       -       pipe flags=F user=ftn
    argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp      unix  -       n       n       -       -       pipe flags=Fq.
    user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix - n       n       -       2       pipe flags=R
    user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop}
    ${user} ${extension}
mailman    unix  -       n       n       -       -       pipe flags=FR
    user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop}
    ${user}
policyd-spf unix -       n       n       -       0       spawn user=policyd-spf
    argv=/usr/bin/policyd-spf

来自 master.cf 的相关提交配置:

submission inet n - - - - smtpd                                                                                                                                                                                     
 -o syslog_name=postfix/submission                                                                                                                                                                                  
 -o smtpd_tls_security_level=encrypt                                                                                                                                                                                
 -o smtpd_sasl_auth_enable=yes                                                                                                                                                                                      
 -o smtpd_sasl_type=dovecot                                                                                                                                                                                         
 -o smtpd_sasl_path=private/auth                                                                                                                                                                                    
 -o smtpd_sasl_security_options=noanonymous                                                                                                                                                                         
 -o smtpd_sender_login_maps=mysql:/etc/postfix/mysql-email2email.cf                                                                                                                                                 

 #-o smtpd_sender_restrictions=reject_sender_login_mismatch -- ORIGINAL // new value was extracted from main.cf                                                                                                     
 -o smtpd_sender_restrictions=permit_mynetworks,permit_sasl_authenticated,permit_tls_clientcerts,reject_non_fqdn_sender,reject_unknown_sender_domain                                                                

 -o smtpd_sasl_local_domain=$myhostname                                                                                                                                                                             
# -o smtpd_client_restrictions=permit_sasl_authenticated,reject                                                                                                                                                      
#-o smtpd_recipient_restrictions=reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_sasl_authenticated,reject ;; original value, but main.cf should be better

来自 main.cf 的相关配置:

smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated, permit_tls_clientcerts, reject_non_fqdn_sender, reject_unknown_sender_domain
smtpd_relay_restrictions = permit_mynetworks, reject_unauth_destination, permit_sasl_authenticated, reject
smtpd_recipient_restrictions =                                                                                                                                                                                      
                             permit_sasl_authenticated,                                                                                                                                                             
                             permit_mynetworks,                                                                                                                                                                     
                             check_policy_service unix:private/policyd-spf,                                                                                                                                         
                             reject_unauth_pipelining,                                                                                                                                                              
                             reject_invalid_hostname,                                                                                                                                                               
                             reject_non_fqdn_sender,                                                                                                                                                                
                             reject_unknown_sender_domain,                                                                                                                                                          
                             reject_non_fqdn_recipient,                                                                                                                                                             
                             reject_unknown_recipient_domain,                                                                                                                                                       
                             reject_rbl_client bl.spamcop.net,                                                                                                                                                      
                             reject_rbl_client zen.spamhaus.org,                                                                                                                                                    
                             reject_rbl_client dnsbl.sorbs.net,                                                                                                                                                     
                             reject_unauth_destination,                                                                                                                                                             
                             permit
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_tls_security_level = encrypt
smtp_tls_security_level = may
smtpd_sasl_security_options = noanonymous

编辑:-o smtpd_client_restrictions=permit_sasl_authenticated,reject从 中删除master.cf,添加了 的输出postconf -Mf

答案1

我的一个朋友发现了这个问题。Postfix 会评估所有限制列表,包括用于接收电子邮件的中继列表。由于我的配置在 末尾有一个“拒绝” smtpd_relay_restrictions,因此smtpd_recipient_restrictions从未被评估过。将 更改rejectdefer_unauth_destination即可解决问题。

答案2

postconf 程序默认只显示 main.cf 的内容,但 master.cf 中也有一些服务配置(postconf 需要一个特殊的“-M”标志来显示它)。 smtpd 服务看起来配置为只接受来自经过身份验证的客户端的电子邮件:

-o smtpd_client_restrictions=permit_sasl_authenticated,reject

相关内容