阻止SMTP端口阻止服务器发送电子邮件?

我有一个与cPanel的Centos服务器。

昨天,一些黑客已经成功地连接到我的smpt服务器,并从它发送了数以千计的电子邮件。

我想要做的是阻止每个端口除了HTTP和HTTPS端口给所有人(IN和OUT),除了一些IPS(用于pipe理目的)。

在过去的几个月里,我已经做了这个smpt端口打开。 这是完美的,但我想知道阻塞端口25,465和587(IN和OUT)将阻止服务器本身发送电子邮件。 我有一些需要发送电子邮件的PHP脚本。

我不想要任何电子邮件帐户,所以从邮件客户端发送电子邮件是没有必要的。

SMTP涉及端口25上的两个SMTP服务器之间的对话。我将复制并粘贴来自此网站的示例会话, 该会话演示使用telnettestingSMTP:

 telnet: > telnet mx1.example.com smtp telnet: Trying 192.0.2.2... telnet: Connected to mx1.example.com. telnet: Escape character is '^]'. server: 220 mx1.example.com ESMTP server ready Tue, 20 Jan 2004 22:33:36 +0200 client: HELO client.example.com server: 250 mx1.example.com client: MAIL from: <[email protected]> server: 250 Sender <[email protected]> Ok client: RCPT to: <[email protected]> server: 250 Recipient <[email protected]> Ok client: DATA server: 354 Ok Send data ending with <CRLF>.<CRLF> client: From: [email protected] client: To: [email protected] client: Subject: Test message client: client: This is a test message. client: . server: 250 Message received: [email protected] client: QUIT server: 221 mx1.example.com ESMTP server closing connection 

如果你只允许传出,这将是一个简短的谈话。 您的服务器永远不会收到来自远程SMTP服务器的任何回复。

换句话说:是的,它会阻止邮件。

是的,如果你阻塞端口# 没有成功的沟通,这是需要的服务工作。

或者,不要在需要的时候阻塞连接和解除阻塞(这就是你想要做的),你可以停止服务器,只在需要的时候启动它,看起来像一个“更干净”的选项。