3

I have a domain named example.com. I want to set two mail servers on this domain. The main purpose to set these mail servers is to have two different mail server, as if we have two different domains => so it is not one main server and the other one for backup.

An MX record for domain example.com is already existing (all mails sent to user@example.com are delivered to smtp.example.com), so we have

@   3600    IN  MX  1   smtp.example.com

The A records are set like this:

@   600 IN  A   12.12.12.12
smtp    3600    IN  A   13.13.13.13
relay   3600    IN  A   14.14.14.14</pre>

Can we add new MX records for the second mail server?

For example, we set up a new subdomain relay.example.com that points to our new mail server (at ip 14.14.14.14). So that all mail that are sent to user@relay.example.com will be sent to relay.example.com.

  • Are you asking if email to foo.example.com can be directed to, and received by, a different server from that which handles email to example.com? If so, the answer is yes. – MadHatter Sep 5 '14 at 10:10
  • @MadHatter For example if I send an email to user@relay.example.com it will be delivered to user at the relay.example.com(14.14.14.14) mail server, same thing for sending and receiving – meksof Sep 5 '14 at 10:18
  • @MadHatter I added a new MX record like this: relay 3600 IN MX 10 relay.example.com – meksof Sep 5 '14 at 10:22
  • @MadHatter But the problem here is when I send a mail from google for example to user@relay.example.com it will be delivered to smtp.example.com – meksof Sep 5 '14 at 10:24
3

This should do it:

@     3600 IN A    12.12.12.12    ; irrelevant for mail routing

@     3600 IN MX 1 smtp.example.com.
smtp  3600 IN A    13.13.13.13

relay 3600 IN MX 1 relay.example.com.
relay 3600 IN A    14.14.14.14

Notes:

  • The last MX record is not strictly required (according to the standards, if there is no MX record for a domain then its A record is tried as a fallback - but some MTAs might not like that)
  • Don't forget the terminating dot at then end of fully qualified records in your zonefile!

To avoid confusion, here a clarifying variant that would send all mail targeted at @subdom.example.com to the MTA relay.example.com:

subdom 3600 IN MX 1 relay.example.com.
relay  3600 IN A    14.14.14.14
  • Thx for your help, I have changed the subdomain, to avoid confusion and now it delivers mails from gmail user to user@subdom.example.com on the second mail server (relay.example.com) – meksof Sep 5 '14 at 10:59
  • Glad you got your answer, but it seems like we might've got there a lot quicker if you hadn't redacted the domain name in question. For future questions like this, please very seriously consider not redacting. – MadHatter Sep 5 '14 at 12:07
2

Of course, yes. A domain can have as many MX records (and thus, mail servers) as you wish. You can even set up priorities between them. For example, the MX records of the domain gmail.com are (you can get this a command host -t MX -v gmail.com):

gmail.com.              3547    IN      MX      5 gmail-smtp-in.l.google.com.
gmail.com.              3547    IN      MX      10 alt1.gmail-smtp-in.l.google.com.
gmail.com.              3547    IN      MX      20 alt2.gmail-smtp-in.l.google.com.
gmail.com.              3547    IN      MX      30 alt3.gmail-smtp-in.l.google.com.
gmail.com.              3547    IN      MX      40 alt4.gmail-smtp-in.l.google.com.

The outer mail servers trying to deliver mail to your domain are expected to follow the priorities in ascending order. Same priorities means redundancy (although it isn't really good on my experience).

In this example, the first try will be gmail-smtp-in.l.google.com., the second alt.gmail-smtp-in.l.google.com, and so on. The priorities are in before the last column.

Some similar can you set up in your domain. In your place I did it as a secondary mail server, for backup purposes if the first isn't really working.

  • thx for your help, but making a backup mail server is not my main purpose – meksof Sep 5 '14 at 11:00
  • @meksof Maybe you didn't read my answer enough carefully. ("Same priorities means redundancy") – peterh Sep 5 '14 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.