XMailforum is a readonly knowledge archive now.

Registering as a new user or answering posts is not possible anymore.

Might the force be with you, to find here what you are looking for.

2019-09-20 - hschneider, Admin

Cookie Disclaimer: This forum uses only essential, anonymous session cookies (xmailforum*), nothing to be scared of.

XMail Forum [Powered by Invision Power Board]
Printable Version of Topic
Click here to view this topic in its original format
XMail Forum > Documentation and Knowledge Base > Backup MX setup


Posted by: catfish Feb 19 2004, 05:23 AM
I have a friend who needed someone to host his backup (seconary) mail server. Since I've been running an xmail server without a second mx also we agreed to run each other's backup.

I'm running XMail 1.17 under Win2k Pro.
My domain is halfdone.com and the email server is mail.halfdone.com
Lets say his domains are Friend.com and Buddy.com with same email server
MX set to mail1.friend.com.

If I'm reading the Linux Beginner's Guild and these forums right I just need to make these additions to my current setup:

1. Create a new custDomain (for his email)
2. Setup a new MX record (for my email)

My question is with part 1, when do I use the domain and when do I use the server dns name?

The linux guide has:
CtrlClnt -s myserver.mydomain.org -u postmaster -p ciao custdomset customdomain.org
"smtprelay" [Tab] "customdomain.org" [Return]

and another post here says:
Under custdomains directory create a mx1.client.com.tab file with following lines in it:
"smtprelay"[TAB]"server"[NEWLINE]


Now using CtrlClnt am I suppost to do custdomset friend.com, or custdomset mail1.friend.com?
On the "smtprelay" line am I suppost to use friend.com or mail1.friend.com?
Do I need to take into account both of those domains?


Also is there an easy why to test this kinda setup without actually taking down my server? Like tring to email the backup server directly?

Thanks.

Posted by: hschneider Feb 19 2004, 09:35 AM
>My question is with part 1, when do I use the domain and when do I use the server dns name?

For custdomains you'll need the domain name, since XMail checks the incoming email address here.

>Now using CtrlClnt am I suppost to do custdomset friend.com, or custdomset mail1.friend.com?

friend.com

>On the "smtprelay" line am I suppost to use friend.com or mail1.friend.com?

mail1.friend.com, because the target is the mailserver's address.
friend.com _should_ also work, since the domain's MX record is looked up.

>Do I need to take into account both of those domains?
You mean 2 smtprelay entries ? No ...

>Also is there an easy why to test this kinda setup without actually taking down my server? Like tring to email the backup server directly?

>Also is there an easy why to test this kinda setup without actually taking down my server? Like tring to email the backup server directly?
Sure - just send a mail to his IP address @xxx.xxx.xxx.xxx or connect by telnet xxx.xxx.xxx.xxx 25 and paste a SMTP conversation, you prepared before (or type it live)

Posted by: catfish Feb 20 2004, 06:15 PM
>>On the "smtprelay" line am I suppost to use friend.com or mail1.friend.com?
>mail1.friend.com, because the target is the mailserver's address.
>friend.com _should_ also work, since the domain's MX record is
>looked up.

Would I not want it to look up MX since it would loop back to me?

>>Do I need to take into account both of those domains?
You mean 2 smtprelay entries ? No ...

Well how about 2 custdomains then?

I assume I need to do:

CtrlClnt -s localhost -u user -p pass custdomset friend.com
"smtprelay" [Tab] "mail1.friend.com" [Return]
[Ctrl-C]

CtrlClnt -s localhost -u user -p pass custdomset buddy.com
"smtprelay" [Tab] "mail1.friend.com" [Return]
[Ctrl-C]

It would then create 2 files in the custdomains directory called and contains:
friend.com.tab
"smtprelay" [Tab] "mail1.friend.com"

buddy.com.tab
"smtprelay" [Tab] "mail1.friend.com"

Posted by: hschneider Feb 20 2004, 08:20 PM
Sorry ... I've overread the 2 domains. Yes - in this case let 2 custdomains point to the same target.

Posted by: catfish Feb 22 2004, 05:13 AM
Thanks, another thing that is coming up is that now, I'm getting his bounced spam messages to non existant accounts. I don't think he's running xmail so I'll have to bug him about it but I'm wondering how xmail would handle it. Right now I have a "catch all" *@halfdone.com so it would never bounce but what if I dropped that? Would the same thing happen to him?

Just to make sure I understand what is happening, some spammer emails a nonexistant address sales@friend.com to my server. My server accepts anything at his domain. My server then emails the message to his server but his server yells at my server saying that the account doesn't exist so my server sends a message to postmaster about it.

Does xmail do the same thing?
Is there a way to filter this? perhaps some filter/script that ignores error messages from his server? So far it's always been to sales@friend.com there a way to block that address completely?

Posted by: hschneider Feb 22 2004, 10:02 AM
If you drop the catchall entry, then XMail will also bounce messages to non existing users. You can filter the bouncing message by a script. Or, when you have a catchall account, you can fitler the message to non existing users also by a script.

Posted by: nickp Jun 28 2004, 01:39 PM
QUOTE (hschneider @ Feb 19 2004, 09:35 AM)


mail1.friend.com, because the target is the mailserver's address.
friend.com _should_ also work, since the domain's MX record is looked up.


I am setting up the exact same thing with my brother, both running XMail. The fact that XMail looks up MX records for smtprelay is a bit worrying. I backup Bro's domain, when his server is off, mail will be routed to me as the next priority MX record. If my XMail get's an email for Bro and looks up his domain's MX records, won't it try Bro find him offline then find itself as the backup? Seems like a great opportunity for a loop.

Nick

Posted by: hschneider Jun 28 2004, 07:25 PM
Setting your bro's domain as an aliasdomain on your machine should prevent loops.

Posted by: svenvg Jun 30 2004, 10:23 AM
Hi,

I'm following this Topic with great interest, as I was using backup MX, and I had to disable it because of continueos mail loops...

I have the Altaircom auto sync tool installed (so if 1 MX has created some new domain, the backup automatically adds this to it's custdomains).

this is how I had the DNS entries:
domain1.com IN MX 10 mx1.domain1.com
domain1.com IN MX 50 domain2.domain2.com
mx1.domain1.com IN A 1.2.3.4

and domain2.domain2.com resolves to the right address (eg. 5.6.7.8)

I have in my custdomain folder a file domain2.com.tab containing only:
"smtp" [NEWLINE] (what the sync program put there automatically)

Result: primary goed down: mail gets delivered to the secondary, that accepts the mail, then opens a connection to the primary, its not available, looks up the DNS MX entry, finds itself as the secondary, opens a conection to itself, deliveres the mail, etc, like 15 times until the maill loop prevention kicks in and stops the loop...
(BTW, when the mail gets deleted by mail loop detection, does the original sender receives a bounce?)

Now Harald, you say add the domain as an aliasdomain, but alias to what domain??? The documentation on alias domain says:
"aliasdomain"[TAB]"realdomain"[NEWLINE]

so I have to setup the domain2.com as alias to domain1.com?? I don't understand, this would try to deliver everything to the local domain, no? let's say I have on both domains info account, would the mail for info@domain2.com not be delivered to info@domain1.com ??

Or should I use "smtprelay"[TAB]"server:port"[NEWLINE] rather then "smtp"[NEWLINE] (but then the sync doesn't work anymore....)

thanks,
Sven.

Posted by: hschneider Jun 30 2004, 10:38 AM
Setting the aliasdomain prevents XMail to lookup the MX, sending looping mails to itself. The real domain is an existing domain on the local machine, the alias is the domain of the machine, which is down.

When a loop stops, no notification is sent, because it would produce anotehr loop.

Up to now, there exists no backup MX howto. If you (or any others out there) manage a working setup, please post!


Posted by: svenvg Jun 30 2004, 12:01 PM
What if we play with the hosts file in Win32 (c:\winnt\system32\drivers\etc\)??? I don't know how Xmail does the DNS lookups, is it using windows lookup system for that or has it something of its own inside? I mean, all domains inside the hosts file have prio in windows over DNS lookup...
It's eg the hosts file that contains the localhost --> 127.0.0.1

If you put let's say yahoo.com 127.0.0.1 in the hosts file, and you ping to yahoo.com, the ping will go to 127.0.0.1 and not to the real address, because there will be NO DNS lookup... (same with Internet Explorer)

So, what if I put in the hosts file of the backup domain1.com and point it to the real IP? Will Xmail resolve via windows that IP address only? or will Xmail still go to DNS and find the MX 50 entry (Itself).
If not this would be a solution, because the secondary server would like this never find itself in the lookup, but only the primary it's IP (should be static of course)

thanks for your input
Sven.

Posted by: atomant Jun 30 2004, 12:55 PM
Xmail looks at the DNS servers in the dnsroots file. By default, this file looks like this:
CODE
a.root-servers.net.
h.root-servers.net.
c.root-servers.net.
g.root-servers.net.
f.root-servers.net.
b.root-servers.net.
j.root-servers.net.
k.root-servers.net.
l.root-servers.net.
m.root-servers.net.
i.root-servers.net.
e.root-servers.net.
d.root-servers.net.


But here you can put your own dns servers and delete all others.

Posted by: nickp Jul 2 2004, 06:25 PM
QUOTE (svenvg @ Jun 30 2004, 12:01 PM)
What if we play with the hosts file in Win32 (c:\winnt\system32\drivers\etc\)??? I don't know how Xmail does the DNS lookups, is it using windows lookup system for that or has it something of its own inside? I mean, all domains inside the hosts file have prio in windows over DNS lookup...
It's eg the hosts file that contains the localhost --> 127.0.0.1

If you put let's say yahoo.com 127.0.0.1 in the hosts file, and you ping to yahoo.com, the ping will go to 127.0.0.1 and not to the real address, because there will be NO DNS lookup... (same with Internet Explorer)

So, what if I put in the hosts file of the backup domain1.com and point it to the real IP? Will Xmail resolve via windows that IP address only? or will Xmail still go to DNS and find the MX 50 entry (Itself).
If not this would be a solution, because the secondary server would like this never find itself in the lookup, but only the primary it's IP (should be static of course)

thanks for your input
Sven.

Interestingly thats exactly what other mail servers suggest you do to prevent loops.

Posted by: nickp Jul 2 2004, 06:30 PM
QUOTE (atomant @ Jun 30 2004, 12:55 PM)
Xmail looks at the DNS servers in the dnsroots file. By default, this file looks like this:
CODE
a.root-servers.net.
h.root-servers.net.
c.root-servers.net.
g.root-servers.net.
f.root-servers.net.
b.root-servers.net.
j.root-servers.net.
k.root-servers.net.
l.root-servers.net.
m.root-servers.net.
i.root-servers.net.
e.root-servers.net.
d.root-servers.net.


But here you can put your own dns servers and delete all others.

To use this:

Will xmail stop at the first DNS server that returns a match? or will it carry on down the list and eventually find the public server that has teh backup mx record in it.

Is this always used or will XMAIL use stuff in the hosts file first?

Thanks

Posted by: nickp Jul 2 2004, 06:39 PM
QUOTE (hschneider @ Jun 28 2004, 07:25 PM)
Setting your bro's domain as an aliasdomain on your machine should prevent loops.

Hmm but won't that mean the mail won't get delivered when the primary comes online. Worse it will get thrown away if teh mailboxes don't exist on my server?

Thanks

Posted by: hschneider Jul 3 2004, 07:24 AM
You just should give it a test run. It would be nice, if this topic could be cleared this way. There are many knowledge fragments flying around, but the complete solution is still missing.

>Worse it will get thrown away if the mailboxes don't exist on my server?

For this you'll need cmdaliases:

QUOTE

CMD ALIASES

   CmdAliases implement aliases that are handled only through commands and
   can be thought of as a user level implementation of custom domain
   processing commands. The command set is the same of the one that is
   described above ("Custom domain mail processing") and won't be explained
   again here.

   For every handled domain (listed inside 'domains.tab') a directory with
   the same domain name is created inside the 'cmdaliases' subdirectory.
   This directory is automatically created and removed when you add/remove
   domains through the CTRL protocol (or 'CtrlClnt').

   When a mail for 'USER@DOMAIN' is received by the server, the domain
   'DOMAIN' is to be handled locally, and the standard users/aliases lookup
   fails, a file named 'USER.tab' is searched inside
   '$MAIL_ROOT/cmdaliases/DOMAIN'. If such file is found, commands listed
   inside the file (whose format must follow the one described in the
   previous section) are executed by the server as a matter of mail message
   processing. An important thing to remember is that all domain and user
   names, when applied to the file system, must be lower case.

   The use of the command '[SMTP]' must be implemented with great care
   because it could create mail loops within the server.


Furthermore:
Use "smtprelay" instead of "smtp". This delivers its target(s) directly without using DNS lookups, which should solve the loop problem.

QUOTE

    [SMTPRELAY]
         "smtprelay"[TAB]"server[:port],server[:port],..."[NEWLINE]

        Send mail to the specified SMTP server list by trying the first, if
        that fails, the second and so on.

        Otherwise you can use this syntax:

         "smtprelay"[TAB]"#server[:port],server[:port],..."[NEWLINE]

        To have XMail random-select the order the specified relays.


Again:
If you or someone else manages to put these fragments together, a backup MX howto would be greatly appreciated.

Posted by: nickp Jul 3 2004, 06:43 PM
OK I have tested it and it works... no loops!

How to create a backup server

Assume
Domain name = MyDomain.com
Primary mailserver = mail.mydomain.com
backup mailserver = mail2.mydomain.com

1) Set up MX record for mydomain.com so that mail is delivered to the primary server in preference to the backup e.g.

mydomain.com. IN MX 10 mail.mydomain.com
mydomain.com. IN MX 20 mail2.mydomain.com

2) On the backup server, create a customdomain tab for MyDomain.com
name: MyDomain.com.tab
content: "smtprelay"<tab>"mail.mydomain.com"<newline>
image007.gif

Posted by: hschneider Jul 3 2004, 07:18 PM
Fine fine ... thank U! image008.gif


Posted by: svenvg Jul 6 2004, 10:28 AM
Great! ... or not?

Like I pointed out in one of the previous posts: this should do the trick, BUT with this the auto sync tool from Altaircom isn't working anymore.... and that is a pity, because if you are ISP like we are and you are hosting domains for your customers you have a lot of domains...

As I see it this can be overcome as long as you only have 2 servers, A primary one and a secondary one...

acording Xmail manual:
QUOTE
If a message that has as target domain of 'sub1.sub2.domain.net' arrives at the XMail server, 'AND' XMail does not have a real domain 'sub1.sub2.domain.net' inside its domain list, XMail decides if this domain gets a custom domain processing by trying to lookup:

sub1.sub2.domain.net.tab
.sub2.domain.net.tab
.domain.net.tab
.net.tab
.tab

inside the 'custdomains' directory.


So: I could make just the .tab file, meaning "all not local domains"...?

once you have more then 1 primary server for load balancing and 1 backup, then this will not work anymore...

just a thought..
Sven.

Posted by: hschneider Jul 6 2004, 10:46 AM
>BUT with this the auto sync tool from Altaircom isn't working anymore
Do you have closer infos about which config files are changed in which way by this tool ?

>So: I could make just the .tab file, meaning "all not local domains"...?
Yes!


Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)