{"id":25,"date":"2015-12-10T06:47:41","date_gmt":"2015-12-10T14:47:41","guid":{"rendered":"http:\/\/www.founditdata.com\/blog\/?p=25"},"modified":"2015-12-10T13:58:28","modified_gmt":"2015-12-10T21:58:28","slug":"a-sender-policy-framework-spf-primer-for-exchange-administrators","status":"publish","type":"post","link":"https:\/\/www.fidcyber.com\/blog\/network\/a-sender-policy-framework-spf-primer-for-exchange-administrators\/","title":{"rendered":"A Sender Policy Framework (SPF) Primer for Exchange Administrators"},"content":{"rendered":"<p>Email spam continues to be a huge problem for organizations these days, and it usually falls on the Exchange administrator to do something about it. Aside from the usual anti-spam measures we can put in place to protect our own servers from spam, we also need to consider how to prevent spammers from spoofing (imitating) the domain names for our own organization. After all, it can be very embarrassing or cause serious brand damage to have spam and malware that uses your domain name.<\/p>\n<p>To detect spoofed email many receiving servers, particularly those operated by large email providers such as Microsoft, Yahoo, Google, and AOL, will\u00a0perform a check of the Sender Policy Framework (SPF) record for the sender\u2019s domain when a sending server is attempting to send an email message.<\/p>\n<p>SPF records allow a domain owner to specify which mail servers are permitted to send email for that domain name. When the sending server issues its \u201cMAIL FROM\u201d command in the SMTP conversation, the receiving server will look up the SPF record in the domain name of the \u201cFrom\u201d address to see if there is a match for the source IP address of the SMTP connection.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12176\" src=\"http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF_1.png\" sizes=\"(max-width: 710px) 100vw, 710px\" srcset=\"http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF_1-450x231.png 450w, http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF_1-600x308.png 600w, http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF_1.png 710w\" alt=\"4-X-SPF_1\" width=\"710\" height=\"365\" \/><\/p>\n<p>If you were reading about SPF records on the internet you may find advice from some websites that it is better to have no SPF record than it is to have an incorrect SPF record. There\u2019s some truth to that, but also some risks. Some mail hosts will reject mail if there is no SPF record for the domain. It tends to be few hosts that do that, but because they are very large mail hosts the impact can be quite noticeable. Ultimately, it is best to have a correctly configured SPF record in DNS for your domain.<\/p>\n<p>An SPF record is simply a TXT record with a certain syntax. The syntax is made up of two parts; mechanisms, and modifiers. Modifiers are optional and are not commonly used except for special circumstances. During management and troubleshooting of transport you\u2019ll most often be dealing with SPF records containing only mechanisms.<\/p>\n<p>The mechanisms for an SPF record define the sets of hosts that can send email from the domain. Mechanisms can be defined by:<\/p>\n<ul>\n<li><strong>all<\/strong> \u2013 matches any host, and is placed at the end of the SPF record as a \u201ccatch all\u201d for any senders that did not match other mechanisms listed ahead of it.<\/li>\n<li><strong>ip4<\/strong> \u2013 matches a single IPv4 address or IPv4 network range.<\/li>\n<li><strong>ip6<\/strong> \u2013 matches a single IPv6 address of IPv6 network range.<\/li>\n<li><strong>a<\/strong> \u2013 matches a host name or domain name. The IP addresses that the name resolves to in DNS are matched against the sender\u2019s IP address. This mechanism is useful for matching against a web server IP address based on the domain name.<\/li>\n<li><strong>mx <\/strong>\u2013 matches against the MX records for the domain. This mechanism is useful when the outbound mail is handled by the same servers as the MX records resolve to for inbound mail.<\/li>\n<li><strong>ptr <\/strong>\u2013 reverse DNS queries are used to match the sender IP address to the host names that it resolves to. This mechanism is generally not recommended due to the DNS load it causes.<\/li>\n<li><strong>exists <\/strong>\u2013 simply checks that the domain exists in DNS.<\/li>\n<li><strong>include <\/strong>\u2013 matches the sender IP against the SPF record another domain. This is commonly used when your outbound email is routing via a cloud service such as Exchange Online Protection.<\/li>\n<\/ul>\n<p>Mechanisms are used in combination with a qualifier that tells the server what to do when a match is found. The qualifiers are:<\/p>\n<ul>\n<li>\u201c<strong>+<\/strong>\u201d for pass (this is the default if no qualifier is explicitly provided)<\/li>\n<li>\u201c<strong>\u2013<\/strong>\u201d for fail (email from unauthorized hosts should be rejected)<\/li>\n<li>\u201c<strong>~<\/strong>\u201d for SoftFail (may result in email being accepted but marked as \u201clikely spam\u201d)<\/li>\n<li>\u201c<strong>?<\/strong>\u201d for Neutral (regardless of the result the email should be accepted)<\/li>\n<\/ul>\n<p>An example of a mechanism paired with a qualifier is \u201c-all\u201d at the end of an SPF record, which means \u201c<em>Fail\/reject email from any sender who did not match an earlier mechanism in the SPF record<\/em>.\u201d<\/p>\n<p>If this all seems very complicated to you, don\u2019t worry, it starts out that way for everyone who has to deal with SPF records. Fortunately, there are many tools available to help you construct and validate your SPF records. For example, Microsoft provides the <a href=\"https:\/\/www.microsoft.com\/mscorp\/safety\/content\/technologies\/senderid\/wizard\/\">Sender ID Framework SPF Record Wizard<\/a>, which has an awkwardly long name but is nonetheless very useful.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12177\" src=\"http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF-2.png\" sizes=\"(max-width: 517px) 100vw, 517px\" srcset=\"http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF-2-450x92.png 450w, http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF-2.png 517w\" alt=\"4-X-SPF-2\" width=\"517\" height=\"106\" \/><\/p>\n<p>After entering your domain name the wizard will step you through a series of questions to determine the most likely SPF record that you will need. In this example I answered the questions as follows:<\/p>\n<ul>\n<li>Domain\u2019s inbound servers may send mail (in other words, the servers listed as MX records also handle outbound email)<\/li>\n<li>An additional domain name whose A record is a valid outbound email server (a common example of this is an externally hosted website that uses its own SMTP service to send notifications and other emails)<\/li>\n<li>This domain sends mail only from the IP addresses identified above (in other words, anything else trying to send email from my domain name should be considered unauthorized)<\/li>\n<\/ul>\n<p>The resulting SPF record looks like this.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12178\" src=\"http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF-3.png\" alt=\"4-X-SPF-3\" width=\"414\" height=\"206\" \/><\/p>\n<p>By adding that string as a TXT record in the public DNS zone for the domain name I will have prevented unauthorized email servers from spoofing my domain name. At least, they won\u2019t be able to do it when sending to any receiving server that checks SPF records. Anyone who is not checking SPF records can still receive the spoofed email, but may reject it for other reasons such as spam content or malware.<\/p>\n<p>Apart from tools to generate your own SPF record, many email services will provide you with the exact strings to add to your SPF record. When you add a domain name to <a href=\"http:\/\/exchangeserverpro.com\/office-365\/\">Office 365<\/a> Microsoft advises you of the SPF record they suggest, which is appropriate for organizations sending their outbound email using Exchange Online Protection. Similarly, email marketing services and SMTP hosting services will also have documented solutions to adjust your SPF record so that you can successfully use their services without your email being rejected.<\/p>\n<p>After you have your SPF record in place you should validate it. And in fact, you should repeat this validation test any time you suspect an external organization may be rejecting your email because of your SPF record. <a href=\"http:\/\/mxtoolbox.com\/spf.aspx\">MXToolbox has an SPF record validator<\/a> that takes a domain name and IP address as input and lets you know what the result will be if that IP address sends email for your domain.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12179\" src=\"http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF-4.png\" sizes=\"(max-width: 527px) 100vw, 527px\" srcset=\"http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF-4-450x227.png 450w, http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF-4.png 527w\" alt=\"4-X-SPF-4\" width=\"527\" height=\"266\" \/><\/p>\n<p>Aside from the result for that specific IP address, the MXToolbox SPF record lookup tool will also validate the general health of your SPF record for problems such as excessive DNS lookups or syntax problems.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12180\" src=\"http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF-5.png\" sizes=\"(max-width: 740px) 100vw, 740px\" srcset=\"http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF-5-450x128.png 450w, http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF-5-600x170.png 600w, http:\/\/exchangeserverpro.com\/wp-content\/uploads\/2015\/12\/4-X-SPF-5.png 740w\" alt=\"4-X-SPF-5\" width=\"740\" height=\"210\" \/><\/p>\n<p>Despite the importance of SPF records for internet email delivery, your internal mail flow between Exchange servers in your own organization is not dependent on SPF records. The Exchange servers in your organization already understand that other Exchange servers in the same organization are authoritative for your domains.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Email spam continues to be a huge problem for organizations these days, and it usually falls on the Exchange administrator to do something about it. Aside from the usual anti-spam measures we can put in place to protect our own &hellip; <a href=\"https:\/\/www.fidcyber.com\/blog\/network\/a-sender-policy-framework-spf-primer-for-exchange-administrators\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-25","post","type-post","status-publish","format-standard","hentry","category-network"],"_links":{"self":[{"href":"https:\/\/www.fidcyber.com\/blog\/wp-json\/wp\/v2\/posts\/25"}],"collection":[{"href":"https:\/\/www.fidcyber.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fidcyber.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fidcyber.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fidcyber.com\/blog\/wp-json\/wp\/v2\/comments?post=25"}],"version-history":[{"count":1,"href":"https:\/\/www.fidcyber.com\/blog\/wp-json\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":26,"href":"https:\/\/www.fidcyber.com\/blog\/wp-json\/wp\/v2\/posts\/25\/revisions\/26"}],"wp:attachment":[{"href":"https:\/\/www.fidcyber.com\/blog\/wp-json\/wp\/v2\/media?parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fidcyber.com\/blog\/wp-json\/wp\/v2\/categories?post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fidcyber.com\/blog\/wp-json\/wp\/v2\/tags?post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}