bind:sender_policy_framework_spf
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
bind:sender_policy_framework_spf [2016/11/29 16:32] – peter | bind:sender_policy_framework_spf [2019/11/26 21:09] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Bind - Sender Policy Framework (SPF) ====== | ||
- | Sender Policy Framework (SPF), is an email-validation system which is designed to allow spoofed mails to be identified. | ||
- | |||
- | SPF allows you to specify, via a DNS-record, which hosts are allowed to send email on behalf of a particular domain. | ||
- | |||
- | Because SPF involves the use of DNS there is not anything to actually configure on your mail-server, | ||
- | |||
- | |||
- | ===== DNS config ===== | ||
- | |||
- | SPF-policies are published as TXT records, in DNS. | ||
- | |||
- | The basic record looks like this: | ||
- | |||
- | < | ||
- | ; spf record for example.com | ||
- | $ORIGIN example.com. | ||
- | .... | ||
- | example.com. | ||
- | ; use the SPF details for example.net | ||
- | ; in the above case to replace example.com' | ||
- | ; or | ||
- | example.com. | ||
- | ; additive - use MX RR for example.com | ||
- | ; AND if that fails use example.nets' | ||
- | </ | ||
- | |||
- | |||
- | ===== SPF tags ===== | ||
- | |||
- | The SPF record is a simple text string, in a TXT, record which contains a **v=spf1** prefix, and a number of additional components. For example: | ||
- | |||
- | ^Component^Meaning^ | ||
- | |A|If the domain name has an address record (A or AAAA) that can be resolved to the sender' | ||
- | |MX|If the domain name has an MX record resolving to the sender' | ||
- | |IP4|If the sender is in the given IPv4 address range, match.| | ||
- | |IP6|If the sender is in the given IPv6 address range, match.| | ||
- | |PTR|Use DNS PTR RRs for verification.| | ||
- | |EXISTS|Test for existence of domain.| | ||
- | |||
- | |||
- | ===== Types of rejection levels ===== | ||
- | |||
- | The domain-administrator may also decide whether violations should be regarded as hard-failure " | ||
- | |||
- | ^Rejection Type^Detail^ | ||
- | |-all|Reject or fail them - don't deliver the email if anything does not match.| | ||
- | |~all|Soft-fail them - accept them, but mark it as ' | ||
- | |+all|Pass regardless of match - accept anything from the domain.| | ||
- | |? | ||
- | |||
- | Most records will have a **" | ||
- | |||
- | Very large domains such as gmail.com have **"? | ||
- | |||
- | |||
- | ===== The " | ||
- | |||
- | |||
- | <block 80: | ||
- | all | ||
- | </ | ||
- | |||
- | |||
- | This mechanism always matches. | ||
- | |||
- | < | ||
- | # Allow domain' | ||
- | " | ||
- | |||
- | # The domain sends no mail at all. | ||
- | " | ||
- | |||
- | # The domain owner thinks that SPF is useless and/or doesn' | ||
- | " | ||
- | </ | ||
- | |||
- | |||
- | ===== The " | ||
- | |||
- | <block 80: | ||
- | ip4:< | ||
- | ip4:< | ||
- | </ | ||
- | |||
- | |||
- | The argument to the " | ||
- | |||
- | < | ||
- | # Allows any IP address between 192.168.0.1 and 192.168.255.255. | ||
- | " | ||
- | </ | ||
- | |||
- | |||
- | ===== The " | ||
- | |||
- | The argument to the " | ||
- | |||
- | < | ||
- | # Allow any IPv6 address between 1080:: | ||
- | " | ||
- | |||
- | |||
- | # Allow any IPv6 address between 1080:: | ||
- | " | ||
- | </ | ||
- | |||
- | |||
- | ===== The " | ||
- | |||
- | All the A records for domain are tested. | ||
- | |||
- | If domain is not specified, the current-domain is used. | ||
- | |||
- | The A records have to match the client IP exactly, unless a prefix-length is provided, in which case each IP address returned by the A lookup will be expanded to its corresponding [[http:// | ||
- | |||
- | < | ||
- | # The current-domain is used. | ||
- | " | ||
- | |||
- | # Equivalent if the current-domain is example.com. | ||
- | " | ||
- | |||
- | # Perhaps example.com has chosen to explicitly list all the outbound mailers in a special A record under mailers.example.com. | ||
- | " | ||
- | |||
- | # If example.com resolves to 192.0.2.1, the entire class C of 192.0.2.0/ | ||
- | " | ||
- | </ | ||
- | |||
- | |||
- | ===== The " | ||
- | |||
- | All the A records for all the MX records for domain are tested in order of MX priority. | ||
- | |||
- | If domain is not specified, the current-domain is used. | ||
- | |||
- | The A records have to match the client IP exactly, unless a prefix-length is provided, in which case each IP address returned by the A lookup will be expanded to its corresponding [[http:// | ||
- | |||
- | < | ||
- | # Perhaps a domain sends mail through its MX servers plus another set of servers whose job is to retry mail for deferring domains. | ||
- | " | ||
- | |||
- | # Perhaps a domain' | ||
- | " | ||
- | </ | ||
- | |||
- | |||
- | ===== The " | ||
- | |||
- | The hostname or hostnames for the client IP are looked up using PTR queries. The hostnames are then validated: at least one of the A records for a PTR hostname must match the original client IP. Invalid hostnames are discarded. If a valid hostname ends in domain, this mechanism matches. | ||
- | |||
- | If domain is not specified, the current-domain is used. | ||
- | |||
- | If at all possible, you should avoid using this mechanism in your SPF record, because it will result in a larger number of expensive DNS lookups. | ||
- | |||
- | < | ||
- | # A domain which directly controls all its machines (unlike a dialup or broadband ISP) allows all its servers to send mail. For example, hotmail.com or paypal.com might do this. | ||
- | " | ||
- | |||
- | # Any server whose hostname ends in otherdomain.com is designated. | ||
- | " | ||
- | </ | ||
- | |||
- | |||
- | ===== The " | ||
- | |||
- | Perform an A query on the provided domain. | ||
- | |||
- | When you use [[http:// | ||
- | |||
- | < | ||
- | # In the following example, the client IP is 1.2.3.4 and the current-domain is example.com. | ||
- | # | ||
- | # If example.com does not resolve, the result is fail. If it does resolve, this mechanism results in a match. | ||
- | " | ||
- | </ | ||
- | |||
- | |||
- | ===== The " | ||
- | |||
- | The specified domain is searched for a match. If the lookup does not return a match or an error, processing proceeds to the next directive. | ||
- | |||
- | <WRAP warning> | ||
- | **WARNING**: | ||
- | </ | ||
- | |||
- | < | ||
- | # In the following example, the client IP is 1.2.3.4 and the current-domain is example.com. | ||
- | |||
- | # If example.com has no SPF record, the result is PermError. | ||
- | # Suppose example.com' | ||
- | # Look up the A record for example.com. | ||
- | # If there is no match, other than the included domain' | ||
- | " | ||
- | </ | ||
- | |||
- | **Trust relationships** — The " | ||
- | |||
- | < | ||
- | " | ||
- | </ | ||
- | |||
- | In hindsight, the name " | ||
- | |||
- | |||
- | ===== Modifiers ===== | ||
- | |||
- | Modifiers are optional. A modifier may appear only once per record. Unknown modifiers are ignored. | ||
- | |||
- | ==== The " | ||
- | |||
- | The SPF record for domain replace the current record. The macro-expanded domain is also substituted for the current-domain in those look-ups. | ||
- | |||
- | < | ||
- | # In the following example, the client IP is 1.2.3.4 and the current-domain is example.com. | ||
- | # | ||
- | # If example.com has no SPF record, that is an error; the result is unknown. | ||
- | # Suppose example.com' | ||
- | # Look up the A record for example.com. If it matches 1.2.3.4, return Pass. | ||
- | # If there is no match, the exec fails to match, and the -all value is used. | ||
- | " | ||
- | </ | ||
- | |||
- | |||
- | ==== The " | ||
- | |||
- | <block 80: | ||
- | |||
- | If an SMTP receiver rejects a message, it can include an explanation. An SPF publisher can specify the explanation string that senders see. This way, an ISP can direct nonconforming users to a web page that provides further instructions about how to configure SASL. | ||
- | |||
- | The domain is expanded; a TXT lookup is performed. | ||
- | |||
- | |||
- | ===== Example Records ===== | ||
- | |||
- | If we pretend that mail from the host example.com can only come from the IPv4 address 1.2.3.4 we would create this record: | ||
- | |||
- | < | ||
- | " | ||
- | </ | ||
- | |||
- | This record lists a single IP-address, but CIDR-formatted ranges are also supported. | ||
- | |||
- | A more complex record, for the domain steve.org.uk, | ||
- | |||
- | < | ||
- | " | ||
- | </ | ||
- | |||
- | That record shows that mail may come from a small IPv4 range, a pair of IPv6 ranges, and mail should also be accepted if it comes from the MX-host of the domain, along with the host having the IP address which matches the hostname (i.e. sharewiz.net). | ||
- | |||
- | Finally this record shows that mail can only be sent from hosts listed as the MX-machine(s) for the domain, but it is configured with a soft-fail, because the domain-owner isn't 100% sure that that is sufficient: | ||
- | |||
- | < | ||
- | " | ||
- | </ | ||
- | |||
- | |||
- | ===== Checking SPF ===== | ||
- | |||
- | To publish a policy you must merely define a TXT-record, in DNS, for the domain you're sending from. To test that the policy is visible you can query that record, like so: | ||
- | |||
- | <code bash> | ||
- | dig -t txt +short sharewiz.net | ||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | From a Windows machine use: | ||
- | |||
- | <code bash> | ||
- | nslookup -type=txt sharewiz.net | ||
- | </ | ||
- | |||
- | Returns | ||
- | |||
- | < | ||
- | Non-authoritative answer: | ||
- | sharewiz.net | ||
- | |||
- | " | ||
- | </ | ||
- | </ | ||
- | |||
- | Result | ||
- | |||
- | < | ||
- | " | ||
- | </ | ||
- | |||
- | |||
- | An SPF record may also include a " | ||
- | |||
- | < | ||
- | v=spf1 redirect=_spf.google.com | ||
- | </ | ||
- | |||
- | This tells the receiving server to check the SPF record of google.com instead of gmail.com. | ||
- | |||
- | < | ||
- | v=spf1 ip4: | ||
- | </ | ||
- | |||
- | |||
- | ===== Drawbacks of SPF ===== | ||
- | |||
- | The single biggest problem with SPF is that testing records at SMTP-time can fail if your mail is handled via a forward. | ||
- | |||
- | There are several online sites which allow mail to be received at a vanity-domain, | ||
- | |||
- | |||
- | ===== References ===== | ||
- | |||
- | |||
- | https:// | ||
- | |||
- | http:// |
bind/sender_policy_framework_spf.1480437121.txt.gz · Last modified: 2020/07/15 09:30 (external edit)