Mail does not work, when virtual server is created on different IP

I use Google Apps for all my domains and have configured Virtualmin to automatically create host name records like for example (domain names and IPs are modified):

$ttl 38400 @ IN SOA host.mydomain.org. root.host.mydomain.org. ( 1296263686 10800 3600 604800 38400 ) anydomain.net. IN A 204.211.212.190 www.anydomain.net. IN A 204.211.212.190 mail.anydomain.net IN A ghs.google.com. @ IN NS ns1.mydomain.org. @ IN NS ns2.mydomain.org. @ MX 1 ASPMX.L.GOOGLE.COM. @ MX 5 ALT1.ASPMX.L.GOOGLE.COM. @ MX 5 ALT2.ASPMX.L.GOOGLE.COM. @ MX 10 ASPMX2.GOOGLEMAIL.COM. @ MX 10 ASPMX3.GOOGLEMAIL.COM. @ MX 10 ASPMX4.GOOGLEMAIL.COM. @ MX 10 ASPMX5.GOOGLEMAIL.COM.

and everything works just fine. However, when I create virtual server using one of 4 other IPs bound to my server, then above mentioned settings for mail system do not take effect, mails are just do not work despite the fact that domain name is resolved fine and the website is available online.

So, when virtual server is created for 204.211.212.190 then website and e-mails work fine.
But when virtual server is created for 204.211.212.193 then website works, e-mails do not work.

What other configurations are missing in my case? What could be the reason of this problem?

Two things that strike me: You have a fixed IP in your BIND template. When creating a vserver for another IP, it’ll still get the .190 in its zone file. I guess you’d rather want ${IP} instead of the fixed one?

Then, the line “mail.anydomain.net IN A ghs.google.com.” is incorrect. “A” means “address”, as in IP address. If you wish to map a hostname to another hostname, the record type needs to be “CNAME”.

Thanks for noting about CNAME, of course you are right and I have replaced A with CNAME. But this one is just for redirecting mail.anydomain.com to gmail.com/a/anydomain.com and should not effect functionality of mail system.

So, following your first advice, I examined /etc/named.conf (if it is the right file to look at) and found out only two specific records in the very beginning of the file like:

options {
directory “/etc”;
pid-file “/var/run/named/named.pid”;
allow-recursion { localnets; 127.0.0.1; };
};

zone “.” {
type hint;
file “/etc/db.cache”;
};

and lots of records for each of the virtual servers like:

zone "oneofmydomains.net" { type master; file "/var/named/oneofmydomains.net.hosts"; allow-transfer { 127.0.0.1; localnets; }; };

and nothing else. Where I can set ${IP} instead of the fixed one, if I have fixed one?

Another guess, I use APF, could it be a reason?

Well, you wrote that you have Virtualmin to “automatically create host name records”, I was assuming that you use Server Templates for that? :slight_smile:

Under System Settings -> Server Templates -> BIND DNS Domain you can enter the records you wish created for new domains, and in that template, you write

anydomain.net. IN A ${IP} www.anydomain.net. IN A ${IP}

instead of putting the fixed IP address there. That should result in the correct IP address for domains you create with a different one than your main one.