Add DNS MX records for secondary mail servers? option not working

Hi,

I'm using Virtualmin 4.03 Pro and CentOS 6.4.

I've setup a secondary mail server and I've defined the MX record in the template's BIND section so I checked No in the Add DNS MX records for secondary mail servers? option. But when I create a new virtual server a line with the MX record and priority 10 is still added to the end of the BIND zone file. If I forget to delete it the mail is bounced in the secondary mail server with the error "mail for domain loops back to myself". What can I do?

By the way, I've got a problem too with the Validate MX records for domains with email? My primary MX mail server isn't the Virtualmin server so I selected No, but then the warning "This domain has email enabled, but none of the MX records..." appears. If I select Yes, then the warning goes away. Any idea?

Thanks in advance.

-Robert

Status: 
Closed (fixed)

Comments

Was the MX that was added for the Virtualmin system itself, or one of the secondary MXs?

It added the secondary MX record.

Can you check that in the file /etc/webmin/virtual-server/config, the line secmx_nodns=1 appears?

That is supposed to disable creation of MX entries for secondary DNS servers.

Sorry for the delay.

I checked the file and that line appears as you mentioned.

Thanks. Could you create a new test domain and then post the complete BIND zone file here? I'd like to see the exact ordering of the records.

I created testdomain.com and this is the BIND zone. As you can see I had to change the MX priorities in the template from 10,20 and 30 to 1,2 and 3 to avoid the MX loopback.

$TTL 2d
@ IN SOA dns1.tsc.es. hostmaster.tsc.es. (
2013110802
12h
1h
4W
3h )
;
;  Name servers
;
                IN      NS      dns1.tsc.es.
                IN      NS      dns2.tsc.es.
                IN      NS      pegaso.canal-alicante.com.
;
                IN      MX 1   antlia.tsc.es.
                IN      MX 2   perseo.tsc.es.
                IN      MX 3   hydra.tsc.es.
;
; SPF Records
;
                IN      TXT     "v=spf1 mx -all"
                IN      SPF     "v=spf1 mx -all"
;
; zone records
;
;
@               IN      A       195.57.58.70
www             IN      A       195.57.58.70
mail            IN      A       195.57.58.70
ftp             IN      A       195.57.58.70
smtp            IN      A       195.57.58.70
pop3            IN      A       195.57.58.70
imap            IN      A       195.57.58.70
admin           IN      A       195.57.58.70
webmail         IN      A       195.57.58.70
testdomain.com. IN MX 10 perseo.tsc.es.
autoconfig.testdomain.com. IN A 195.57.58.70

Ok, it looks like those MX records aren't in the format that Virtualmin creates. Do you have any custom records set at System Settings -> Server Templates -> Default Settings -> BIND DNS Domain ?

Well, yes. I read the BIND DNS book long time ago so I set the records in my Default Template like they were shown in that book.

$TTL 2d
@       IN      SOA     dns1.tsc.es. hostmaster.tsc.es. (
                        ${CURRENT_YEAR}${CURRENT_MONTH}${CURRENT_DAY}01 ; serial YYYYMMDDnn
                        12h        ; refresh = 12 hours
                        1h         ; retry   =  1 hour
                        4W         ; expire  =  4 weeks
                        3h         ; minimum =  3 hours
                        )
;
;  Name servers
;
                IN      NS      dns1.tsc.es.
                IN      NS      dns2.tsc.es.
                IN      NS      pegaso.canal-alicante.com.
;
                IN      MX 1   antlia.tsc.es.
                IN      MX 2   perseo.tsc.es.
                IN      MX 3   hydra.tsc.es.
;
; SPF Records
;
                IN      TXT     "v=spf1 mx -all"
                IN      SPF     "v=spf1 mx -all"
;
; zone records
;
;
@               IN      A       195.57.58.70
www             IN      A       195.57.58.70
mail            IN      A       195.57.58.70
ftp             IN      A       195.57.58.70
smtp            IN      A       195.57.58.70
pop3            IN      A       195.57.58.70
imap            IN      A       195.57.58.70
admin           IN      A       195.57.58.70
webmail         IN      A       195.57.58.70

Ok, so that's where the MX records are coming from.

You should just leave that field empty, and Virtualmin will create the correct records for your domain, including the MXs that are appropriate.

Thanks for your answer, but I can't leave it empty because I'm using a frontend machine to filter all the email that comes in and out of our servers. The primary MX relays all the email to the Virtualmin host in the backend. If I let Virtualmin create all the records it will add itself as the first MX bypassing the filtering host.

It was all working very well untiI I decided to add a secondary mail server. I configured it in "Addresses and Networking" | "Secondary Mail Servers" then I added the new MX record in the BIND DNS default template. The problem came out when I set up the "Add DNS MX records for secondary mail servers?" option to No. I think It doesn't work as expected because even though I selected "No" it still adds automatically the secondary MX record in the dns zone when I create a new domain.

Sorry if I didn't explained it clearly in my previous posts.

Ok, now I understand better .. your template actually seems fine then.

I am mystifies as to where that priority 10 MX record is coming from, as it should be blocked if secmx_nodns=1 is set. Is there any chance I could login to your system myself to see what is going wrong here?

Of course.

I activated the "Remote Login Privileges" and it send to you the keys, but I forgot to write a comment about what thread it was referred to. You'll see in the message that the server is hydra.tsc.es.

Thanks for the login. I just created a test domain on your system with the command :

virtualmin create-domain --domain jamietest.com --dir --unix --dns --pass smeg

and the only MX records that were added were the ones from the template.

You're right. I made another test and If you add the --mail option when creating the domain then it adds the line with the secondary MX record. Try:

virtualmin create-domain --domain jamietest.com --dir --unix --dns --mail --pass smeg

Ok, I see the cause of this bug now - it will be fixed in the next Virtualmin release.

Automatically closed -- issue fixed for 2 weeks with no activity.