个人工具

“UbuntuHelp:Postfix/SPF”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第43行: 第43行:
 
<pre><nowiki>
 
<pre><nowiki>
 
policy-spf  unix  -      n      n      -      -      spawn
 
policy-spf  unix  -      n      n      -      -      spawn
    user=nobody argv=/usr/bin/python /usr/bin/policy-spf
+
user=nobody argv=/usr/bin/python /usr/bin/policy-spf
 
</nowiki></pre>
 
</nowiki></pre>
  
第50行: 第50行:
 
<pre><nowiki>
 
<pre><nowiki>
 
smtpd_recipient_restrictions =
 
smtpd_recipient_restrictions =
    ...
+
...
    permit_sasl_authenticated
+
permit_sasl_authenticated
    permit_mynetworks
+
permit_mynetworks
    reject_unauth_destination
+
reject_unauth_destination
    check_policy_service unix:private/policyd-spf
+
check_policy_service unix:private/policyd-spf
    ...
+
...
 
</nowiki></pre>
 
</nowiki></pre>
 
Note: Put the policy server after reject_unauth_destination to prevent risk that unexpected responses from the policy server could make your system and open relay (this is recommended for all policy servers). Put the policy server after you permit local senders. You only want SPF to check inbound mail from the internet and not outbound mail from your users.
 
Note: Put the policy server after reject_unauth_destination to prevent risk that unexpected responses from the policy server could make your system and open relay (this is recommended for all policy servers). Put the policy server after you permit local senders. You only want SPF to check inbound mail from the internet and not outbound mail from your users.

2007年5月24日 (四) 15:19的版本


Introduction

This guide explains how to install and integrate Sender Policy Framework (SPF) checking with Postfix. It applies to Ubuntu 7.04 and later releases. Previous Ubuntu releases do not have the packages necessary.

SPF is an e-mail anti-forgery technology the enables domain owners to list, in the Domain Name Service (DNS), authorized sources of mail from their domains. It enables mail receivers to reject mail that does not come from authorized sources. This guide describes the second part of the protocol, rejecting mail from unauthorized sources. It assumes you have your Postfix set up and running. Setting up and running Postfix is described elsewhere in the wiki and in the Postfix documentation.

SPF Package selection and installation

In Ubuntu 7.04 there are two RFC 4408 compliant package sets you can use. One is written in Python. The other is written in Perl. They have essentially equivalent functionality. If you are uncertain, you should review the documentation (man pages) for both. It's largely a question of which programming language you are more comfortable with.

For the Python programs, installation is:

apt-get install python-policyd-spf python-spf

For the Perl system, installation is:

apt-get install postfix-policyd-spf-perl libmail-spf-perl

Postfix Integration

There are a number of changes the need to be made to integrate SPF checking with Postfix. In this guide, integration of the Python programs is described. The Perl programs are integrated very similarly. See man postfix-policyd-spf-perl for details.

Enabling the Policy Service

In /etc/postfix/main.cf you will need to add the following line (it doesn't matter where, usually they get added to the end.

policy_time_limit = 3600s

This changed the ups the policy time limit so the policy server won't time out while a message is still being processed.

Add this section to /etc/postfix/master.cf

policy-spf  unix  -       n       n       -       -       spawn
user=nobody argv=/usr/bin/python /usr/bin/policy-spf

Finally, you need to add the policy service to your smtpd_recipient_restrictions:

smtpd_recipient_restrictions =
...
permit_sasl_authenticated
permit_mynetworks
reject_unauth_destination
check_policy_service unix:private/policyd-spf
...

Note: Put the policy server after reject_unauth_destination to prevent risk that unexpected responses from the policy server could make your system and open relay (this is recommended for all policy servers). Put the policy server after you permit local senders. You only want SPF to check inbound mail from the internet and not outbound mail from your users.

Restart Postfix

sudo /etc/init.d/postfix restart

Verifying It's Working

Check your mail logs. The Python server logs mail that is rejected or deferred due to SPF. If there is a problem with the policy server or its integration with Postix, it will be logged.

tail -f /var/log/mail.log

or

less /var/log/mail.log