Understanding MX records

by Sangeetha Naik, co-Founder, Bobcares.com

What is a 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.


Hate these ads?

Lets take an example of say liz@mydomain.com.

This is what a typical DNS record(for mydomain.com) looks like.


;
; Zone file for mydomain.com
@ 14400 IN SOA ns.mynameserver.com. root.ns.mynameserver.com. (
109157199 
86000 
7200 
3600000 
600 ) 
mydomain.com. 14400 IN NS ns.mynameserver.com. 
mydomain.com. 14400 IN NS ns2.mynameserver.com. 
mydomain.com. 14400 IN NS ns3.mynameserver.com.



; A Record
mydomain.com. 14400 IN A 216.34.94.184








localhost.mydomain.com. 14400 IN A 127.0.0.1



; MX record
mydomain.com. 14400 IN MX 0 mydomain.com. 



mail 14400 IN Cname mydomain.com. 
www 14400 IN Cname mydomain.com. 
ftp 14400 IN Cname mydomain.com. 





Notice the line with the ``MX'' in it. This is called the MX record.


mydomain.com. 14400 IN MX 0 mydomain.com. 


The MX record shows that all emails @ mydomain.com should be routed to the mail server at mydomain.com. The DNS record shows that mydomain.com is located at 216.34.94.184. This means that email meant for liz@mydomain.com will be routed to the email server at 216.34.94.184. 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 ``mydomain.com.mydomain.com''. 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


mydomain.com. 14400 IN A 216.34.94.184
server2.mydomain.com. 14400 IN A 216.34.94.185
mydomain.com. 14400 IN MX 0 mydomain.com. 
mydomain.com. 14400 IN MX 30 server2.mydomain.com. 


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 'mydomain.com. 14400 IN MX 0 216.34.94.184`` is wrong. Define an ``A Record'' first and then have the MX record pointing to it.



server2.mydomain.com. 14400 IN A 216.34.94.185
mydomain.com. 14400 IN MX 30 server2.mydomain.com. 


MX records for Subdomains

A Subdomain is something like this ``Subdomain.mydomain.com''. Assume you want to send an email to liz@subdomain.mydomain.com and to capture that on another server.


mydomain.com. 14400 IN A 216.34.94.184
server2.mydomain.com. 14400 IN A 216.34.94.185
mydomain.com. 14400 IN MX 30 mydomain.com. 
subdomain.mydomain.com. 14400 IN MX 30 server2.mydomain.com. 


In this configuration, liz@subdomain.mydomain.com would go to 216.34.94.185 and liz@mydomain.com would go to 216.34.94.184.

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 
> yahoo.com 
Server: 192.168.1.1 Address: 192.168.1.1#53
Non-authoritative answer: 
yahoo.com mail exchanger = 1 mx1.mail.yahoo.com. 
yahoo.com mail exchanger = 1 mx2.mail.yahoo.com. 
yahoo.com mail exchanger = 1 mx3.mail.yahoo.com. 
yahoo.com mail exchanger = 5 mx4.mail.yahoo.com.
Authoritative answers can be found from: 
yahoo.com nameserver = ns2.yahoo.com. 
yahoo.com nameserver = ns3.yahoo.com. 
yahoo.com nameserver = ns4.yahoo.com. 
yahoo.com nameserver = ns5.yahoo.com. 
yahoo.com nameserver = ns1.yahoo.com. 
mx1.mail.yahoo.com internet address = 4.79.181.14 
mx1.mail.yahoo.com internet address = 4.79.181.15 
mx1.mail.yahoo.com internet address = 67.28.113.10 
mx1.mail.yahoo.com internet address = 67.28.113.11 
ns1.yahoo.com internet address = 66.218.71.63 
ns2.yahoo.com internet address = 66.163.169.170 
ns3.yahoo.com internet address = 217.12.4.104 
ns4.yahoo.com internet address = 63.250.206.138 
ns5.yahoo.com internet address = 216.109.116.17 
>


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.


Sangeetha Naik is Co-Founder of Bobcares.com, Tech support company for WebHosts and ISPs .Bobcares is an ISO 9001:2000 certified company and employes over 140 engineers.




Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)

Or use any RSS reader

Delivered by FeedBurner



Views for this page
Today This Week This Month This Year  Overall
4842,207 5,805

/Unixart/understanding_mx.html copyright December 2005 Sangeetha Naik All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

More:
       - Mail




Unix/Linux Consultants


larryi@ccamedical.com SCO OS5, Debian Linux, RedHat Linux, MySQL, Apache, AJAX development using dXport/dL4/Unibasic, Windows Connectivity, Sharing Resouces, Automation, Shell Scripting


SCO, OpenServer, UnixWare, software, servers, security, networks, installation, administration, troubleshooting, maintenance, Watchguard, firewalls, VPNs, e-mail. Visit us at http://opensystemscomputing.com and www.go2unix.com.


http://www.breakthru.com.au SCO (Openserver and Unixware), Unix, Solaris and Linux Consulting services including: Secure Networking Solutions; Linux based Firewalls; Backup Solutions; Secure Home to Office Network Setup; Phone, Remote and On-Site Support available - Satisfaction Guaranteed!



Twitter
  • Nov 30 20:25
    I have 37,000 words of a 50,000 word project. I'd like to finish it this week..
  • Nov 30 20:05
    My wife made turkey sandwiches with stuffing and cranberry orange relish - I did not want to eat the last bite. Didn't want it to end!




card_image








Change Congress


Related Posts