CentOS 7 Web服务器已安装了postfix,dovecot和mailx。我已经能够与服务器建立IMAP连接,以便使用远程Thunderbird客户端读取收件箱邮件,但是我无法建立SMTP连接以从Thunderbird发送电子邮件。进行取证时,我发现尝试的SMTP连接超时。如何解决连接超时的问题,以便可以通过服务器从Thunderbird发送电子邮件?
到目前为止,我的取证结果是:
hostname
在服务器上输入终端会返回mydomain.com
。
nano /usr/lib/firewalld/services/smtp.xml
表示smtp端口为25
在公共区域中激活了smtp服务,因为会firewall-cmd --list-all
导致:
public (default, active)
interfaces: enp3s0
sources:
services: dhcpv6-client imaps openvpn smtp
ports:
masquerade: yes
forward-ports:
icmp-blocks:
rich rules:
但是,当我尝试从devbox远程登录到远程CentOS 7服务器时,会得到以下结果。键入telnet mydomain.com 25
导致:
Trying my.SERVER.ip.addr...
telnet: connect to address my.SERVER.ip.addr: Connection timed out
然后输入telnet smtp.mydomain.com 25
结果:
Trying my.SERVER.ip.addr...
telnet: connect to address my.SERVER.ip.addr: Connection timed out
另外,键入openssl s_client -CApath /etc/ssl/certs -starttls smtp -port 25 -host smtp.mydomain.com
结果为:
socket: Connection timed out
connect:errno=110
同样,键入openssl s_client -CApath /etc/ssl/certs -starttls smtp -port 25 -host mydomain.com
也会导致:
socket: Connection timed out
connect:errno=110
我键入nano /etc/postfix/main.cf
以开始检查配置,但未找到任何与端口有关的内容。
编辑:
根据FaheemMitha的建议,我telnet mydomain.com 587
从客户那里进行了尝试,并得到No route to host
了回复。我认为这是因为在smtp的firewalld中仅打开了端口25。
因此,我想从远程服务器mydomain.com内尝试telnet。当我通过ssh登录到远程服务器并输入时telnet localhost 25
,结果是:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mydomain.com ESMTP Postfix
这使我怀疑postfix在端口25上运行,但是某种程度上它不能接受外部连接。
编辑#2
按照@RedCricket的建议,我跑了iptables -L
。由于结果很冗长,因此我将它们上传到了文件共享站点,您可以通过单击此链接来查看该站点。
我还尝试iptables --flush
了firewall-cmd --reload
,然后尝试了,然后从上面重复了telnet和thunderbird的测试,但是我仍然遇到连接超时错误。
我还能尝试什么?
我将整个上传/etc/postfix/main.cf
到文件共享站点。您可以通过单击此链接阅读它。
编辑#3
有效的电子邮件地址someone.else@some_other_domain.com可以毫无问题地将电子邮件发送到[email protected]。因此,作为测试,我让我的远程Thunderbird客户端尝试将电子邮件发送给该person.else@some_other_domain.com,作为该操作文档中上面记录的工作的一部分。今天早上,由于测试电子邮件,我在Thunderbird中收到了“发回发件人”消息。我将返回的消息解释为意味着至少有我来自Thunderbird的测试消息之一进入了mydomain.com上的SMTP,但是mydomain.com无法查找或以其他方式连接到some_other_domain.com。这是消息:
This is the mail system at host mydomain.com.
I'm sorry to have to someone.elserm you that your message could not
be delivered to one or more recipients. It's attached below.
For further assistance, please send mail to postmaster.
If you do so, please include this problem report. You can
delete your own text from the attached returned message.
The mail system
<someone.else@some_other_domain.com>: Host or domain name not found. Name service error for
name=some_other_domain.com type=MX: Host not found, try again
Reporting-MTA: dns; mydomain.com
X-Postfix-Queue-ID: 2C915811BD1C
X-Postfix-Sender: rfc822; [email protected]
Arrival-Date: Mon, 23 Feb 2015 16:46:34 -0500 (EST)
Final-Recipient: rfc822; someone.else@some_other_domain.com
Action: failed
Status: 4.4.3
Diagnostic-Code: X-Postfix; Host or domain name not found. Name service error
for name=some_other_domain.com type=MX: Host not found, try again
ForwardedMessage.eml
Subject: key enclosed
From: [email protected]
Date: 02/23/2015 01:46 PM
To: someone.else@some_other_domain.com
this is the body of the email
因此,似乎有时关闭了从我的远程devbox到mydomain.com的连接,而在其他时候,则关闭了从mydomain.com到Internet其余部分的连接。
编辑#4
按照@derobert的建议,我首先尝试了从devbox到服务器的两个telnet命令,然后尝试使用devbox上的Thunderbird客户端从[email protected]发送电子邮件,然后在两个devbox并在服务器上。打字tcpdump port 25
在devbox终端产生下列:
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
在tun0上侦听,链接类型RAW(原始IP),捕获大小65535字节^ C 0捕获的数据包过滤器接收的0数据包内核丢弃的0数据包
接下来,tcpdump
在服务器上键入会产生大量输出,结果结果无休止地滚动,直到我键入Ctrl-C为止。因此,我输入tcpdump port 25
了以下结果:
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on tun0, link-type RAW (Raw IP), capture size 65535 bytes
^C
0 packets captured
0 packets received by filter
0 packets dropped by kernel
出于好奇,我随后tcpdump port 25
同时在devbox和服务器上再次键入内容Ctrl-C
,并使其保持打开状态而没有键入,然后我尝试使用devbox上的Thunderbird客户端从[email protected]手动发送电子邮件。我仍然遇到相同的连接超时失败,但是打开tcpdump port 25
命令没有报告活动。之后,当我Ctrl-C
在两个终端上键入内容时,总数也变为零。
经过大量的故障排除后,我们确定客户端的ISP阻止了传出端口25(SMTP)。通过使用Internet上的随机邮件服务器测试站点并发现它可以正常连接到邮件服务器,可以证实这一点。来自客户端计算机的SMTP数据包根本没有到达(通过确认tcpdump
)。
解决方案是在其他端口上重新配置SMTP侦听器。常用选项为465(基于SSL的SMTP)和587(邮件提交,RFC6409)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句