我使用Postfix作为MTA来接收我的域名的邮件。 最近我已经开始从外部IP尝试利用bash获得一些根邮件到@ localhost。 我的bash被修补,所以我应该是足够安全的,但我不知道任何人都可以从世界任何地方发送邮件到域根@本地主机的想法。
我仍然需要本地系统邮件localhost,所以不希望完全删除它,理想情况下,我想要从任何地方阻止邮件本地主机和localhost.hostname,除非邮件源于本地系统。
这可能吗? 看看文档,看起来像是可以用smtpd_relay_restrictions或smtpd_recipient_restrictions来完成,但我还没有find一个工作的configuration。
用postfix 2.11.0-1运行Ubuntu服务器14.04
下面的postfix -n输出。 我希望没关系,但我已经删除了在输出中使用的FQDN的详细信息。
alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases append_dot_mydomain = no biff = no config_directory = /etc/postfix home_mailbox = Maildir/ inet_interfaces = all mailbox_command = /usr/bin/procmail mailbox_size_limit = 0 mydestination = <hostname>, <domain>, localhost.<hostname>, mail.<domain>, localhost myhostname = <hostname> mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 myorigin = /etc/mailname queue_directory = /var/spool/postfix readme_directory = no recipient_delimiter = + relayhost = smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtpd_banner = $myhostname ESMTP smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination smtpd_sasl_auth_enable = yes smtpd_sasl_path = private/auth smtpd_sasl_type = dovecot smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtpd_use_tls = yes unknown_local_recipient_reject_code = 550 virtual_alias_domains = <virtual_domain_1> <virtual_domain_1> <virtual_domain_2> <virtual_domain_3> <virtual_domain_4> virtual_alias_maps = hash:/etc/postfix/virtual
因为您已经在permit_mynetworks中拥有了smtpd_relay_restrictions ,那么您可以在它之后添加新的限制。
smtpd_relay_restrictions = permit_mynetworks, check_recipient_access hash:/etc/postfix/block_localhost, permit_sasl_authenticated, defer_unauth_destination
在/etc/postfix/block_localhost ,你可以放
root@localhost REJECT
postmap该文件并运行postfix reload 。
从本地系统到root @ localhost的邮件已被permit_mynetworks允许。 所以,简单的解决办法是在它之后添加root @ localhost的拒绝。