Select Page

Understanding MX records

What is an MX Record

MX stands for Mail Exchange Records. MX records are used in DNS records(or Zone files) to specify how email should be routed.


Hire Bobcares Server Administrators
Get super reliable servers and delighted customers

See how we do it!


Lets take an example of say

This is how a typical DNS record(for looks like.

; Zone file for

@ 14400 IN SOA (
			600 ) 14400 IN NS 14400 IN NS 14400 IN NS

; A Record 14400 IN A 14400 IN A

; MX record 14400 IN MX 0

mail 14400 IN CNAME
www 14400 IN CNAME
ftp 14400 IN CNAME

Notice the line with the “MX” in it. This is called the MX record. 14400 IN MX 0

The MX record shows that all emails @ should be routed to the mail server at The DNS record shows that is located at This means that email meant for will be routed to the email server at This finishes the task of the MX record. The email server on that server(say sendmail) then takes over, collects the email and then proceeds to distribute it to the user “liz”.

It is important that there be a dot(“.”) after the domain name in the MX record. If the dot is absent, it routes to “”. The number 0, indicates Preferance number. Mail is always routed to the server which has the lowest Preferance number. If there is only one mail server, it is safe to mark it 0.

Multiple mail servers

Multiple email servers are useful for the sake of redundancy. If the Highest Priority email server (one with the lowest Preference number) is down, then the email is routed to the Server with the second highest Preference number.

For example 14400 IN A 14400 IN A 14400 IN MX 0 14400 IN MX 30

You can have unlimited MX entries for Fallback.

If all the MX records are equal Preference numbers, the client simply attempts all equal Preference servers in random order, and then goes to MX record with the next highest Preference number.

Pointing MX records to an IP

Its not possible to have an MX record pointing directly to an IP. For example ‘ 14400 IN MX 0“ is wrong. Define an “A Record” first and then have the MX record pointing to it. 14400 IN A 14400 IN MX 30

MX records for Subdomains

A Subdomain is something like this “”. Assume you want to send an email to and to capture that on another server. 14400 IN A 14400 IN A 14400 IN MX 30 14400 IN MX 30

In this configuration, would go to and would go to

Testing the MX record

Once you setup your MX record, always test it to see if it is setup correctly. You can do with tools like nslookup.

[root@localhost sangeetha]# nslookup
> set q=mx
Server: Address:
Non-authoritative answer: mail exchanger = 1 mail exchanger = 1 mail exchanger = 1 mail exchanger = 5
Authoritative answers can be found from: nameserver = nameserver = nameserver = nameserver = nameserver = internet address = internet address = internet address = internet address = internet address = internet address = internet address = internet address = internet address =

How spammers read your MX

Spammers will typically target your lowest priority Email servers, in the hopes of encountering a poorly configured box. The Spam program reads the MX records, locates the Email server with the lowest Priority(highest Preference number) and attempts to spam with that server.

So it is important to equally update all your email servers with Antivirus and Antispam.

Articles by Sangeetha Naik About the author:

Sangeetha Naik heads She is the co-founder of Poornam Info Vision Ltd., Software and IT services company specializing in Linux based solutions for Webhosts and ISPs. Poornam Info Vision is an ISO 9001:2000 certified company with a team of over 140 engineers.

Sangeetha is a Computer Engineer based in India and has over 7 years of experience in the hosting industry. Her articles have been published both online as well as in print in magazines.

DNSServer Support


  1. Hi Sangeetha,

    Thanks for the easy to understand explanation of MX records. I have a question. I have a limited number of records that I can use through my registrar for a given domain. However, I would like to give each of my family members their own email subdomain with 5 MX records each. I’ll soon run out of records.

    For example:,,… etc… etc. I’m using Google Apps for each one, so they all point to the same servers.

    The question…
    Is there a way to combine the MX records? The asterisk is not allowed (* when specifying a MX record. Is there another way to conserve records and still catch the mail for all of the various subdomains?


  2. If you can’t use wildcards with your Host, I would suggest a single MX record for each subdomain(family member).
    For example

    ; MX record 14400 IN MX 0 14400 IN MX 0

    Of course, I am assuming that your mail server is implemented in my

    You can have multiple email accounts setup with individual subdomains, using your mail server. For example., etc. That can be setup with your mail server.

    If this is what you need, there really is no need to have multiple MXs for each family member. Thereby, you can restrict it to 1 MX per family member.

  3. I switched my MX records to point to Google Apps from my domain but I want to still go to my own server. Currently is a CNAME for (not sure how to say that :-)). I tried making a MX record for to point to my server but that does not seems to work. Any ideas on what I should do?


  4. MX records should always point to a A record. Technically it should not point to a CNAME record, and may be disallowed by your DNS provider or host. However it is still widely implemented. To see how you can implement it, see

  5. Hi Sangeetha,
    Many thanks for your excellent documentation on the SOA and MX records. I found them very helpful.

  6. H Sangeetha
    i have small query on MX record below

    mx1 86400 IN a
    mx2 86400 IN a

    10 @ 604800 IN mx
    20 @ 604800 IN mx
    i have user like user1, user2 & user3 whereas user2/user3 is in

    1.when someone send mail to how it deliver the mail on mx2 server ?
    2.what is maximum no for MX priority?

  7. Hi sangeetha,
    I need to read the mx record to know whether an email address exists in the mail box or not is there a way to do this?

  8. I have looked everywhere for the MX Records for Yahoo Mail. I recently moved host and need to enter new MX Records so my mail still goes to Yahoo. I need the PRIORITY, HOST and RECORD and it is no where to be found!

  9. Hi, thnks for well explained article. Any newbie can understand it. 🙂

Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.