我繼承了一個在 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 伺服器訪問,但是,4 個中的 3 個在 postfix 日誌中逾時。
關於如何找出 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 ~]$
新增了 22 年 4 月 20 日 - 郵件中繼之間的設備
我們無法了解中繼之間的網路或安全設備。 Traceroute 僅指示 3 個躍點,根據我們網路佈局中的 IP 位址,所有這些躍點很可能都是標準路由器。
新增於 22 年 4 月 20 日 - Postfix 版本
Postfix 似乎是版本 2.10.1 ,這將在 2013 年左右安裝 根據 Postfix 版本頁面
新增了 22 年 4 月 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)
新增了 22 年 4 月 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)
[刪除重複項,該伺服器的所有項目都是完全相同的兩個訊息]
最終編輯 2022 年 4 月 27 日
在上週的故障排除中,我們發現 /etc/resolv.conf 有一個不再存在的名稱伺服器。刪除這個並重新啟動 postfix 後,我們似乎不再在日誌中看到逾時,而且郵件流動很快。
正如 @anx 在評論中提到的,這對於連接超時來說沒有多大意義,但是一旦它被修復並且 postfix 重新啟動,我們的出站發送速度就會急劇增加,並且我們還沒有遇到任何問題。儘管每天增加超過20,000 封額外的出站測試電子郵件(比常規郵件量增加約30%),但此後仍出現延遲問題。
答案1
據我們所知,此問題是由 /etc/resolv.conf 中的 DNS 條目無效引起的。一旦錯誤的條目被刪除,我們就不再出現日誌中的問題,並且郵件恢復正常流動,並且出站延遲最小。