MX (Mail eXchanger) Resource Record

An “MX” (Mail eXchanger) Resource Record is specifically for mail servers. It’s a special type of service-specifier record. It identifies a mail server for the domain.
These records is used by mail servers to determine where to deliver email.

MX records should only map to A records (not CNAME records).

If an MX record is missing for the domain the mail for the domain will normally be attempted to be delivered to the matching A record. So for the domain “example.com” if there were no MX records for “example.com” then the mail would be attempted to delivered to the apex / root record of “example.com”.

Name: This is normally always left blank for MX records. This will be the host for your domain which is actually a computer within your domain. Your domain name is automatically appended to your name. So if you leave it blank it will be the instructions on where to send email for your domain (ie. username@example.com).

Server: This will be the host (the mail server) that will accept mail for the host that is specified in the name field. Your domain name is automatically appended to your value if it does not end it a dot.

MX Level: The MX level determines the order (which mail server) that your mail will be attempted to be delivered. The mail server with the lowest MX level will first be attempted to have the email delivered.

So if you hade three MX records with levels 10, 20, 30 the following would occur:
Mail would always be first tried to be delivered to the MX record with MX Level of 10.

If that mail server is down then the mail will try to be delivered to the mail server at 20.

If the mail server at level 20 is down then the mail will be attempted to be delivered at the mail server at level 30.

If the mail servers at level 20 and 30 are backup mail servers then the mail will be delivered to the mail server at level 10 when it comes back online.

If you have multiple MX records with the same MX level then it will setup a round robin configuration for your email. The sending email server will not send email to both email servers.

TTL: The TTL (Time to Live) is the amount of time your record will stay in cache on systems requesting your record (resolving nameservers, browsers, etc.). The TTL is set in seconds, so 60 is one minute, 1800 is 30 minutes, etc..

Systems that have a static IP should usually have a TTL of 1800 or higher. Systems that have a dynamic IP should usually have a TTL of 1800 of less.

The lower the TTL the more often a client will need to query the name servers for your host’s (record’s) IP address this will result in higher query traffic for your domain name. Where as a very high TTL can cause downtime when you need to switch your IPs quickly.

Best Practice Tip
If you plan on changing your IP you should set your TTL to a low value a few hours before you make the change. This way you won’t have any downtime during the change. Once your IP is changed you can always raise your TTL to a higher value again.

Example 1 – Simple MX record within the same domain:

NAME TTL TYPE DATA MX LEVEL
mail1.example.com. 1800 A 192.168.1.2
example.com. 1800 MX mail1.example.com. 10

 

 

like a CNAME, MX Entries must point to a domain and never point directly to an IP address. 

 

Glossary

  • Zone File: This is where all the DNS records are stored for a domain.
  • Host Record: This is the domain or subdomain you wish to use. The @ symbol is used to indicate the root domain itself. In our example the Host Record ‘ftp’ would be for the subdomain ftp.google.com and ‘@’ would be google.com itself.
  • Points to: This is the destination server that the domain or subdomain is sending the traffic to.
  • TTL: The ‘time to live’ value indicates the amount of time the record is cached by a DNS Server, such as your Internet service provider. The default (and lowest accepted) value is 14400 seconds (4 hours). You do not normally need to modify this value.
  • Action: This allows you to modify or remove existing records.
  • Weight: This is similar to priority, as it controls the order in which multiple records are used. Records are grouped with other records that have the same Priority value. As with MX Entries, lower numbers are used before higher numbers.
  • Port: This is used by the server or computer to process traffic to specific services, ensuring that all traffic comes through the door that it’s expected on.
  • Target: This is the destination that the record is sending the traffic to. This record would send traffic from service.example.com to listerning.otherexample.com over port 5060. SRV records generally require advanced knowledge of server administration to use.