Answer
When your organization is sending and receiving a large amount of emails, one might want to add multiple mail servers to cope with the overload and to avoid queues and delays in the delivery of email. When using multiple mail servers, you would need to route inbound emails to both mail servers in a way that both mail servers process roughly the same amount of emails, thus load balancing the mail servers.
The following are two possible ways used 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. MX records are a type of DNS record which identify 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 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.
Define multiple MX records with the same priorityIn 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 a random order. The sending email server then selects one IP address based on its 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
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. The A record is than 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 a 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
Priyanka Bhotika
Comments