Postfix - 排除除一台服务器之外的所有服务器的连接超时故障

Postfix - 排除除一台服务器之外的所有服务器的连接超时故障

我继承了一个在 RedHat 上运行的 Postfix 服务器。这是一个未记录的版本,但对于业务运营至关重要(难道我们都不喜欢这些吗?)

邮件投递出现延迟和积压问题。这些问题是几周前首次报告的,但可能持续很长时间。

我对 *nix 的经验很少,但我已经能够对系统进行足够的了解,以确定当服务器遇到积压时,它会向我组织的上游 SMTP 中继报告连接超时。

错误示例:

*3D27412A016
4187 4月19日星期二 17:04:26
[电子邮件保护]

(传送暂停:连接到 UpstreamRelayA4.doi.net[10.xx.xx.206]:25:连接超时)

[电子邮件保护]*

但是,上游中继所有者报告称,他们没有在 SMTP 服务器日志中发现匹配错误。我的组织有一条 MX 记录,其中包含 4 个中继服务器。所有 4 个服务器都可以通过端口 25 上的 telnet 从我的 SMTP 服务器访问,但是,在 postfix 日志中,4 个服务器中有 3 个超时了。

关于如何追踪 Postfix 认为其超时的原因,有什么提示吗?

添加 4/20/22 - postconf -n 输出

    [USERNAME@mailer ~]$ postconf -n

alias_database = hash:/etc/aliases

alias_maps = hash:/etc/aliases

broken_sasl_auth_clients = yes

command_directory = /usr/sbin

config_directory = /etc/postfix

daemon_directory = /usr/libexec/postfix

debug_peer_level = 2

debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin xxgdb
 
$daemon_directory/$process_name $process_id & sleep 5

disable_vrfy_command = yes

html_directory = no

inet_interfaces = all

inet_protocols = ipv4

local_recipient_maps =

mail_owner = postfix

mail_spool_directory = /var/mail

mailbox_size_limit = 0

mailq_path = /usr/bin/mailq.postfix

manpage_directory = /usr/share/man

maximal_queue_lifetime = 1d

message_size_limit = 30720000

mydestination = $myhostname, localhost.$mydomain, localhost

myhostname = mailer.domain.org.com

mynetworks = 

127.0.0.0/8,165.83.0.0/16,10.0.0.0/8,64.241.25.0/24,172.16.0.0/12

myorigin = $mydomain

newaliases_path = /usr/bin/newaliases.postfix

queue_directory = /var/spool/postfix

readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES

relayhost = relayLOCATION.parentorg.com

sample_directory = /usr/share/doc/postfix-2.10.1/samples

sendmail_path = /usr/sbin/sendmail.postfix

setgid_group = postdrop

smtp_tls_note_starttls_offer = yes

smtp_use_tls = yes

smtpd_delay_reject = yes

smtpd_helo_required = yes

smtpd_helo_restrictions = 
permit_mynetworks,reject_non_fqdn_helo_hostname,reject_invalid_helo_hostname,permit

smtpd_policy_service_max_idle = 5s

smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination

smtpd_sasl_auth_enable = yes

smtpd_sasl_authenticated_header = yes

smtpd_sasl_local_domain =

smtpd_sasl_security_options = noanonymous

smtpd_sender_restrictions = permit_mynetworks,reject_non_fqdn_sender,permit

smtpd_tls_CAfile = /etc/postfix/ssl/mailer_DOMAIN_ORG_COM.pem

smtpd_tls_auth_only = no

smtpd_tls_cert_file = /etc/postfix/ssl/mailer_DOMAIN_ORG_COM.crt

smtpd_tls_key_file = /etc/postfix/ssl/mailer_DOMAIN_ORG_COM.key

smtpd_tls_loglevel = 1

smtpd_tls_security_level = may

smtpd_use_tls = yes

tls_random_source = dev:/dev/urandom

transport_maps = hash:/etc/postfix/transport

[USERNAME@mailer ~]$

已添加 4/20/22 - postconf -M 输出

[USERNAME@mailer ~]$ postconf -M
smtp       inet  n       -       n       -       -       smtpd
pickup     fifo  n       -       n       60      1       pickup
cleanup    unix  n       -       n       -       0       cleanup
qmgr       fifo  n       -       n       300     1       qmgr
tlsmgr     unix  -       -       n       1000?   1       tlsmgr
rewrite    unix  -       -       n       -       -       trivial-rewrite
bounce     unix  -       -       n       -       0       bounce
defer      unix  -       -       n       -       0       bounce
trace      unix  -       -       n       -       0       bounce
verify     unix  -       -       n       -       1       verify
flush      unix  n       -       n       1000?   0       flush
proxymap   unix  -       -       n       -       -       proxymap
smtp       unix  -       -       n       -       -       smtp
relay      unix  -       -       n       -       -       smtp -o fallback_relay=
showq      unix  n       -       n       -       -       showq
error      unix  -       -       n       -       -       error
discard    unix  -       -       n       -       -       discard
local      unix  -       n       n       -       -       local
virtual    unix  -       n       n       -       -       virtual
lmtp       unix  -       -       n       -       -       lmtp
anvil      unix  -       -       n       -       1       anvil
scache     unix  -       -       n       -       1       scache
maildrop   unix  -       n       n       -       -       pipe flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}
old-cyrus  unix  -       n       n       -       -       pipe flags=R user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -m ${extension} ${user}
cyrus      unix  -       n       n       -       -       pipe user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -r ${sender} -m ${extension} ${user}
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=foo argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient
retry      unix  -       -       n       -       -       error
proxywrite unix  -       -       n       -       1       proxymap
[USERNAME@mailer ~]$

已添加 4/20/22 - 邮件中继之间的设备

我们无法看到中继器之间的网络或安全设备。Traceroute 仅显示 3 个跳数,根据网络布局中的 IP 地址,所有这些跳数很可能都是标准路由器。

已添加 4/20/22 - Postfix 版本

Postfix 似乎是 2.10.1 版本,这意味着安装时间大约在 2013 年 根据 Postfix 发布页面

已添加 4/22/22 - openssl 连接测试

[USERNAME@mailer ~]$ openssl s_client -connect UPSTREAM_RELAY.ORG.net:25 -starttls smtp -crlf
CONNECTED(00000003)
depth=1 DC = net, DC = ORG, CN = CA_Server
verify error:num=20:unable to get local issuer certificate
---
Certificate chain
 0 s:/C=US/ST=STATE/L=CITY/O=PARENT_ORG/OU=PARENT_ORG/CN=UPSTREAM_RELAY.ORG.net
   i:/DC=net/DC=ORG/CN=CA_Server
 1 s:/DC=net/DC=ORG/CN=CA_Server
   i:/CN=ORGRootCA2
---
Server certificate
-----BEGIN CERTIFICATE-----

[Cert contents removed]

-----END CERTIFICATE-----
subject=/C=US/ST=STATEA/L=CITY/O=PARENT_ORG/OU=PARENT_ORG/CN=UPSTREAM_RELAY.ORG.net
issuer=/DC=net/DC=ORG/CN=CA_Server
---
No client certificate CA names sent
Peer signing digest: SHA1
Server Temp Key: ECDH, P-384, 384 bits
---
SSL handshake has read 5841 bytes and written 538 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES256-SHA384
    Session-ID: [REMOVED]
    Session-ID-ctx:
    Master-Key: [REMOVED]
    Key-Arg   : None
    Krb5 Principal: None
    PSK identity: None
    PSK identity hint: None
    Start Time: 1650649689
    Timeout   : 300 (sec)
    Verify return code: 20 (unable to get local issuer certificate)
---
250 XSHADOWREQUEST
 (Functional console after this)

已添加 4/22/22 - 用于非工作服务器的 Maillog grep

[USERNAME@mailer ~]$  sudo mailq | grep  UPSTREAM_RELAY_103.ORG.net

(delivery temporarily suspended: conversation with UPSTREAM_RELAY_103.ORG.net[10.x.x.125] timed out while sending end of data -- message may be sent more than once)

(conversation with UPSTREAM_RELAY_103.ORG.net[10.x.x.125] timed out while sending end of data -- message may be sent more than once)

[删除重复项,该服务器的所有条目都是完全相同的两条消息]

最终编辑 4/27/2022

在上周的故障排除中,我们发现 /etc/resolv.conf 中有一个不再存在的名称服务器。删除它并重新启动 postfix 后,日志中不再出现超时,邮件传输也变得快速。

正如@anx 在评论中提到的那样,这对于连接超时来说没有多大意义,但是一旦它被修复并且postfix重新启动,我们的出站发送速度就会大幅增加,而且从那以后我们就没有遇到任何延迟问题,尽管每天增加了超过20,000封额外的出站测试电子邮件(比常规邮件量增加了大约30%)。

答案1

据我们所知,这个问题是由于 /etc/resolv.conf 中存在无效的 DNS 条目而引起的。删除错误条目后,日志中的问题就消失了,邮件也恢复正常,出站延迟也降到了最低。

相关内容