Ubuntu

Exim 說 DNS 查找成功,但也說“主機查找未完成”

  • September 12, 2014

我正在嘗試向我網站的使用者發送自動通知電子郵件。這些電子郵件由自定義守護程序發送給使用者,該守護程序通過 exim 4 發送它們。Exim 在這方面的作用只是將郵件中繼到與收件人地址關聯的郵件伺服器。必須轉發所有傳出的電子郵件。沒有本地電子郵件,也沒有收到的郵件。

但是,當我嘗試發送電子郵件時,我的守護程序總是得到以下響應:

com.sun.mail.smtp.SMTPAddressFailedException: 451 Temporary local problem - please try later

/var/log/exim4/mainlog中,我有以下幾行

2014-09-09 22:30:50 no host name found for IP address 10.0.2.2
2014-09-09 22:30:50 H=(lotp-lanbox) [10.0.2.2] F=<noreply@mydomain.com> temporarily rejected RCPT <foobar@romandie.com>: host lookup did not complete

(請注意,10.0.2.2 是安裝了發送者守護程序的主機的 IP 地址。)

該消息很奇怪,但缺少細節。這是我啟動的另一個調試命令:

user@host:~$ exim4 -bt -d-resolver foobar@romandie.com
Exim version 4.82 uid=0 gid=0 pid=14035 D=fbb95cfd
Berkeley DB: Berkeley DB 5.3.28: (September  9, 2013)
Support for: crypteq iconv() IPv6 GnuTLS move_frozen_messages DKIM
Lookups (built-in): lsearch wildlsearch nwildlsearch iplsearch cdb dbm dbmjz dbmnz dnsdb dsearch nis nis0 passwd
Authenticators: cram_md5 plaintext
Routers: accept dnslookup ipliteral manualroute queryprogram redirect
Transports: appendfile/maildir/mailstore autoreply lmtp pipe smtp
Fixed never_users: 0
Size of off_t: 8
Compiler: GCC [4.8.2]
Library version: GnuTLS: Compile: 2.12.23
                        Runtime: 2.12.23
Library version: PCRE: Compile: 8.31
                      Runtime: 8.31 2012-07-06
Total 13 lookups
WHITELIST_D_MACROS: "OUTGOING"
TRUSTED_CONFIG_LIST: "/etc/exim4/trusted_configs"
changed uid/gid: forcing real = effective
 uid=0 gid=0 pid=14035
 auxiliary group list: <none>
seeking password data for user "uucp": cache not available
getpwnam() succeeded uid=10 gid=10
changed uid/gid: calling tls_validate_require_cipher
 uid=109 gid=116 pid=14036
 auxiliary group list: <none>
tls_validate_require_cipher child 14036 ended: status=0x0
configuration file is /var/lib/exim4/config.autogenerated
log selectors = 00000ffc 00632001
trusted user
admin user
seeking password data for user "mail": cache not available
getpwnam() succeeded uid=8 gid=8
user name "root" extracted from gecos field "root"
originator: uid=0 gid=0 login=root name=root
sender address = root@dev
Address testing: uid=0 gid=116 euid=0 egid=116
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Testing foobar@romandie.com
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Considering foobar@romandie.com
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
routing foobar@romandie.com
--------> hubbed_hosts router <--------
local_part=foobar domain=romandie.com
checking domains
expansion of "${if exists{/etc/exim4/hubbed_hosts}{partial-lsearch;/etc/exim4/hubbed_hosts}fail}" forced failure: assume not in this list
hubbed_hosts router skipped: domains mismatch
--------> dnslookup_relay_to_domains router <--------
local_part=foobar domain=romandie.com
checking domains
romandie.com in "@:localhost"? no (end of list)
romandie.com in "*"? yes (matched "*")
romandie.com in "! +local_domains : +relay_to_domains"? yes (matched "+relay_to_domains")
R: dnslookup_relay_to_domains for foobar@romandie.com
calling dnslookup_relay_to_domains router
dnslookup_relay_to_domains router called for foobar@romandie.com
 domain = romandie.com
DNS lookup of romandie.com (MX) succeeded
dnslookup_relay_to_domains router: defer for foobar@romandie.com
 message: host lookup did not complete
foobar@romandie.com cannot be resolved at this time: host lookup did not complete
search_tidyup called
>>>>>>>>>>>>>>>> Exim pid=14035 terminating with rc=1 >>>>>>>>>>>>>>>>

這是對我來說特別奇怪的摘錄(從該輸出的末尾開始):

dnslookup_relay_to_domains router called for foobar@romandie.com
 domain = romandie.com
DNS lookup of romandie.com (MX) succeeded
dnslookup_relay_to_domains router: defer for foobar@romandie.com
 message: host lookup did not complete
foobar@romandie.com cannot be resolved at this time: host lookup did not complete

DNS 查找如何既成功又不完成?我究竟做錯了什麼?

我嘗試使用dig安裝 exim4 的機器進行 DNS 查找,結果對我來說很好:

user@host:~$ dig mx romandie.com
;; Warning: Message parser reports malformed message packet.

; <<>> DiG 9.9.5-3-Ubuntu <<>> mx romandie.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36151
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: Message has 1 extra bytes at end

;; QUESTION SECTION:
;romandie.com.                  IN      MX

;; ANSWER SECTION:
romandie.com.           3600    IN      A       37.35.105.169
romandie.com.           3600    IN      A       37.35.105.166

;; Query time: 19 msec
;; SERVER: 10.0.2.3#53(10.0.2.3)
;; WHEN: Tue Sep 09 23:14:45 UTC 2014
;; MSG SIZE  rcvd: 63

查找本身看起來不錯。

為什麼 exim 說它同時成功和失敗?

您正在使用的遞歸 DNS 解析器(打開的那個10.0.2.3)已嚴重損壞。在您的 dig 命令中,您要求它進行MX記錄。但它會發送一個包含兩條A記錄的答案。這甚至不是因為域沒有MX記錄。我剛查了一下,確實有MX那個域的記錄。而且dig警告你回複數據包格式不正確WARNING: Message has 1 extra bytes at end

我建議您停止使用那個有問題的 DNS 伺服器。嘗試將另一個 DNS 解析器放入/etc/resolv.conf. 我有很好的使用經驗8.8.8.8

引用自:https://serverfault.com/questions/627425