【问题标题】:Google Compute Engine will not allow incoming smtp connectionsGoogle Compute Engine 将不允许传入的 smtp 连接
【发布时间】:2013-05-29 16:41:22
【问题描述】:

我有一个在 Google 计算引擎上运行的虚拟机 (CentOS),一切看起来都非常简单,我已经阅读了我能找到的所有文档,但是这件事让我束手无策。我知道 GCE 阻止了出站 SMTP 连接,但是从我读过的内容来看,传入应该没有问题。但是,我已经正确配置了服务器(我认为)并通过 gcutil 为 SMTP 添加了防火墙,但仍然没有骰子:

gcutil addfirewall smtp --description="Incoming smtp allowed." --allowed="tcp:smtp"

这会添加允许 SMTP 连接的规则。

gcutil listfirewalls

    +------------------------+---------------------------------------+---------+------------+-------------+-------------+
    |          name          |              description              | network | source-ips | source-tags | target-tags |
    +------------------------+---------------------------------------+---------+------------+-------------+-------------+
    | default-allow-internal | Internal traffic from default allowed | default | 10.0.0.0/8 |             |             |
    | default-ssh            | SSH allowed from anywhere             | default | 0.0.0.0/0  |             |             |
    | http2                  | Incoming http allowed.                | default | 0.0.0.0/0  |             |             |
    | pop3                   | Incoming pop3 allowed.                | default | 0.0.0.0/0  |             |             |
    | smtp                   | Incoming smtp allowed.                | default | 0.0.0.0/0  |             |             |
    +------------------------+---------------------------------------+---------+------------+-------------+-------------+

SMTP 规则已列出。其他端口工作正常,我可以进入端口 80、22 和 110。但是当尝试进入端口 25 时:

telnet nextcore.com 25
Trying 173.255.112.1...

它不会连接。

连接到虚拟机上的 localhost 端口 25 工作正常:

telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 nextcore.localdomain ESMTP Postfix

我错过了什么?

【问题讨论】:

    标签: smtp google-compute-engine


    【解决方案1】:

    我不确定您在端口 25 上监听了什么(例如 sendmail、postfix 等)。我可以确认我也无法在端口 25 上连接到您的虚拟机,但我可以在端口 80 上连接。

    您可以使用sudo netstat -lpn -A inet 来检查哪些程序正在侦听哪些端口,例如

    $ sudo netstat -lpn -A inet
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2691/sshd
    tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      15845/nc
    udp        0      0 0.0.0.0:23153           0.0.0.0:*                           2291/dhclient
    udp        0      0 0.0.0.0:68              0.0.0.0:*                           2291/dhclient
    udp        0      0 10.87.233.49:123        0.0.0.0:*                           2566/ntpd
    udp        0      0 127.0.0.1:123           0.0.0.0:*                           2566/ntpd
    udp        0      0 0.0.0.0:123             0.0.0.0:*                           2566/ntpd
    

    您可能会发现您的邮件程序仅在 localhost (127.0.0.1) 上侦听,或者您在 /etc/hosts.allow 中缺少一个条目,或者在“/etc/hosts.deny”中有一个条目阻止来自外部的请求您的本地网络。

    【讨论】:

    • 呸,应该检查默认的后缀配置。您可以从我最初的问题中看到它是后缀监听,并且默认情况下它在 GCE 上的 CentOS VM 上是打开的,但我没有看到它被设置为只监听本地主机。更改 main.cf,重新启动 postfix,现在它正在接收外部连接。谢谢!
    【解决方案2】:

    你可以看看这个:https://developers.google.com/compute/docs/networking#mailserver 您将看到 Google Compute Engine 阻止了端口 25、465 和 587 上的出站连接。 该页面上还提供了设置 postfix 以使用 GCE 的说明。

    【讨论】:

    • 请在答案中引用链接文档中的相关部分。
    猜你喜欢
    • 2018-04-28
    • 1970-01-01
    • 2018-08-15
    • 2020-09-25
    • 2014-05-21
    • 1970-01-01
    • 2020-01-28
    • 2021-05-28
    • 2014-12-14
    相关资源
    最近更新 更多