![如何让 Postfix 要求对内部邮件进行身份验证?](https://linux22.com/image/728450/%E5%A6%82%E4%BD%95%E8%AE%A9%20Postfix%20%E8%A6%81%E6%B1%82%E5%AF%B9%E5%86%85%E9%83%A8%E9%82%AE%E4%BB%B6%E8%BF%9B%E8%A1%8C%E8%BA%AB%E4%BB%BD%E9%AA%8C%E8%AF%81%EF%BC%9F.png)
我收到了使用虚假本地地址的网络钓鱼者的邮件,我了解源自 mynetworks 的邮件不需要身份验证(对于 cron 作业等),但即使其他国家/地区的人在我的域内发送邮件,也不应该需要身份验证吗?
例如:目前我被允许从[电子邮件保护]到[电子邮件保护]无需身份验证,即使我是从其他国家/地区(而非我的网络)进行连接。
在 main.cf 中,mynetworks 仅设置了 localhost
我能做些什么吗?
进一步解释 占领网站短信例如。它不在我的服务器上托管(可能也不在我的国家/地区),所以我以为如果我放置服务器的主机和端口,没有输入正确的凭据并请求从我托管的电子邮件发送邮件,它应该会失败。但事实并非如此。它通过得很好。
索取信息
根据要求,这是我的 main.cf
smtpd_banner = $myhostname ESMTP $mail_name powered by Easy Hosting Control Panel (ehcp) on Ubuntu, www.ehcp.net
biff = no
append_dot_mydomain = no
readme_directory = /usr/share/doc/postfix
# TLS parameters
tls_random_source=dev:/dev/urandom
tls_preempt_cipherlist = yes
# TLS Incoming
smtpd_tls_cert_file=/path/to/my/certificate.crt
smtpd_tls_key_file=/path/to/my/certificate.key
smtpd_tls_CAfile=/path/to/my/certificate.ca-bundle
smtpd_use_tls=yes
smtpd_tls_auth_only=yes
smtpd_tls_security_level=may
smtpd_tls_ciphers = high
smtpd_tls_mandatory_ciphers=high
smtpd_tls_exclude_ciphers = MD5, DES, ADH, RC4, PSD, SRP, 3DES, CAMELLIA, eNULL, aNULL
smtpd_tls_mandatory_exclude_ciphers = MD5, DES, ADH, RC4, PSD, SRP, 3DES, CAMELLIA, eNULL, aNULL
smtpd_tls_loglevel=1
smtpd_tls_received_header=yes
smtpd_tls_session_cache_timeout=3600s
smtpd_tls_mandatory_protocols = TLSv1.2, TLSv1.1, TLSv1, !SSLv2, !SSLv3
smtpd_tls_protocols = TLSv1.2, TLSv1.1, TLSv1, !SSLv2, !SSLv3
smtpd_starttls_timeout = 300s
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
# TLS Outgoing
smtp_tls_cert_file=/path/to/my/certificate.crt
smtp_tls_key_file=/path/to/my/certificate.key
smtp_tls_CAfile=/path/to/my/certificate.ca-bundle
smtp_use_tls=yes
smtp_tls_security_level=may
smtp_tls_ciphers = high
smtp_tls_mandatory_ciphers=high
smtp_tls_exclude_ciphers = MD5, DES, ADH, RC4, PSD, SRP, 3DES, CAMELLIA, eNULL, aNULL
smtp_tls_mandatory_exclude_ciphers = MD5, DES, ADH, RC4, PSD, CAMELLIA, SRP, 3DES, eNULL
smtp_tls_loglevel=1
smtp_tls_received_header=yes
smtp_tls_session_cache_timeout=3600s
smtp_tls_mandatory_protocols = TLSv1.2, TLSv1.1, TLSv1, !SSLv2, !SSLv3
smtp_tls_protocols = TLSv1.2, TLSv1.1, TLSv1, !SSLv2, !SSLv3
smtp_starttls_timeout = 300s
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# General Configuration
myhostname = mydomain.tld
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost
relayhost =
mynetworks = 127.0.0.0/8
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
debug_peer_list =
debug_peer_level = 1
disable_vrfy_command = yes
inet_protocols = ipv4
inet_interfaces = all
smtpd_destination_concurrency_limit = 2
smtpd_destination_rate_delay = 1s
smtpd_extra_recipient_limit = 10
smtpd_error_sleep_time = 1s
smtpd_soft_error_limit = 10
smtpd_hard_error_limit = 20
# Virtual domains, mailboxes, etc
virtual_alias_domains =
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, proxy:mysql:/etc/postfix/mysql-virtual_email2email.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_mailbox_base = /home/vmail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = "The user you are trying to reach is over quota."
virtual_overquota_bounce = yes
virtual_mailbox_limit = 0
virtual_message_limit = 0
mailbox_size_limit = 0
message_size_limit = 0
default_process_limit = 3
sender_canonical_maps =
transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $mynetworks $virtual_mailbox_limit_maps $transport_maps
# SASL Authentication
#smtpd_sasl_type = courier
smtpd_sasl_path = smtpd
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_tls_auth_only = yes
# Restrictions
#smtpd_delay_reject = yes
#smtpd_helo_required = yes
#smtpd_helo_restrictions = permit_mynetworks, reject_invalid_helo_hostname, permit
#smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
#smtpd_sender_restrictions = permit_mynetworks, reject_unknown_sender_domain, reject_unlisted_sender, permit
#smtpd_recipient_restrictions = reject_unauth_pipelining, reject_non_fqdn_recipient, reject_unknown_recipient_domain, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_rbl_client zen.spamhaus.org, reject_rbl_client b1.spamcop.net, check_policy_service unix:postgrey/socket, permit
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_client_access cidr:/etc/postfix/client_checks
# milters & filters (Amavis & DKIM)
content_filter = smtp-amavis:127.0.0.1:10024
milter_protocol = 2
milter_default_action = accept
smtpd_milters = inet:localhost:8891
non_smtpd_milters = $smtpd_milters
答案1
那里发生的事情是意料之中的,而且大部分都是设计好的。细微差别在于这些信息并没有被发送,而是被接收通过您的邮件服务器。
接收任何本地域名的邮件都无需身份验证,因为其他发送邮件服务器如何进行身份验证?您无法向 Hotmail、Gmail、example.com 和其他可能向您发送电子邮件的人提供用户名和密码,以便他们在向您的域发送邮件时进行身份验证……
为了对发件人声称自己是您所在域内的邮箱的特殊情况进行例外处理,您需要实施 SPF。SPF 用于创建和实施策略以限制哪些服务器可以为你的域发送电子邮件。(无论这个问题如何,你都应该这么做。)
这将允许您的邮件服务器拒绝声称来自您自己的电子邮件域但从事先未列入白名单的 IP 地址发送的传入消息。如果发件人成功通过身份验证,他们将绕过 SPF 检查,并且该消息将被接受并进行传递。