Dkfilter
注意: DomainKeys 已被 DKIM 取代,请使用 OpenDKIM。
Dkfilter 是一个用于 Postfix 的 DomainKeys 过滤器。
它是什么?
它是一种数字邮件签名/验证技术,已被纳入 RFC,并已被许多邮件服务器支持。(例如 yahoo, google 等)。
它是如何工作的?
发送者使用私钥签名邮件。
接收者获取签名邮件,从 DNS 请求公钥并验证它。
因此您可以检查实际是谁发送了这封邮件。
有关更多信息,请参阅 RFC 4870。
安装
默认情况下,您应该添加 dkfilter 用户和组。如果您不想这样做,请编辑 /etc/conf.d/dkfilter 并更改 DKFILTER_USER 和 DKFILTER_GROUP。
通用配置
- 生成密钥
$ openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private.key $ openssl rsa -in private.key -pubout -out public.key
- 调整
/etc/conf.d/dkfilter
。 - 使用您的选择器(请参阅
/etc/conf.d/dkfilter
中的DKFILTER_SELECTOR
,您可以选择随机名称)和密钥添加 DNS 记录
server1._domainkey IN TXT "k=rsa; p=MHwwDQYJK ... OprwIDAQAB; t=y"
- 启动/启用
dkfilter-in.service
和dkfilter-out.service
。
Postfix 集成
入站过滤器
入站过滤器从端口 10025 获取连接,并将过滤后的数据输出到端口 10026。(入站过滤器不会删除任何数据,它只是将验证结果添加到邮件中)
将以下内容添加到 /etc/postfix/master.cf 中
# # Before-filter SMTP server. Receive mail from the network and # pass it to the content filter on localhost port 10025. # smtp inet n - n - - smtpd -o smtpd_proxy_filter=127.0.0.1:10025 -o smtpd_client_connection_count_limit=10 # # After-filter SMTP server. Receive mail from the content filter on # localhost port 10026. # 127.0.0.1:10026 inet n - n - - smtpd -o smtpd_authorized_xforward_hosts=127.0.0.0/8 -o smtpd_client_restrictions= -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o smtpd_data_restrictions= -o mynetworks=127.0.0.0/8 -o receive_override_options=no_unknown_recipient_checks
出站过滤器
出站过滤器从端口 10027 获取连接,并将签名后的数据输出到端口 10028。
将以下内容添加到 /etc/postfix/master.cf 中
# # modify the default submission service to specify a content filter # and restrict it to local clients and SASL authenticated clients only # submission inet n - n - - smtpd -o smtpd_etrn_restrictions=reject -o smtpd_sasl_auth_enable=yes -o content_filter=dksign:[127.0.0.1]:10027 -o receive_override_options=no_address_mappings -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject # # specify the location of the DomainKeys signing filter # dksign unix - - n - 10 smtp -o smtp_send_xforward_command=yes -o smtp_discard_ehlo_keywords=8bitmime # # service for accepting messages FROM the DomainKeys signing filter # 127.0.0.1:10028 inet n - n - 10 smtpd -o content_filter= -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks -o smtpd_helo_restrictions= -o smtpd_client_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks=127.0.0.0/8 -o smtpd_authorized_xforward_hosts=127.0.0.0/8