Knowledge Base/Domain Name Management/DNS

What is an MX record?

Jeremiah Stanley - http://www.name.com/cs/jeremiah
posted this on March 02, 2012 10:39 AM

The MX record defines how email will be routed for your domain. These are read by mail servers to determine where to send messages to, but not directly. MX records require that you point them at a hostname not an IP address. With many hosting plans your web server and your mail server are the same physical device; it is not required that this be the case however. Let's take a look at a quick example. We'll need to establish an A record first, then we can define an MX record to associate with it.

example.com    IN    A     192.168.0.1
example.com    IN    MX    10 example.com


In this example we have established a host name for the bare record example.com and given it the address 192.168.1.1. Since we can't set an MX record to be just an IP, we reference it with the second record. You'll notice the number 10 in there however. This is what is known as priority, and the lower the number the more important the record is.

You can have many MX records for a domain. The mail server will attempt to contact them in numeric order starting at the lowest number. This lets you set up multiple values if you need more than one nameserver. If you had two records with the same value it will choose between them randomly for which record gets used. And if a lower valued record isn't available the next highest value will be used. Often times higher values are configured to only save the messages and then forward them on to the lower values when they come available again.

example.com    IN    MX    1 aspmx.l.google.com
example.com   IN    MX    5 alt1.aspmx.l.google.com
example.com   IN    MX    5 alt2.aspmx.l.google.com
example.com   IN    MX    10 aspmx2.googlemail.com
example.com    IN    MX    10 aspmx3.googlemail.com

 
With this example we see the values that Google suggests to use with their Google Apps service. You can see the cascading priority values all the way down to one.

Trivia: MX stands for Mail eXchanger.

 
Topic is closed for comments