The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MX Records, 2 servers...

Discussion in 'General Discussion' started by kiran, May 19, 2004.

  1. kiran

    kiran Member

    Joined:
    Apr 28, 2002
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Hi all,

    I wanted to point the MX record of my domain to the 2 servers.

    Actually my purpose is when the server1 is goes down, it has to automatically switch over to Server2.

    Is this possible if i enter the 2 MX records?

    Please give me an idea to use both the servers for Email purpose.

    Thanks,
    Kiran
     
  2. Izzee

    Izzee Well-Known Member

    Joined:
    Feb 6, 2004
    Messages:
    469
    Likes Received:
    0
    Trophy Points:
    16
    Edit your DNS Zone in WHM and enter your Mail Exchange records like this:

    yourdomain.com. 14000 IN MX 0 server1.com.
    yourdomain.com. 14000 IN MX 10 server2.com.

    The dots after the domain names must be included.
    Substitute your domain and server information.

    The number 0 (zero) denotes that this MX is primary and the number 10 denotes the first backup MX. So if the primary MX fails then the backup MX will take over and queue messages until your primary MX becomes available again.
    You can add more backup MXs by increasing the number to each backup MX ie. the next in line would be:
    yourdomain.com. 14000 IN MX 20 backupmx3.com.
    etc. etc. etc.

    Now to save you having to do this with each new account created add this info to the DNS Zone Templates in WHM.

    Is this what you wanted?
     
  3. kiran

    kiran Member

    Joined:
    Apr 28, 2002
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    HI Izzee,

    thanks for help.

    I'm using the Registrars DNS service. According to you i've going to create the MX records like below.

    First I'll create the "A" record for domain XYZ.com like.

    mail1.xyz.com = first servers IP Address.
    mail2.xyz.com = Second Servers IP address.

    After creating the "A" record in a "MX" record i'll enter,

    xyz.com. 14000 IN MX 0 mail1.xyz.com.
    xyz.com. 14000 IN MX 10 mail2.xyz.com.

    Is these settings are correct? or I've to add something?

    With Thanks,
    Kiran
     
  4. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    There is an additional step if you only want the mail queued on the backup MX server until the primary is back up. You should put the domain in question on the backup MX server into the file:
    /etc/secondarymx

    This tells Exim to queue the mail until the first server is back up.
     
  5. Valetia

    Valetia Well-Known Member

    Joined:
    Jun 20, 2002
    Messages:
    207
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Sorry if this is a silly question but does this mean there is no need at all to create a hosting account based on that domain, on the 2nd machine?

    Just pointing via the MX and adding the entry to /etc/secondarymx is sufficient?

    Do we use the main shared IP of the 2nd machine for the secondary MX, or would any IP on the 2nd machine do?

    Thanks! :)
     
    #5 Valetia, May 27, 2004
    Last edited: May 27, 2004
  6. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    That's correct, there is no need at all for an account on the second server if you just want a backup MX server incase the primary becomes unavailable for a while and then want the mails acrued on the secondary delivered to the primary.

    I believe that you can use any IP address for the MX record since exim, by default, listens on all of them.
     
  7. Valetia

    Valetia Well-Known Member

    Joined:
    Jun 20, 2002
    Messages:
    207
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Thanks! That's good to know.

    Earlier you had said this:

    When you mean there is an additional step that is needed for this particular scenario, what would be the other scenario (where this additional step is not needed)?

    In other words, if you were to just have the 2nd MX record but do not add the domain to /etc/secondarymx, what would happen and why would someone want to leave out that latter step?
     
  8. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    If you did not want the email simply to queue on the second server, but to actually be delivered to a local account, then you wouldn't put the domain into the secondarymx file and would create an account and make sure that the domain was in /etc/localdomains.

    However, this is not a great idea as mail could be delivered to the secondary MX record for all sorts of reasons and you would then have to check the accounts on boths servers continually for new mail rather than just on the primary.
     
  9. Valetia

    Valetia Well-Known Member

    Joined:
    Jun 20, 2002
    Messages:
    207
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    I see! :)

    If you were to put it in the queue on the secondary, what would be the interval between checks by the secondary to see if the primary is back up, and how would this interval be modified?
     
  10. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    It uses the intervals described at the bottom of the /etc/exim.conf file under RETRY CONFIGURATION have a read of the description in the comments of that section to understand the setting.
     
  11. alex042

    alex042 Well-Known Member

    Joined:
    Sep 13, 2003
    Messages:
    76
    Likes Received:
    0
    Trophy Points:
    6
    Any idea how this would work if the secondary mail server is a windows server running MailEnable and not EXIM?

    BTW, I thought the secondary mailserver required an account for that domain? What's to keep me from using john doe's mail server as a secondary mail server?
     
  12. Valetia

    Valetia Well-Known Member

    Joined:
    Jun 20, 2002
    Messages:
    207
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    I think Jonathan means that if you don't create an account on the secondary mailserver, then you would need to insert the domain into /etc/secondarymx instead (either one or the other is required, depending on whether you want it to queue or not).

    So if "john doe's" server isn't configured via either of the 2 methods, it can't be used as a secondary mailserver for your domain.
     
  13. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    What Valetia said ;)

    It doesn't matter at all if you use different MTA's (i.e. Exim and MailEnable) so long as they both support the concept of providing backup MX mail queuing.
     
  14. peruda.com

    peruda.com Well-Known Member

    Joined:
    Aug 23, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    Here's a question for y'all: What if you have accounts setup on the secondary server (in /etc/localdomains) AND also in the /etc/secondarymx - I know it sounds crazy, but in theory, would the mail be delivered to the existing accounts or to the secondary MX queue? Which one has priority; does it depend on the Exim config order?

    Thanks much!
     
  15. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Not 100% sure on that. I would guess that it would be delivered locally. All the secondarymx file does is add the doamins to the relay_domains list. This list also contains localdomains, so simply establishes for exim whether to accept the email for relaying. It then uses local_domains which is populated by localdomains for local delivery, otherwise it will simply relay the email (keept it in the queue and then release it to the primary when available).

    So, not much point in doing it IMHO ;)
     
  16. easyhoster1

    easyhoster1 Well-Known Member

    Joined:
    Sep 25, 2003
    Messages:
    659
    Likes Received:
    0
    Trophy Points:
    16
    This is not true, as the MX needs a qualified TLD. Keep in mind named based servers. ;)
     
  17. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Yes. Fair enough, I missed out a step, but the answer is true within the context of the questions asked - that you can use any IP address on the server for the eventual translation of the MX record :rolleyes:

    If you want to be pedantic, it doesn't need a "qualified TLD". You can use any A record that points to any IP address on the server. Name based servers have nothing whatever to do with it - that's apache speak :rolleyes:
     
  18. Brando

    Brando Member

    Joined:
    Nov 6, 2003
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Hi guys,

    I know this topic is a little old, but I'd just like to find out whether would there be any problem if the primary mx is actually an exchange server elsewhere while the cpanel account is supposed to be acting as a secondary mx. I've made the necessary DNS entries changes but when I test it out by sending an email to the domain, the email ends up on the 2nd mx eventhough the 1st mx is working fine.

    Thanks in advance for any kinda assistance. :)
     
  19. philb

    philb Well-Known Member

    Joined:
    Jan 28, 2004
    Messages:
    116
    Likes Received:
    0
    Trophy Points:
    16
    If it's /always/ winding up on the secondary mx there's something wrong with your primary and/or it's not accessible from the internet for some reason.

    If you have the account setup in CPanel the server will expect to handle email for that domain, and so will accept the mail for local delivery to users on the cpanel server as opposed to queuing it for delivery to the primary mx when the retry period(s) is/are reached. I'm not entirely sure how you'd go about adding a domain to a cpanel box without it expecting to handle the mail for it - not something I've looked into.
     
  20. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Not sure what you mean by "cPanel account" here and I'm not 100% sure that the cPanel exim configuration would allow what you want. You would certainly need to:

    1. Setup MX records for both servers with the high pointing to the cPanel server

    2. If the domain is hosted on the cPanel server (which I assume it is), then you must remove the domain from /etc/localdomains and put it into /etc/remotedomains and /etc/secondarymx

    What should then happen is that any email delivered to the secondary MX is queued in exim until such time as exim can contact the primary MX when it will be relayed on.

    You will always get some email delivered to your secondary MX for a couple of reasons:

    1. Some MUA's simply ignore multiple MX entries and deliver to the first one that resolves

    2. The route to the primary on the internet from the MUA is down or slow

    3. As philb says, there's a problem with your DNS configuration of the MX records
     
Loading...

Share This Page