Understanding Email: what is MX record and how it works?

0
2243

 

One of the Core component of a working email system is the MX record and a clear concept of “how it works?” is very much important for the System Administrator who is going to manage an Email server. there are lots of platform that an email system can work but the functionality of DNS for the domain and how Email flows to the email system is the same basic theory for all.

 

Very unfortunately, there are many administrators who manage an email system but don’t have a clear concept on how actually it works!!! And there are IT managers who actually depends on vendors but they should also have a clear picture idea that how their Email system is working.

 

MX is the sort name for “Mail Exchanger” which is a TYPE of DNS record. To understand MX need to understand the basics of Domain Name System (DNS) first.

 

Basic theory of DNS:

Primary purpose of a Domain Name System or DNS is to translate a name into IP address so the entire INTERNET can be easy to use make the network communications between connected host and server on the network.

 

For example, when you type a domain name on your browser, DNS is used to lookup the name or the “A” record for that domain and find the IP address where the site is hosted and then browser connects to that server. let’s say the domain name is sudotoolbox.com

 

Now if anybody send an email to @sudotoolbox.com how it works?

DNS is the key to find any service for a domain, so now sending Email server will look up the MX records into the DNS and this happen on the below process.

 

  1. Look up the authoritative Name Server for sudotoolbox.com from the root DNS servers.
  2. Query the sudotoolbox.com Name Servers for the MX records.
  3. Look up the “A” record for the MX value in NS to get the IP address.

 

If we run the manual DNS lookup for the MX records of sudotoolbox.com from a CLI, results will be as below:

And for better understanding here is a visual of this process:

 

MX preferences:

you may ask for the value “MX preference” in the output and what does it means. To explain this here is another MX query for gmail.com

Here it is pointing to multiple host with a preference value of 5,10,20,30 & 40. Which is simply declaring that which host should try first to send the email. If the first one is unreachable or busy, it will try the second one and so on up to the last resort. Here the lowest value represents the highest priority.

 

Purpose of multiple MX records can be explaining in two ways.

  1. Using multiple MX with same preference value will do load balancing for incoming emails.
  2. Using multiple MX with different priority will provide a backup MX service that receive email when primary one is unreachable or experiencing downtime.

 

Now what should be your MX record?

MX can be pointed to the hostname of the Email server directly but if you consider to secure your Email server from external thread, this should be pointed to an Email Security Gateway where Email will be scanned for SPAM/Viruses and the filtered email will be delivered to the original Email server. this also protects Email server from other network level security threats.

 

 

Now you should have a basic understanding of MX record and how it works with an Email system. If you have any further query you may drop a comment below.

 

LEAVE A REPLY