无法访问 SMTP 端口 25

无法访问 SMTP 端口 25

重启 VPS 后,我最近设置的电子邮件服务器无法正常工作。具体来说,它无法接受端口 25 上的连接。重启之前可以。我尝试了几种方法,但不确定哪里出了问题。我希望问题很简单,但我担心可能是 SystemD、FirewallD 和 OpenVZ(使用的虚拟化类型)之间不兼容*。

需要澄清的是,在重启之前,我能够使用 telnet 向我的服务器发送邮件。我还能够从我的 gmail 帐户向服务器发送邮件/从服务器接收邮件。

我希望有人能帮助我诊断这个问题。

我认为问题出在防火墙上。以下是从 VPS 到其自身的成功 telnet 连接:

[root@VPS ~]# telnet mydomain.com 25
Trying <Server IP>...
Connected to mydomain.com.
Escape character is '^]'.
220 mail.mydomain.com ESMTP Exim 4.84_2 Mon, 13 Jun 2016 00:38:39 -0400
> HELO test
250 mail.mydomain.com Hello mydomain.com [Server IP]
> QUIT
221 mail.mydomain.com closing connection
Connection closed by foreign host.

从其他机器尝试连接时失败。请注意,域名确实解析了,这是我用来连接ssh到 VPS的 Windows 机器。ssh [email protected]

C:\Users\Liam>telnet mydomain.com 25
Connecting To mydomain.com...Could not open connection to the host, on port 25: Connect failed

以下是防火墙区域信息:

[root@VPS ~]# firewall-cmd --zone=public --list-all
public (default)
  interfaces:
  sources:
  services: dhcpv6-client imaps pop3s smtp ssh
  ports: 25/udp 587/udp 80/tcp 465/udp 465/tcp 25/tcp 587/tcp 9418/tcp 53/tcp 53/udp
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

以下是 FirewallD 的当前状态

[root@VPS~]# systemctl status firewalld
* firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2016-06-12 23:14:35 EDT; 1h 30min ago
 Main PID: 941 (firewalld)
   CGroup: /system.slice/firewalld.service
           `-941 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Jun 12 23:14:34 hostname systemd[1]: Starting firewalld - dynamic firewall daemon...
Jun 12 23:14:35 hostname systemd[1]: Started firewalld - dynamic firewall daemon.
Jun 12 23:14:35 hostname firewalld[941]: 2016-06-12 23:14:35 ERROR: ebtables not usable, disabling ethernet bridge firewall.

我不确定重启之前是否存在该错误,但是*这个帖子有一些关于错误以及 FirewallD + OpenVZ 的相关信息。

以下是 exim 和 dovecot 的状态,以及命名。

[root@VPS~]# systemctl status {exim,dovecot,named}
 * exim.service - Exim Mail Transport Agent
   Loaded: loaded (/usr
 * List item

/lib/systemd/system/exim.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2016-06-12 22:08:27 EDT; 2h 38min ago
 Main PID: 172 (exim)
   CGroup: /system.slice/exim.service
           `-172 /usr/sbin/exim -bd -q1h

Jun 12 22:08:27 hostname systemd[1]: Starting Exim Mail Transport Agent...
Jun 12 22:08:27 hostname systemd[1]: Started Exim Mail Transport Agent.

* dovecot.service - Dovecot IMAP/POP3 email server
   Loaded: loaded (/usr/lib/systemd/system/dovecot.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2016-06-12 22:08:27 EDT; 2h 38min ago
 Main PID: 182 (dovecot)
   CGroup: /system.slice/dovecot.service
           |-182 /usr/sbin/dovecot -F
           |-205 dovecot/anvil
           |-206 dovecot/log
           |-866 dovecot/auth
           `-869 dovecot/ssl-params

Jun 12 22:08:27 hostname systemd[1]: Starting Dovecot IMAP/POP3 email server...
Jun 12 22:08:27 hostname systemd[1]: Started Dovecot IMAP/POP3 email server.

* named.service - Berkeley Internet Name Domain (DNS)
   Loaded: loaded (/usr/lib/systemd/system/named.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2016-06-12 22:08:27 EDT; 2h 38min ago
 Main PID: 191 (named)
   CGroup: /system.slice/named.service
           `-191 /usr/sbin/named -u named

Jun 12 22:08:27 hostname named[191]: zone 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa/IN: loaded serial 0
Jun 12 22:08:27 hostname named[191]: zone localhost.localdomain/IN: loaded serial 0
Jun 12 22:08:27 hostname 967277 named[191]: zone localhost/IN: loaded serial 0
Jun 12 22:08:27 hostname named[191]: zone mydomain.com/IN: loaded serial 0
Jun 12 22:08:27 hostname named[191]: all zones loaded
Jun 12 22:08:27 hostname systemd[1]: Started Berkeley Internet Name Domain (DNS).
Jun 12 22:08:27 hostname named[191]: running
Jun 12 22:08:27 hostname named[191]: zone domain.com/IN: sending notifies (serial 0)
Jun 12 22:15:21 hostname systemd[1]: Started Berkeley Internet Name Domain (DNS).
Jun 12 23:08:27 hostname named[191]: listening on IPv4 interface venet0:0, <VPS IP>#53

摘自我的exim.conf文件:

[root@VPS~]# cat /etc/exim/exim.conf | grep daemon_smtp
daemon_smtp_ports = 25 : 465 : 587

而且,我不确定这是否相关,但这里有一些iptables信息。

[root@VPS~]# iptables -L | grep smtp
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:smtp ctstate NEW
ACCEPT     udp  --  anywhere             anywhere             udp dpt:smtp ctstate NEW
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:smtp ctstate NEW
[root@VPS~]# iptables -L -n | grep 25
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:25 ctstate NEW
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:25 ctstate NEW
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:25 ctstate NEW 

我很乐意提供更多可能相关的信息。另外,这是我在网站上的第一篇帖子。我认为这是主题,但我也简要讨论了 Unix 或 Superuser。

更新

我关闭了防火墙:

[root@domain~]# systemctl stop firewalld
[root@domain~]# systemctl status firewalld
* firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Mon 2016-06-13 01:52:47 EDT; 4s ago
  Process: 941 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 941 (code=exited, status=0/SUCCESS)

Jun 12 23:14:34 hostname systemd[1]: Starting firewalld - dynamic fire....
Jun 12 23:14:35 hostname systemd[1]: Started firewalld - dynamic firew....
Jun 12 23:14:35 hostname firewalld[941]: 2016-06-12 23:14:35 ERROR: eb....
Jun 13 01:52:47 hostname systemd[1]: Stopping firewalld - dynamic fire....
Jun 13 01:52:47 hostname systemd[1]: Stopped firewalld - dynamic firew....
Hint: Some lines were ellipsized, use -l to show in full.

然后我检查了iptables服务

[root@domain~]# systemctl status iptables
* iptables.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)
[root@domain~]# service iptables status
Redirecting to /bin/systemctl status  iptables.service
* iptables.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

当我尝试通过 25 端口 telnet 到 VPS 时仍然出现同样的错误。

答案1

问题可能出在您的机器之外。您可以尝试远程登录您的 ISP SMTP 服务器或 Gmail 服务器,以测试它是否正常工作。

有些 ISP 会阻止 SMTP 连接,以阻止病毒从非托管计算机传播。对于这种情况,您可以要求 ISP 打开从您的计算机到服务器的连接。

相关内容