Linux 技术手札

Postfix 使用 postgrey 实现灰名单Greylisting

Greylisting 是一种十分有效减少垃电邮的方法,它的原理是暂时拒绝接收邮件,正常的电邮服务器当不能送出邮件时会重新尝试,这时才接收这封电邮。而发送垃圾邮件的主机因为需要发出大量的电邮,为了加快进度,当不能传送后便会放弃。

postgrey 是在 Postfix 简单实现灰名单的工具,以下是安装及设定 postgrey 的方法。

安装 postgrey:

RHEL / CentOS:

# dnf install postgrey

# yum install postgrey

Debian / Ubuntu:

# apt-get install postgrey

现在启动及设定开机自动执行 postgrep:

# systemctl enable postgrey
# systemctl start postgrey

现在需要在 Postfix 设定使用 postgrey,开启 /etc/postfix/main.cf, 找到 smtpd_recipient_restrictions 的段落。
CentOS 默认会以 socket 的方式执行 postgrey,而 Ubuntu 则会在 port 10023 监听,需要安执行的方式设定,以下是 CentOS 的例子:

在 Ubuntu 则用类似以下设定:

然后新加载 Postfix:

# systemctl reload postfix
Exit mobile version