In DNS a MX record is like an address book for email servers. It tells other servers where to send emails for a specific domain name. Every domain has its own MX record created on its authoritative DNS server that tells other email servers where to deliver their email.
A MX record contains two important pieces of information.
- The name of the server that should can be used to deliver the email for that domain.
- Priority number that tells servers which server to use first.
It’s must to set up MX records because they help ensure that emails are delivered to the right place. When you set up an MX record, you tell other mail servers which server(s) you want them to use when they try to send emails for your domain.
In this example we are using nslookup to find out the email servers of Gmail. Following is the sequence of commands on command prompt,
- nslookup
- set type=mx
- gmail.com
As a result of these commands followings are the MX records are found for gmail.com.
Based upon the above outcome, the sending email server will try to connect the SMTP with following order. Since the preference is 5,10,20,30,40.
- gmail-smtp-in.l.google.com (Preference 5)
- alt1.gmail-smtp-in.l.google.com (Preference 10)
- alt2.gmail-smtp-in.l.google.com (Preference 20)
- alt3.gmail-smtp-in.l.google.com (Preference 30)
- alt4.gmail-smtp-in.l.google.com (Preference 40)
Why multiple MX Record
Now the questions arises why we need multiple records. Answer is simple, if first email server is down and unable to receive the email, the sending server will retry to send email to 2nd or third server and so on. Incase non of the servers is available for email delivery, the sending server will keep the email in it queue and retry after some time. If none is reachable for a long period of time, sending server may discard the email (depending of sending email server policy) and generate a non delivery alert for the sender.
Another and relatively easier way to run for mail server loookup of Gmail in single line is “nslookup -q=mx gmail.com”. Following is the output.
If you want to make your life more easy. Web based GUI tools are also available to query MX record of domain. Go to “http://pingstage.com“. Type the domain name in this example we are using gmail.com. Select MX in record type and click lookup.
It will bring the MX records of gmail.com for you. Later these names can be converted to IP address using DNS A record.
If you want to learn more What is DNS server and different type of DNS records, and you may check other articles/posts on our site.
Frequently Asked Questions (FAQ)
You can run “nslookup -q=mx domainname.com” to find the MX record for any domain.
Yes it is possible to have more MX records for a domain. Infect it is recommended to have more than one mail exchanger records for redundancy and failover purpose.
This will result into non delivery report (NDR).
No you can not. The whole purpose of MX record is to tell others which email server should be used to deliver email. Incase of trying to hide the whole purpose is lost.
-
DNS Port 53 TCP or UDP?
Ever wondered why DNS uses both TCP and UDP? Find out when DNS switches between TCP and UDP on port 53 and why it matters.
-
DNS Forwarder
Learn how a DNS forwarder can boost your network’s speed, improve security. Reduce load for better DNS management.
Leave a Reply