{"id":187,"date":"2018-04-13T15:30:19","date_gmt":"2018-04-13T13:30:19","guid":{"rendered":"http:\/\/zupertails.be\/wur\/?p=187"},"modified":"2018-04-13T15:30:19","modified_gmt":"2018-04-13T13:30:19","slug":"spf-records-and-how-they-work","status":"publish","type":"post","link":"https:\/\/zupertails.be\/wur\/?p=187","title":{"rendered":"SPF records and how they work"},"content":{"rendered":"<h2>The mysteries of the internet : SPF edition<\/h2>\n<p>First of all, SPF stands for &#8220;Sender Policy framework&#8221;.<br \/>\nNow you know.<br \/>\nPeriod.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Just kidding.<\/p>\n<p>An SPF record is used as a &#8220;sort of &#8221; security\/anti-spam measure in order to protect your outgoing mail from being sent FROM a certain list of sender locations.<br \/>\nYou read it right : &#8220;<span style=\"text-decoration: underline;\">from<\/span>&#8221; (not &#8220;<span style=\"text-decoration: underline;\">to<\/span>&#8220;).<br \/>\nIt&#8217;s in no way a fail-safe antispam solution, but it will decrease the amount of mails sent in your name significantly.<br \/>\nOffice 365 even requires this specific record on first setup (although you can skip this step eventually).<\/p>\n<p>Who didn&#8217;t configure his Outlook Express in the old days to send mail from as his boss to fake a &#8220;you&#8217;re fired&#8221; mail to your new colleague ? Right ? Right ? N-Nobody ?<br \/>\nOops. Sorry, Bjorn.<\/p>\n<p>&nbsp;<\/p>\n<h2><a href=\"http:\/\/wwW.howstuffworks.com\">Comment \u00e7a marche<\/a> ?<\/h2>\n<p>In order to understand how things work, wel&#8217;ll start out with a little example from our fake (?) company Shortstraw LLC and their Office 365.<br \/>\nAfter setting up your O365\u00a0 subscription, your SPF records looks a bit like this :<\/p>\n<figure id=\"attachment_192\" aria-describedby=\"caption-attachment-192\" style=\"width: 963px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" class=\"wp-image-192 size-full\" src=\"http:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/spf_shortstraw.png\" alt=\"\" width=\"963\" height=\"560\" srcset=\"https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/spf_shortstraw.png 963w, https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/spf_shortstraw-300x174.png 300w, https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/spf_shortstraw-768x447.png 768w\" sizes=\"(max-width: 963px) 100vw, 963px\" \/><figcaption id=\"caption-attachment-192\" class=\"wp-caption-text\">Note the &#8220;subtle&#8221; reference to mxtoolbox.com<\/figcaption><\/figure>\n<p>I deliberately used the expression &#8220;text record&#8221; as SPF is nothing more than a TXT record with a specific markup. Most hosting companies have a separate entry box for SPF nowadays, but in the background it&#8217;s still a TXT.<\/p>\n<p>Let&#8217;s split up everyting in this text record, so we can understand completely what exactly it is that Microsoft wants us to do.<\/p>\n<p><strong>v=spf1 :\u00a0<\/strong><br \/>\nAll this does is stating the obvious.<br \/>\nThis record is &#8220;version SPF1&#8221;.<br \/>\nTo make things confusing, there&#8217;s an <a href=\"https:\/\/en.wikipedia.org\/wiki\/Sender_ID\">unrelated spf2.0<\/a> record, which stands for &#8220;Sender ID&#8221;<\/p>\n<p><strong>include:spf.protection.outlook.com :<\/strong><br \/>\nThe include value *drumrolls* includes the values of another SPF record, in this case a large list of IP addresses of Microsoft servers.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-193 size-full\" src=\"http:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/spf_o365.png\" alt=\"\" width=\"961\" height=\"245\" srcset=\"https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/spf_o365.png 961w, https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/spf_o365-300x76.png 300w, https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/spf_o365-768x196.png 768w\" sizes=\"(max-width: 961px) 100vw, 961px\" \/><\/p>\n<p>The very same website I&#8217;ve used in the example above (<a href=\"https:\/\/www.mxtoolbox.com\">MX Toolbox<\/a>) easily provided me with this information. You can see that in itself this record loops through to more SPF values in spfa.protection.outlook.com.<br \/>\nThis has to do with the maximum accepted length for a TXT record, which is limited to 255 characters, as explained <a href=\"https:\/\/kb.isc.org\/article\/AA-00356\/0\/Can-I-have-a-TXT-or-SPF-record-longer-than-255-characters.html\">on this RFC page<\/a>.<\/p>\n<p><strong>-all<br \/>\n<\/strong>The final entry in the record is also the most conclusive one.<br \/>\nThe &#8220;-all&#8221; stands for &#8220;disallow all other entries&#8221;<\/p>\n<h2>Other entries<\/h2>\n<p><img loading=\"lazy\" class=\"alignright wp-image-200 size-full\" src=\"http:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/percep-vs-reality.jpg\" alt=\"\" width=\"470\" height=\"239\" srcset=\"https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/percep-vs-reality.jpg 470w, https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/percep-vs-reality-300x153.jpg 300w\" sizes=\"(max-width: 470px) 100vw, 470px\" \/>The above example was just a textbook sample provided by Microsoft to get you started. It should be sufficient for the average O365 setup.<\/p>\n<p>Reality however will often slap you in the face with a more complex situation where you&#8217;ll be needing to <a href=\"http:\/\/zupertails.be\/wur\/?p=163\">configure all-in-one printers<\/a>, <a href=\"http:\/\/zupertails.be\/wur\/?p=163\">old software packages<\/a> with support for mail over port 25 only, websites sending from something@your_domain_name, &#8230;<br \/>\nThey all have a couple of specific things to keep in mind when configuring your SPF record.<\/p>\n<p>A handy tool for helping you configuring your SPF record is\u00a0<a href=\"https:\/\/www.spfwizard.net\/\">https:\/\/www.spfwizard.net\/<\/a>, which does exactly what the name implies.<\/p>\n<p>Other possible entries you might use in your record :<\/p>\n<p><strong>A:<\/strong><br \/>\nIt&#8217;s usually followed by an actual DNS A-record<br \/>\nAn example will make things clear.<\/p>\n<pre class=\"alert alert-success\">v=spf1 include:spf.protection.outlook.com <strong>a:mail.suamae.br<\/strong> -all<\/pre>\n<p>The classic O365 SPF record was added <strong>a:mail.suamae.br<\/strong>, which will allow the IP resolving to this Brazilian mail server name to be able to send mails from shortstraw.be&#8217;s domain name as well.<\/p>\n<p>Just adding &#8220;A&#8221; and not defining anything behind it, will result in all A-records in shortstraw.be being able to send mail from this domain name.<\/p>\n<p><strong>MX:<br \/>\n<\/strong>Works similar to the A-entry.<\/p>\n<pre class=\"alert alert-success\">v=spf1 include:spf.protection.outlook.com <strong>MX:uwmoeder.com<\/strong> -all<\/pre>\n<p>The example above will allow all the mailservers in the domain uwmoeder.com to be able to send mail from shortstraw.be<\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-197 size-full\" src=\"http:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/mx_uwmoeder.png\" alt=\"\" width=\"585\" height=\"258\" srcset=\"https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/mx_uwmoeder.png 585w, https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/mx_uwmoeder-300x132.png 300w\" sizes=\"(max-width: 585px) 100vw, 585px\" \/><\/p>\n<p>Double checking on this, it will resolve to redirect.ovh.net in this case.<\/p>\n<p>Just adding &#8220;MX&#8221; without a domain name, will allow all MX entries in the shortstraw.be domain to send mail.<\/p>\n<p><strong>IP4:<br \/>\n<\/strong>You may enter one specific IPv4 address or a group of IP addresses in the typical &#8220;slash&#8221; notation (it&#8217;s called &#8220;CIDR format&#8221; in big-boy-language).<br \/>\nNote the omission of the letter &#8220;v&#8221; in ip4. Pay attention to this common typo.<\/p>\n<pre class=\"alert alert-success\">v=spf1 include:spf.protection.outlook.com ip4:194.78.56.8 ip4:37.230.164.0\/22 -all<\/pre>\n<p>This will allow the single host &#8220;<strong>194.78.56.8<\/strong>&#8221; and the group of IP addresses &#8220;<strong>37.230.164.0 to 37.230.167.255<\/strong>&#8221; to send mail from your domain name.<\/p>\n<p><strong>IP6:\u00a0<\/strong><br \/>\nSee above.<\/p>\n<pre class=\"alert alert-success\">v=spf1 include:spf.protection.outlook.com ip6:2a01:4f8:d16:1355::2 -all<\/pre>\n<p>Completely the same, but for IPv6 addresses.<\/p>\n<p><strong>~all<\/strong><br \/>\nReplacing the &#8220;-all&#8221; entry with this &#8220;~all&#8221;, results in the mails from the &#8220;not-allowed&#8221; list to be marked as so-called &#8220;Soft Fail&#8221;. <a href=\"https:\/\/www.arclab.com\/en\/kb\/email\/how-to-read-and-analyze-the-email-header-fields-spf-dkim.html\">You can see the result of this in the headers of a received mail<\/a> as something like &#8230;<\/p>\n<p><em>Received-SPF: softfail (google.com: domain of transitioning mail@example.com does not designate 203.0.113.2 as permitted sender) client-ip=203.0.113.2;<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><strong>+all<\/strong><br \/>\nStating the &#8220;+all&#8221; addendum, ignores everything you just added in the previous part of the SPF record.<br \/>\nYour mails might (or might not, depending on the server) be tagged with an extra header that says something in the likes of &#8220;this mail is probably not OK, but it doesn&#8217;t matter anyway&#8221;.<\/p>\n<p><strong>?all<\/strong><br \/>\nAlmost the same as &#8220;+all&#8221;, with the exception that your mails will not be flagged.<br \/>\n?all stands for &#8220;No policy statement&#8221; and simply does not hold the SPF record in account.<br \/>\nOften used when trying to delete an SPF record without actually deleting it.<\/p>\n<h2>Now how does this REALLY work ?<\/h2>\n<p>Every self-respectable and up-to-date mail server will do an SPF checkup, when receiving mail.<br \/>\nThat&#8217;s right, even Exchange Server 2003 can do this, updated to Service Pack 2. (not sure how it&#8217;s implemented in an Exchange 2000, though\u00a0 &#8211; I&#8217;ve seen software by GFI that used to be able to do this, but if you&#8217;ve come to this page looking for an antispam solution for your Exchange 2000, you can probably guess what I&#8217;m thinking right now&#8230;)<br \/>\nIn a side-note, this function is usually referred to as &#8220;Sender ID&#8221; in an Exchange environment.<\/p>\n<p>It&#8217;s usually a hard-coded feature with nothing much to tweak, except for turning it on or off.<\/p>\n<figure id=\"attachment_202\" aria-describedby=\"caption-attachment-202\" style=\"width: 710px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" class=\"size-full wp-image-202\" src=\"http:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/spf_cartoon.png\" alt=\"\" width=\"710\" height=\"365\" srcset=\"https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/spf_cartoon.png 710w, https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/spf_cartoon-300x154.png 300w\" sizes=\"(max-width: 710px) 100vw, 710px\" \/><figcaption id=\"caption-attachment-202\" class=\"wp-caption-text\">A basic representation of SPF functionality (picture shamelessly stolen from <a href=\"https:\/\/practical365.com\/exchange-server\/a-sender-policy-framework-spf-primer-for-exchange-administrators\/\">this site<\/a>)<\/figcaption><\/figure>\n<p>One simple image explains how it works.<br \/>\nMail server A sends mail from a certain domain.<br \/>\nMail server B receives mail from this domain and does a quick DNS lookup looking for any TXT records containing &#8220;v=spf1&#8221; after which he interprets the information like I&#8217;ve explained about one page up.<\/p>\n<p>That&#8217;s it !<\/p>\n<p>You now know how an SPF record works !<\/p>\n<p>&nbsp;<\/p>\n<h2>More information<\/h2>\n<p>I&#8217;ve taken the liberty of compiling a small list of handy websites should you want to read more on the subject.<\/p>\n<ol>\n<li>Pretty hardcore and a tough cookie to read ; the official <strong>RFC for SPF<\/strong> records :<br \/>\n<a href=\"https:\/\/tools.ietf.org\/html\/rfc7208#section-6.1\">https:\/\/tools.ietf.org\/html\/rfc7208#section-6.1<\/a><\/li>\n<li><strong>SPFWizard<\/strong>, for creating your own custom SPF records on the fly :<br \/>\n<a href=\"https:\/\/www.spfwizard.net\">https:\/\/www.spfwizard.net<\/a><\/li>\n<li><strong>DKIM<\/strong>, a next-level form of protection your domain.<br \/>\nIt&#8217;s not covered on this page, but it&#8217;s just a friendly reminder to let you know that there&#8217;s more than one way to perform mail protection :<br \/>\n<a href=\"https:\/\/blog.returnpath.com\/how-to-explain-dkim-in-plain-english-2\/\">https:\/\/blog.returnpath.com\/how-to-explain-dkim-in-plain-english-2\/<\/a><\/li>\n<li><strong>Mxtoolbox<\/strong>.<br \/>\nYour trustworthy website on troubleshooting DNS and mail related stuff.<br \/>\n<a href=\"https:\/\/www.mxtoolbox.com\">https:\/\/www.mxtoolbox.com<\/a><\/li>\n<li><strong>Microsoft Message Header Analyzer<\/strong>.<br \/>\nNot mentioned in this page yet, but a great tool nevertheless.<br \/>\nIf reading a wall of text is too hard, copy your mail headers in this website and it will provide you with readable text. Huzzah !<br \/>\n<a href=\"https:\/\/testconnectivity.microsoft.com\/?tabid=mha\">https:\/\/testconnectivity.microsoft.com\/?tabid=mha<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>The mysteries of the internet : SPF edition First of all, SPF stands for &#8220;Sender Policy framework&#8221;. Now you know. Period. &nbsp; &nbsp; &nbsp; &nbsp; Just kidding. An SPF record is used as a &#8220;sort of &#8221; security\/anti-spam measure in order to protect your outgoing mail from being sent FROM<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,6,9],"tags":[13],"_links":{"self":[{"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=\/wp\/v2\/posts\/187"}],"collection":[{"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=187"}],"version-history":[{"count":7,"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=\/wp\/v2\/posts\/187\/revisions"}],"predecessor-version":[{"id":203,"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=\/wp\/v2\/posts\/187\/revisions\/203"}],"wp:attachment":[{"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}