Easily import DNS records for Gmail/GSuite/Google Workspace into Cloudflare
Cloudflare (and lots of other DNS providers) allow you to import a DNS file ('zone file') to bulk add DNS records. Use this file to import all default settings for Google Workspace.
Setting up Google Workspace can be tedious. There are many DNS records to add, all with different priorities.
Google did recently release a tool that allows you to log into your DNS provider's account via SAML and they'll add them for you, but only a handful of hosts are supported and you may not - understandably - want to share access across multiple providers.
Many DNS providers, including Cloudflare, allow you to import a DNS zone file, which is effectively a text file for bulk importing DNS entries.
The below snippet can be saved as anything locally, and then imported into Cloudflare from the DNS control panel.
; G Suite - https://gsuite.google.com/
;; Adds G Suite MX records
;; Documentation
;; https://support.google.com/a/answer/140034
;; Adds the default G Suite SPF as a TXT record.
;; Documentation
;; https://support.google.com/a/answer/33786
;; MX Records
@ 1 IN MX 10 alt4.aspmx.l.google.com.
@ 1 IN MX 10 alt3.aspmx.l.google.com.
@ 1 IN MX 5 alt2.aspmx.l.google.com.
@ 1 IN MX 5 alt1.aspmx.l.google.com.
@ 1 IN MX 1 aspmx.l.google.com.
;; TXT Records
@ 1 IN TXT "v=spf1 include:_spf.google.com ~all"
Note the final TXT record which adds an SPF record. Depending on your provider this may overwrite any existing SPF record you have, or add an additional record rather than appending to your existing SPF, so please use with caution.
To add the zone file just go to the DNS section of your domain in Cloudflare, click Advanced and then upload the file.