An MX record is a DNS record that specifies which mail server(s) are responsible for receiving the email for a domain. For example, the dnscheck.co domain has two MX records pointing to the mail.protonmail.ch and mailsec.protonmail.ch mail servers. A domain name can have multiple MX records.
You can look up these records yourself with the dig command:
dig +short dnscheck.co MX
That returns each MX record as a Preference followed by an Exchange:
10 mail.protonmail.ch.
20 mailsec.protonmail.ch.
MX records are also called "mail exchange records", and are partially defined in RFC 5321.
DNS Check can monitor your MX records and notify you if they become unresolvable, or start resolving to the wrong Exchange or using the wrong Preference. The Exchange and Preference fields are explained in the next section.
Fields
Here are the fields that make up an MX record:
| Field | Description | Example |
|---|---|---|
| Name | A fully qualified domain name (FQDN). | example.com. |
| Type | The DNS record type. Always set to "MX". | MX |
| Preference | How desirable this MX record is relative to other MX records. The lower the Preference, the more desirable the MX record is. | 10 |
| Exchange | The mail server that receives the incoming email for this domain, usually given as a fully qualified domain name (FQDN). | mail.example.com. |
The Preference is a number from 0 to 65,535, and lower values are more desirable. Mail is normally delivered to the mail server(s) with the lowest Preference, while higher-Preference servers act as backups. For the dnscheck.co records above, mail goes to mail.protonmail.ch (Preference 10) first, and falls back to mailsec.protonmail.ch (Preference 20) only if it's unavailable.
DNS Zone File Examples
Here's an example of how MX records look in a DNS zone file:
; Name Type Preference Exchange
example.com. MX 10 mx.example.com.
example.com. MX 20 mx2.example.com.
In the above example, the Name and Exchange values end with ., so they're fully qualified domain names.
Alternatively, you can create an MX record that's relative to the zone file's $ORIGIN. Here's an example of how to do this to create DNS records that are equivalent to what's shown in the previous example:
$ORIGIN example.com.
; Name Type Preference Exchange
@ MX 10 mx
@ MX 20 mx2
Null MX Records
A single dot (.) is a valid Exchange. It's called a null MX record (RFC 7505) and signals that the domain accepts no email at all. A null MX uses a Preference of 0 and an Exchange of . (for example, example.net publishes 0 .). You can monitor one by entering 0 as the Preference and . as the Exchange.
Monitoring with Wildcards
You can optionally use an asterisk (*) as a wildcard for the Preference, the Exchange, or both. Each field is matched independently:
- Wildcard Exchange (for example, Preference
10and Exchange*) passes as long as an MX record exists with that exact Preference, no matter which mail server it points to. - Wildcard Preference (for example, Preference
*and Exchangemail.example.com.) passes as long as an MX record points to that Exchange, regardless of its Preference. - Both wildcards (Preference
*and Exchange*) pass if any MX record exists for the Name.
By default, a wildcard check passes as long as at least one returned MX record matches, even if the Name has other MX records too. If you enable the Exclusive option, the full set of returned MX records must correspond one-to-one with the records you monitor. A single wildcard, such as Preference 10 and Exchange *, then passes only when exactly one MX record is returned, and it has Preference 10. To exactly match a Name that has several MX records, add a monitored record (wildcard or specific) for each one.
Additional Resources
- Check Your DNS MX Records - a blog post that goes into a lot of detail on what MX records are and how to check them using dig, nslookup, and DNS Check.
- RFC 5321 - this RFC partially defines MX records.
- RFC 7505 - this RFC defines the null MX record.
Protect your DNS infrastructure with automated monitoring
Get notified immediately when DNS records change. Start monitoring your critical DNS infrastructure for free in under 5 minutes.
No credit card required • Cancel anytime