如何禁止尝试登录我的 postfix 的 IP?

如何禁止尝试登录我的 postfix 的 IP?

操作系统:centos7。

 tail -f /var/log/maillog

Oct 30 07:18:13 localhost postfix/smtpd[3181]: warning: unknown[191.96.249.63]: SASL LOGIN authentication failed: authentication failure
Oct 30 07:19:12 localhost postfix/smtpd[3181]: warning: unknown[191.96.249.70]: SASL LOGIN authentication failed: authentication failure
Oct 30 07:21:00 localhost postfix/smtpd[3184]: warning: unknown[41.191.224.5]: SASL LOGIN authentication failed: authentication failure

如何禁止试图登录我的 postfix 的 ip?
我看过一些资料说 postfix 可以设置黑名单来禁止某些 ip 地址。
使用 iptable 禁止和使用 postfix 的黑名单设置禁止效果一样吗?

答案1

如果您使用 iptables(Linux 的内置防火墙),那么您可以配置一条规则来丢弃来自该 IP 的所有数据包。

命令是:

iptables -A INPUT -s IP-ADDRESS -j DROP

其义为:

iptables - the name of the command which manages iptables.
-A - Appends the rule.
INPUT - is the name of the chain where the rule will be appended to.
-s - Defines source address.
IP-ADDRESS - The address you want the rule to affect on.
-j - Specifies the target of the rule
DROP - The action to take

然后,运行以下命令来应用更改:

service iptables save

对于你的情况,命令将是:

iptables -A INPUT -s 191.96.249.63 -j DROP
iptables -A INPUT -s 191.96.249.70 -j DROP
iptables -A INPUT -s 41.191.224.5 -j DROP
service iptables save

你还可以做另一件事,那就是安装失败禁止,它会自动禁止恶意 IP,我建议你检查一下,否则你将花一整天的时间禁止特定的 IP。

相关内容