Limited Time Free!  Sign up for 1TB of data transfer and get free trials of WAF and Bot Management!
Get Started Now 
learning center banner

What is a DNS MX Record?

Learn how DNS MX records are essential for email delivery and the components of MX records, including domain names, priority values, and mail server domain names. Discover how to use nslookup to view MX records. Explore load balancing techniques by adding multiple MX records with varying or identical priorities to ensure reliable email routing, optimized performance, and redundancy.

What is a DNS MX Record?

A DNS MX (Mail Exchanger) Record is a DNS record type used to specify the address of the mail server. MX records tell the email system which server it should pass the message to when it is sent.

When you send an email, the mail client looks for the MX record of the target email address. The MX record contains a priority value and the domain name of a mail server. A priority value indicates the priority order of the mail server. A lower value indicates a higher priority. The mail client will attempt to connect to the mail servers in the MX record, in order of priority, until the message is successfully sent or all servers are tried.

For example, if you send an E-mail to example.com, the mail client looks up the MX record of example.com to find the domain name and priority of one or more mail servers. The mail client will then attempt to connect to these mail servers in order of priority until the message is successfully sent.

The setting of MX records is usually configured by the domain's administrator or mail service provider. By setting MX records correctly, you can ensure that emails are correctly routed to the target mail server, enabling reliable email delivery.

What are the Components of a DNS MX Record?

Here is a table with an example MX record:

Example of a DNS MX record

As you can see, the DNS MX record consists of the following parts:

  • Domain name: A domain name is a specific domain configured with MX records, such as example.com or example.org. The @ symbol is also used in DNS records to indicate the root domain name or the origin of a region. It is applicable not only to MX records but also to various types of DNS records. For example, if the domain is "example.com," an MX record with the "@" sign in the name field indicates that it applies directly to "example.com."
  • Mail server: A mail server represents the specific host name responsible for handling incoming mail for that domain. For example, if the domain name is example.com, the mail server can be mail.example.com or smtp.example.com, and the configuration may involve multiple mail servers, all based on specific Settings laid out by the email provider. These multiple servers work together to ensure that emails are processed and sent seamlessly, regardless of volume or traffic.
  • Record type: The record type of MX records is always set to "MX" to identify them as mail exchange records. The MX record type indicates that the record is used for mail routing.
  • Priority: The priority field assigns a numerical value to each MX record, indicating the order in which the email server should be contacted. A lower value indicates a higher priority, and the server with a higher priority will attempt the link first.
  • TTL (time-to-live) : The TTL field indicates the duration (in seconds) for which the DNS resolver should cache MX records. When the specified TTL times out, the resolver queries the authoritative DNS server again and refreshes the record. In the diagram above, a TTL of 3600 means that MX records will be cached for one hour.

How to Lookup DNS MX Records?

We commonly use the nslookup tool to query DNS records. Nslookup is a command-line network administration tool used for querying the Domain Name System (DNS) to obtain domain name or IP address mapping information. It can be used to look up various types of DNS records, such as A (address) records, MX (mail exchange) records, and NS (name server) records. Nslookup is available on most operating systems, including Windows, macOS, and Linux. It is commonly used for troubleshooting DNS issues and verifying DNS configurations.

To lookup DNS MX records using nslookup, follow these steps:

1. Open a command prompt (Windows) or terminal (Mac and Linux).

2. Enter the following command format:

nslookup -type=mx example.com

3. Replace "example.com" with the domain name you are looking for.

4. Press Enter to execute the command.

Nslookup displays the result of the MX record. You will see one or more MX records, each containing the priority value and the domain name of the mail server.

For example, here is sample output from looking at an MX record for example.com using nslookup:

Server:  UnKnown
Address:  192.168.1.1

Non-authoritative answer:
example.com     MX preference = 10, mail exchanger = mail.example.com

In this example, the MX record shows a priority value of 10 and a mail server domain name of mail.example.com.

How to Set Up DNS MX Records?

To set up an MX record, you need to visit the control panel or administrative interface of your domain registrar or DNS hosting service provider. The exact steps may vary from service provider to service provider, but the following general process is usually followed:

1. Log into the control panel or administrative interface of your domain registrar or DNS hosting service provider. You may need to provide your account credentials.

2. Look for DNS administration or domain Settings options. This can usually be found in domain name management, DNS Settings, DNS administration, or similar sections.

3. In the MX Records section, you may see a list of existing MX records (if you already have MX records set). If there are no existing MX records, you will see a blank MX record table or a button to add MX records.

4. When adding MX records, you need to provide the following information:

  • Hostname: Specifies the domain name of the mail server. It can be a fully qualified domain name (for example, mail.example.com) or a relative domain name (for example, mail) relative to the current domain.
  • Priority: Specifies the priority order of mail servers. A lower value indicates a higher priority.

5. After entering the full MX record information, save or apply the changes.

6. Wait for DNS records to propagate. Typically, changes to DNS records take some time to take effect globally, a process known as DNS propagation. In general, this process can take anywhere from a few minutes to a few hours.

Please note that the exact setup process may vary by service provider. If you are having difficulty or are unsure how to set up MX records, refer to your service provider's documentation or contact their support team for assistance.

How to Set Load Balancing for DNS MX Records?

To set up load balancing for DNS MX records, you can use the following methods:

  1. Add multiple MX records: On the DNS management page, add multiple MX records for the same domain name. Each record corresponds to a mail server. Set different priority values. A lower value indicates a higher priority. In this way, when sending mail, mail clients will attempt to connect to these mail servers in order of priority to achieve load balancing.

For example:

example.com.    IN    MX    10    mail1.example.com.
example.com.    IN    MX    20    mail2.example.com.
example.com.    IN    MX    30    mail3.example.com.

In this example, there are three MX records, one for three different mail servers. Priority values of 10, 20, and 30 indicate that mail1.example.com has the highest priority, and mail3.example.com has the lowest priority.

  1. Set the same priority: If you want your mail traffic to be evenly distributed among multiple mail servers, you can set the same priority value for them. In this way, the mail client randomly selects one of the mail servers to send mail to achieve load balancing.

For example:

example.com.    IN    MX    10    mail1.example.com.
example.com.    IN    MX    10    mail2.example.com.
example.com.    IN    MX    10    mail3.example.com.

In this example, the three MX records have the same priority value of 10, and the mail client will randomly select one of the mail servers to send the mail.

Why are DNS MX Records Important?

DNS MX records play several key roles in the email system:

  • Mail routing: The MX record specifies the mail server that receives E-mail for a specific domain name. When you send an email, the mail client looks for the MX record of the target domain to determine which mail server the message should be delivered to. MX records ensure that messages are correctly routed to the target mail server, enabling reliable email delivery.
  • Priority control: Priority values in MX records allow you to specify the priority order of multiple mail servers. A lower value indicates a higher priority. The mail client will attempt to connect to the mail servers in the MX record, in order of priority, until the message is successfully sent or all servers are tried. This allows you to set up an alternate mail server to receive and process email when the primary server is not available.
  • Mail delivery Control: By modifying MX records, you can change how mail traffic is routed and distributed. For example, you can point MX records to different mail servers for load balancing or to distribute mail traffic to different geographic locations. This allows you to adapt the performance and reliability of your mail system to your needs.
  • Prevent spam: MX records can also be used to prevent spam. By setting MX records correctly, you can specify that only emails will be accepted from specific mail servers. This can help filter out spam and malicious mail and improve the security and reliability of your email system.

Conclusion

In summary, DNS MX records play a critical role in the email system, ensuring that messages are correctly routed and delivered to the target mail server, and providing flexible control and configuration options to meet different needs and scenarios.

If your platform needs to quickly and securely distribute content to customers worldwide, we invite you to use Tencent EdgeOne .

Tencent EdgeOne can provide integrated analysis, acceleration and security services for your site. With an extensive network of edge servers worldwide, Tencent EdgeOne ensures low latency and high-speed content delivery, no matter where they are located. The platform integrates advanced security features such as DDoS protection, SSL encryption, and access control to keep your content safe.

We have a free trial available now, please contact us for more information.