后缀允许localhost只有本地用户

我有一个小问题。 我提供了一些客户端访问我的服务器,以执行自己的脚本(当然在他们自己的chroot环境等)。 今天发生的问题:有些人在端口25获得本地主机的telnet访问,并发送电子邮件在世界上几乎是一个开放的中继:(

我使用的是后缀,它也需要authentication:

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination 

但是本地脚本显然不需要被authentication。 如果从permit_mynetworks删除本地主机,一些反垃圾邮件例程不再工作…

那么如何configurationpostfix来允许本地主机在本地发送邮件,而不进行身份validation呢?

有什么build议么?

所以你的反垃圾邮件例程使用本地主机,坏人使用本地主机和后缀不能区分

禁止坏人或从受信任的networking( permit_mynetworks )删除本地主机,并configuration您的反垃圾邮件使用其他东西。 或者允许使用smtpd_client_restrictions check_ccert_access进行反垃圾邮件。

回到你的问题。 你在问这样的事情:

 /etc/postfix/main.cf: smtpd_recipient_restrictions = /* replace permit_mynetworks with the next line */ check_client_access hash:/etc/postfix/client_access, /* your other stuff */ permit_sasl_authenticated, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination smtpd_restriction_classes = local_only local_only = check_recipient_access hash:/etc/postfix/local_domains, reject /etc/postfix/client_access: localhost local_only 127.0.0.1 local_only /* check bash#postconf mynetworks for full list of your networks */ /etc/postfix/local_domains: this.domain OK matches this.domain and subdomains that.domain OK matches that.domain and subdomains 

但可以propably它不会工作,因为您的反垃圾邮件与外部收件人重新邮寄。 但这取决于。

给我们更多有关您的反垃圾邮件工具的信息,也许我们将能够提供帮助。

UDP:

你能解释一下邮件stream如何通过这个设置。

不能解释限制类更好,然后官方文档 。

后缀限制类

Postfix SMTP服务器支持访问限制,如SMTP服务器访问(5)表右侧的reject_rbl_client或reject_unknown_client_hostname。 这使您可以为不同的客户或用户实施不同的垃圾邮件限制。

不得不为每个收件人指定访问限制列表变得繁琐。 Postfix限制类允许您为UCE限制(例如“宽容”,“限制”等)组提供易于记忆的名称。

Postfix限制类存在的真正原因更为普遍:不能在Postfix访问表的右侧指定查找表。 这是因为Postfix需要提前打开查询表,但读者可能不关心这些低级细节。

我们使用smtpd_restriction_classes = local_only定义我们的限制类smtpd_restriction_classes = local_only 。 和

 local_only = check_recipient_access hash:/etc/postfix/local_domains, reject 

说:“每当检查这个类检查check_recipient_access (search指定的访问(5)数据库的解决RCPT TO地址,域,父域或localpart @,并执行相应的操作),否则拒绝邮件和local_domains文件说“如果它的这个域名通过了检查,如果它的域名通过了检查”。

但是我们不希望将这个限制类应用于所有电子邮件。 我们希望在发送主机为localhost时删除permit_mynetworks规则。 为此,我们添加了check_client_access哈希:/ etc / postfix / client_access (在指定的访问数据库中search客户端主机名,父域,客户端IP地址或通过删除最不重要的八位字节获得的networking。详细信息。)到smtpd_recipient_restrictions。 它说检查/etc/postfix/client_access文件,如果它的localhost应用local_only限制。 这正是我们想要做的。

希望能帮助到你。

邮件stream量是:

  • 邮件到达
  • 通过smtpd_recipient_restrictions循环
    • check_client_access(如果发送主机是localhost apply local_only限制类)
      • 现在check_recipient_access(如果收件人RCPT TO地址,域,父域或localpart @是“this.domain”或“that.domain”,则接受此邮件)(跳过进一步检查)
      • 否则拒绝
    • 否则继续permit_sasl_authenticated,check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf等

UPD2我刚刚发现另一个选项smtpd_recipient_restrictions(和其他自定义类),您可能会感兴趣

permit_auth_destination

在以下情况之一时,允许请求:

  • Postfix是邮件转发器:已parsing的RCPT TO域匹配$ relay_domains或其子域,并且该地址不包含发件人指定的路由(user @ others @ domain),
  • Postfix是最终的目的地:已parsing的RCPT TO域匹配$ mydestination,$ inet_interfaces,$ proxy_interfaces,$ virtual_alias_domains或$ virtual_mailbox_domains,并且该地址不包含发件人指定的路由(user @ others @ domain)。

一种select是使用iptables来防止这些用户能够在端口25上连接到本地主机。例如:

 iptables -A OUTPUT -p tcp -d 127.0.0.1 --dport 25 -m owner --uid-owner user1 -j REJECT iptables -A OUTPUT -p tcp -d 127.0.0.1 --dport 25 -m owner --uid-owner user2 -j REJECT [etc]