记录开通 25 号端口的经历

2022-01-16 ⏳4.6分钟(1.9千字)

我的博客使用虚拟主机搭建。既然有了公网服务器,为什么不自己搭建电子邮箱服务呢?测试了一下发现,我的服务商居然封锁了 25 号端口。于是给商家提工单。经过漫长的沟通,最终商家开通了 25 号端口的入站访问。在沟通的过程中,商家披露了一些电子邮件相关的细节,也挺有意思。整个沟通过程也给予我不少启发。今天就把过程记录下来,分享给大家。

我是在1月8号提的工单。他们很快就回复说要我使用更安全的 465 端口。显然,我没有把问题说明白。关于 25/465 这样的端口号,大家可以阅读我之前写的细说电子邮件的端口号1

于是我开诚布公,说自己想在服务器上搭建邮箱服务,需要开通 25 号端口权限。谁成想他们直接建议我使用别家的产品:

Sorry, we don’t recommend hosting mail server with our service since we don’t support customized rDNS/PTR.

一副爱搭不理的样子。我之前用过阿里云,也是封 25 号端口。但可以通过工单申请开通。于是我继续留言说能否单独为我开通,被断然拒绝:

We didn’t prevent you from doing this, but just to prevent SPAM, we block the outbound 25. If you aren’t dissatisfied with this, you can don’t pay the renewal invoice.

他们回复说是封掉了出站的 25 号端口流量。你不能在虚拟主机上访问外部服务器的 25 号端口。换句话说就是你不能通过 SMTP 协议给别人发邮件。我又自己测试了一下,发现入站流量也被封锁了。其他服务器同样无法访问虚拟主机的 25 号端口。

然后,我就辩护称,并不是所有人都要发垃圾邮件。而且入站流量又不会产生垃圾邮件问题,为什么也要封呢?对方给出了详细回复:

Outbound 25 means sending emails via port 25 from our network to the outside, and Inbound 25 means receiving emails via port 25 from the outside. Receiving won’t cause SPAM but Sending will. That’s why we do this. Also, we do know that not everyone will do SPAM, but each SPAM means 25 USD SPAM fine from our IP Provider, so we just block them all.

这里面最有意思的就是,如果有垃圾邮件从服务商的网络中发出,那么每发一封,服务商就会被罚款 25 美元。所以他们的态度才会这么坚决。都是钱呀。反观国内,垃圾短信、诈骗电话横行,却从来没有处罚运营商的机制。哪怕现在都实名制了,问题还是不少。看到这个消息,我也就打消了使用服务器发邮件的念头。基本是不可能了。

但是,我觉得他们不应该封入站的 25 号端口。我认为邮件系统更重要的功能是接收。不能发信,做一个收信服务也是好的嘛。于是继续反馈,问能不能允许 25 号端口的入站流量。结果收到了一大拨不专业的回复:

Sorry, since block the outbound 25 and TCP handshake is two-way, it means inbound 25 will also be affected due to can’t finish the complete handshake progress.

We do allow that, you can test via UDP 25, since TCP 25 can’t finish handshake due to outbound 25 has been blocked.

If you want to receive email via port 25 then we can’t block outbound 25. That’s the problem of TCP 3-Way Handshake, and it’s not our problem.

然后我详细解释了为什么入站流量跟出站流量没关系。在技术上可以实现允许入站流量的同时阻止出站流量。

If you really consult a real network or security engineer, you will confirmed there is no need to block the inbound 25 while block the outbound one.

我感觉这个人只是售后,并不懂技术,所以请求他把工单转给网络工程师:

If you do not understand what I said, I beg you to forward this ticket to you network engineer. I guess they will agree with me.

我甚至还说可以提供具体的防火墙规则:

If your team use the iptables, I can even offer the detailed firewall rules for you.

最后,来了一个自我升华,免得他们又一口回绝,让我去用其他服务商:

BTW, please do not just recommend me use other providers. DMIT is not bad. And I wish it will become better.

后面接待的人应该是真正的网络工程师了。他说光在洛杉矶机房,就有80Gbps的流量,不可能使用 iptables 来处理。他们的核心路由器也不支持根据连接状态过滤数据:

We don’t use iptables, we have about 80Gbps traffic at the Los Angles location, and still increasing. The iptables cannot handle the traffic at this level with the line rate.

Juniper MX / Cisco ASR / Arista CR and any line-rate architecture devices will not support the stateful firewall. The kernel bypass design will also make there is no way to filter the packet in the host node by iptables or Netfilter.

All the packets sent to any TCP 25 destination will be dropped at the Core Router. The rule is only for our own IP resources. There is no filter for IP Transit clients.

看到回复,我就知道这里面有误会。于是回复提醒说,这个功能根本不需要所谓的 stateful firewall,还提供了思科路由器的相关配置信息。当然是从 Google 查来的😊

最后,到了1月16号,终于解决了问题:

Our current rule is that try to block any packet with the destination-port TCP 25.

After I checked, the Pro network didn’t have the same rules as the Lite network. I’ve updated it.

其实他们只想封锁出站流量。但防火墙规则配错了,所以影响到了入站流量。为了表示感谢,他们还给我的帐户加了10美元:

Thanks for your patient and all information. I’ve added a 10USD bonus credit for this case.

到此问题圆满解决。好多人可能觉得我是在较真,没有必要这么折腾。但我不这么想。这个世界上有很多不合理的事情,有些是有意为之,有些是无心之作。所谓不平则名。遇到事情,我们应该在能力范围之内去争取解决。在解决的过程中要摆事实、讲道理。这一条我也在如何参与开源项目讨论过。通过我们的努力,可能有一些事情就解决了,其他人也可能跟着受益。如果大家都这么「较真」,那我们的世界就会越来越美好。

我用的是 DMIT 的主机和网络,线路是 CN2 GIA,国内访问非常稳定。 有需要的朋友也可以使用我的推广链接注册。


  1. email-ports.html↩︎