Guide

Cloudflare DNS for Google Workspace and Microsoft 365, record by record

Every record Google or Microsoft asks for goes on your domain's DNS Records page in Cloudflare. Here is where that is, what to type in each box, and the two Cloudflare settings that can quietly stop email working.

Facts checked

At Cloudflare, every record for Google Workspace or Microsoft 365 goes in the same place: sign in to the Cloudflare dashboard, select your account and domain, go to DNS, then Records, and select Add record. Pick the type, type @ in the Name box for your main domain, paste the value Google or Microsoft gave you, and save. Cloudflare's own Google Workspace setup guide walks the same screen.

That only works when Cloudflare answers your domain's DNS, which means your registrar is set to Cloudflare's nameservers. If the nameservers name another company, the records go there instead, and our free DNS lookup tells you which in a few seconds. On Cloudflare, two settings matter more than anywhere else: the proxy switch on CNAME records, and Email Routing.

Adding a record at Cloudflare

The same six steps for every record on this page. Only the type, the name and the value change.

  1. Check that Cloudflare answers your DNS.

    Run your domain through our DNS lookup and read the nameserver lines. Cloudflare's nameservers follow the pattern name.ns.cloudflare.com. If yours name another company, add every record below at that company instead. If the domain is moving to Cloudflare right now, the safe order for that is in moving your DNS to Cloudflare.

  2. Open the domain's DNS Records page.

    In the Cloudflare dashboard, select your account and domain, then go to DNS, Records (Cloudflare's Google Workspace guide). Each domain keeps its own records, so check you opened the right one.

  3. Select Add record and pick the type.

    Choose TXT, MX or CNAME, whichever the tables below say, then fill in the boxes and save, as Cloudflare's guide to creating records shows. The value goes in the box called Content for a TXT record, Mail server for MX and Target for CNAME (Microsoft's Cloudflare guide).

  4. Type @ for the main domain, and only the short part for the rest.

    Cloudflare's own examples put @ in Name for the root of the domain, and only the short part, such as _dmarc or google._domainkey, for a record on a sub name.

  5. Set Proxy status to DNS only, and paste the value bare.

    MX and TXT records are always DNS only. A CNAME record has a Proxy status switch: set it to DNS only, the gray cloud, before you save. Paste values with no quote marks around them; Cloudflare adds its own quotes to a TXT record saved without them.

  6. Save, then check it is public.

    Select Save. Cloudflare says Google typically sees a new record within a few minutes, though DNS can take up to 48 hours. Run the DNS lookup again: once the record shows there, Google and Microsoft can see it too.

Google Workspace records at Cloudflare

Google gives you each value in the Google Admin console. Add them in this order: verification first, the mail record once the new mailboxes are ready, then the three records that keep your mail out of spam.

RecordNameValue
Verify the domainTXT@google-site-verification= followed by your code from the Admin console
Receive mailMX, priority 1@smtp.google.com
SPFTXT@v=spf1 include:_spf.google.com ~all
DKIMTXTgoogle._domainkeyThe key starting v=DKIM1; that the Admin console generates for you
DMARCTXT_dmarcv=DMARC1; p=none; rua=mailto: followed by an address you read

Verifying the domain

In the Admin console, go to Account, Domains, Manage domains, and select Verify domain. Copy the whole value, including google-site-verification=, and add it as a TXT record with @ in Name and the value in Content. Leave it in place until Google confirms, which Google says can take up to 72 hours. This record proves you own the domain and does not change where your email goes, so it is safe to add while your current email keeps working. If Google answers that the domain is already in use, Cloudflare notes that is a Google account matter, not a DNS one: the domain is still attached to another Google Workspace account. Other causes are in Google Workspace domain verification failed.

Pointing mail at Google

Google's current mail record is a single MX record: smtp.google.com at priority 1 (Google's MX guide). Cloudflare's own Google Workspace guide still lists Google's five older records that start with aspmx; Google says those older values are still supported, so a domain already using them with working mail needs no change. Either way, Google says to remove any other MX records, and Cloudflare's guide says to delete MX records that point at another mail provider. Make this change only when the new mailboxes exist.

Check for Cloudflare Email Routing before you start. Cloudflare's Google guide says Email Routing and Google Workspace MX records cannot coexist on the same domain, and has you turn Email Routing off before adding Google's. Turning it off removes every MX, SPF and DKIM record it added, even one you unlocked and edited to point somewhere else. If mail has to keep arriving during the switch, Cloudflare's Email Routing page gives a gentler order: unlock its records, add Google's alongside them as new records, check the new mailboxes work, then turn Email Routing off. Either way, check the record list again straight after.

SPF, DKIM and DMARC

For SPF, Google's value when Workspace is your only sender is v=spf1 include:_spf.google.com ~all (Google's SPF guide). Cloudflare's guide says your domain must have exactly one SPF record, so every other service that sends as you adds its include to that same record rather than a record of its own. Our free SPF checker shows the record the world actually sees.

For DKIM, wait 24 to 72 hours after Gmail is turned on. Then, in the Admin console, go to Apps, Google Workspace, Gmail, Authenticate email, and generate a new record; Cloudflare's guide picks the 2048-bit key length. Add it as a TXT record with google._domainkey in Name and the whole key in Content, and only then select Start authentication (Google's DKIM guide).

Add DMARC last. Google suggests waiting 48 hours after SPF and DKIM, then starting at p=none, which only reports and blocks nothing, and tightening it once the reports show your real mail passing (Google's DMARC guide). If a _dmarc record already exists, we edit it rather than add a second, so the domain keeps one.

Microsoft 365 records at Cloudflare

Microsoft has its own guide for Cloudflare with two routes. For a domain not yet set up with another email service, Domain Connect adds the records for you after you sign in to Cloudflare and select Authorize; the steps are in the questions below. Otherwise the records go in by hand, with the six steps above. In the Microsoft 365 admin center, go to Settings, Domains, select your domain and choose Manage DNS to see the values for your domain.

RecordNameValue
Verify the domainTXT@MS=ms followed by the number the admin center shows you
Receive mailMX, priority 1@Your domain's own address ending in .mail.protection.outlook.com, from the admin center
Outlook setupCNAME, DNS onlyautodiscoverautodiscover.outlook.com
SPFTXT@v=spf1 include:spf.protection.outlook.com -all
DKIMCNAME, two records, DNS onlyselector1._domainkey
selector2._domainkey
The two values the Microsoft Defender portal shows for your domain
DMARCTXT_dmarcv=DMARC1; p=none; rua=mailto: followed by an address you read

Microsoft's Cloudflare guide sets the MX record at priority 1 and then says to delete any other MX records listed. Add your users and mailboxes before you change the MX record. Microsoft's Cloudflare table uses a TTL of 30 minutes, and Cloudflare's Auto setting, five minutes, works too: both are well inside the six hour limit Microsoft sets for Exchange Online. If Email Routing is on, the same rule as above applies: add Microsoft's records as new records, then turn it off.

The autodiscover record and the two DKIM records are CNAME records, the one type on this page with a proxy switch. Set each to DNS only before you save: Cloudflare recommends DNS only for records that do not serve web traffic. Cloudflare's email troubleshooting guide adds that CNAME flattening can stop an email provider reading a record correctly, and suggests turning flattening off if your provider needs CNAME records.

SPF, DKIM and DMARC

The SPF value above is Microsoft's for a domain that sends mail through Microsoft 365 only. Microsoft's Cloudflare guide says not to create a second SPF record: if one exists, add Microsoft's values to it, so the domain keeps a single record, and keep the part for any service that still sends as you.

DKIM is turned on in the Microsoft Defender portal, under Email authentication settings, on the DKIM tab. Select your domain and Create DKIM keys, add the two CNAME records it shows, with each name in Name and each target in Target and the proxy set to DNS only, then switch on Sign messages for this domain with DKIM signatures (Microsoft's DKIM guide).

Microsoft recommends DMARC after SPF and DKIM, starting at p=none and moving to quarantine and then reject as the reports confirm your real mail passes (Microsoft's DMARC guide). The same habit applies: one _dmarc record, edited rather than duplicated.

Mistakes that stop email working

Each of these is quick to avoid and slow to untangle once mail has gone missing.

  • Adding records where the DNS is not answered. With Cloudflare's nameservers set, records at the registrar or an old host are not seen; without them, records in Cloudflare are not. Check the nameservers first.
  • Leaving the orange cloud on a mail CNAME. Autodiscover and Microsoft's two DKIM records are CNAME records. Set each to DNS only, as Cloudflare recommends for email records.
  • Leaving Email Routing on. Cloudflare says Email Routing and Google Workspace MX records cannot share a domain. Move the addresses first, then turn it off.
  • Editing Email Routing's records instead of adding new ones. Turning Email Routing off deletes every record it created, even ones you edited. Add the new provider's records as new records.
  • Leaving old MX records in place. Google, Microsoft and Cloudflare all say to remove MX records that point at another mail provider.
  • Switching MX before the new mailboxes exist. Incoming mail follows the MX record once the change spreads. Verify the domain, set up the accounts, then switch.
  • Adding a second SPF record. Cloudflare and Microsoft both say one SPF record per domain. Put every sender's include in that one record.
  • Starting DMARC at reject. Google and Microsoft both start at p=none and tighten later, so real mail is not blocked by a setting nobody has watched yet.

Who this is for

  • Businesses whose DNS is at Cloudflare, setting up Google Workspace or Microsoft 365
  • Owners who moved their DNS to Cloudflare and want to check the mail records came across
  • Anyone using Cloudflare Email Routing who is moving to real mailboxes
  • Anyone whose Google or Microsoft setup is stuck at the verify your domain step

When this is not the right fit

  • Domains whose nameservers are not Cloudflare's. The records are the same, but they go on that company's DNS screen instead; for GoDaddy, see our GoDaddy DNS guide.
  • Moving the DNS itself to Cloudflare. That move has its own safe order, covered in moving your DNS to Cloudflare.
  • Moving existing mailboxes with years of mail in them. The records are the easy part of that job and the order is the hard part, covered in business email migration.

What TechTruePoint can help with

Adding the records takes minutes once you know where they go. Where owners ask for help is finding out who controls the DNS, the order of the switch, the Cloudflare settings that quietly break mail, and checking that mail really arrives afterwards.

Common questions

Does the orange cloud matter for email records?

Only on CNAME records. Cloudflare says MX and TXT records are always DNS only, so the verification, mail, SPF and DMARC records on this page have no proxy switch at all. Microsoft's autodiscover record and its two DKIM records are CNAME records, and those do.

Set each of them to DNS only, the gray cloud, which is what Cloudflare recommends for records that do not serve web traffic, such as email and verification records.

Can Microsoft 365 add the records at Cloudflare for us?

Yes, when the domain is not yet set up with another email service. Microsoft supports Domain Connect at Cloudflare: in the Microsoft 365 admin center, go to Settings, Domains, select the domain, choose Manage DNS, select Continue and then Add DNS records, sign in to Cloudflare and select Authorize.

If the domain already carries mail somewhere else, Microsoft's manual route lets you choose when the MX record changes, which is the safer way to switch. Either way, check the result against the table on this page with our free DNS lookup.

We use Cloudflare Email Routing to forward our mail. What happens to it?

It has to go. Email Routing is Cloudflare's free email forwarding, and Cloudflare says Email Routing and Google Workspace MX records cannot coexist on the same domain. Turning it off removes the MX, SPF and DKIM records it added, and the forwarding addresses stop working with them.

So set up the same addresses as real users, aliases or groups in Google Workspace or Microsoft 365 first. Cloudflare's own order for moving away is to unlock Email Routing's records, add the new provider's records alongside them as new records, check the new setup works, and only then turn Email Routing off.

How long until Google or Microsoft sees the new record?

Usually minutes. Cloudflare says Google typically verifies within a few minutes, though it can take up to 48 hours, and Microsoft says a change typically takes about 15 minutes. Google's own guide allows up to 72 hours.

Check rather than wait. When our free DNS lookup shows the new record, Google and Microsoft can see it too, and clicking Verify again is all that is left.

Get a Quote

Rather we added the records for you?

Tell us your domain and whether you are moving to Google Workspace or Microsoft 365. We check where your DNS is answered, add every record in Cloudflare with the right proxy setting, and test sending and receiving before we hand it back.

Call now Request a quote