Overview
A multi-server install for MailEssentials becomes necessary if your environment has multiple mail servers that are geographically distributed, with all requiring anti-spam and email protection. Multiple email servers are also deployed in organizations that are sending and receiving a large number of emails in order to cope with the overload and avoid queues and delays in the delivery of email.
When using multiple mail servers, you would need to route inbound emails to the various mail servers in a way that the servers process roughly the same volume of emails, thus load balancing the mail servers.
This article describes how load balancing can be achieved using DNS MX records. The steps provided are also applicable when load balancing incoming emails in a Multi-Server environment.
Information
The following are two possible ways used to load balance mail servers using DNS:
- Define multiple MX records with the same priority
- Define multiple A records with the same name and different IP addresses
MX records, DNS and how emails are routed
A Mail Exchanger (MX) record is a type of resource record in the Domain Name System (DNS) specifying how Internet e-mail should be routed using the Simple Mail Transfer Protocol (SMTP). DNS provides a lookup of domain names to IP addresses. An MX record is a type of DNS record that identifies the IP address(es) responsible for a particular domain.
The MX record will usually return the Fully Qualified Domain Name (FQDN) of the mail server(s). For example, when you query for the MX records of gfi.com, you will get 2 FQDNs msrv1.gfi.com and msrv2.gfi.com. DNS then translates the FQDNs to an IP address which the sending mail servers use when sending emails.
The rest of the article will provide information on how to achieve the load balancing for inbound emails. You only need to apply one of the solutions mentioned below, which assumes that you are load balancing 2 mail servers. The same steps apply if the number of mail servers is more than two.
Option 1: Define multiple MX records with the same priority
In this case, you will be defining 2 MX records with an equal value. This is illustrated in the example provided below.
The example shows that the two records have an equal MX Preference of 10. When using this method, the DNS server will return both MX records and their respective associated IP addresses. You may need to check how to configure your DNS server to provide the IP addresses in random order. The sending email server then selects one IP address based on this algorithm and uses it to deliver the mail.
Record FQDN | Record Type | MX Preference | Record Value |
yourdomain.com | MX | 10 | mail1.yourdomain.com |
yourdomain.com | MX | 10 | mail2.yourdomain.com |
(IP addresses resolved below)
mail1.yourdomain.com A 10.0.0.1
mail2.yourdomain.com A 10.0.0.2
Option 2: Define multiple A records with the same name and different IP addresses
When using the second method, the IP addresses of your mail servers are defined in A records with the same name. This can be configured when MailEssentials is running on the SMTP gateway or multiple relay perimeter servers in a Multi-Server setup. The A record is then configured as the FQDN in the MX record. The sending mail server will then send the email to the first IP address in the list. You may need to check how to configure your DNS server to provide the IP addresses in random order.
Record FQDN | Record Type | MX Preference | Record Value |
yourdomain.com | MX | 10 | mail.yourdomain.com |
yourdomain.com | MX | 10 | mail.yourdomain.com |
mail.yourdomain.com A 10.0.0.1
A 10.0.0.2
Related Articles