6

I've been reading this: http://www.zytrax.com/books/dns/ch8/mx.html

For MX records, and I've setup my nameserver via bind. Here is my zonefile for my website:

$TTL 86400
@   IN  SOA     ns1 root (
        2           ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)
; Specify our two nameservers
        IN  NS      ns1
        IN  NS      ns2

; Nameserver resolve
ns1     IN  A       1.1.1.1
ns2     IN  A       2.2.2.2

; Mail server
        IN  MX 10   mail

; Hostnames
@       IN  A       2.2.2.2
www     IN  A       2.2.2.2
mail    IN  A       1.1.1.1

I am hosting postfix and dovecot. I am unable to receive emails remotely and I've narrowed it down to my DNS not responding correctly on MX requests.

Dovecot and postfix are both hosted on 1.1.1.1 (I've changed my server IP)

After changing my config and restarting bind,

dig example.com MX @localhost 

EDIT: I've tried both mail.example.com and example.com. Both failed. I've updated this question for example.com as I initially posted the dig for mail.example.com (this was an error on my part. It has been updated, though.)

To which I receive,

;; QUESTION SECTION:
;example.com.              IN      MX

;; AUTHORITY SECTION:
example.com.            86400   IN      SOA     ns1.example.com. root.example.com

;; Query time: 0 msec
;; SERVER: ::1#53(::1)
;; WHEN: Thu Jul  3 15:29:40 2014
;; MSG SIZE  rcvd: 79

EDIT: Thought I'd include that everything else works fine. I.e. www.example.com

Jason
  • 163

3 Answers3

16

A really tricky configuration error. By starting a line with neither a hostname, the zone name or the @ shorthand for the zone origin, becomes a continuation of the record above.

ns2     IN  A       2.2.2.2
; Mail server
        IN  MX 10   mail.example.com.

is actually

ns2     IN  A       2.2.2.2
; Mail server
ns2     IN  MX 10   mail.example.com.

and not what you intended:

ns2     IN  A       2.2.2.2
; Mail server
example.com.      IN  MX 10   mail.example.com.

or alternatively you should have used:

@      IN  MX 10   mail.example.com.    
HBruijn
  • 84,206
  • 24
  • 145
  • 224
2

I think you're missing a dot. It should read

IN  MX 10   mail.example.com.

or

IN  MX 10   mail

Otherwise it will be relative to your zone, i.e. results in mail.example.com.example.com..

I'm not sure if this is really the problem but give it a try.

Mario Lenz
  • 1,632
  • 9
  • 13
1

If you don't change the serial number of your zone file, it will not update anything.

There is already a question on SF regarding the importance of serial number in DNS zone files: DNS records serial number


After re-reading your zone, I believe your MX is not properly "declared".

it should read

example.com. MX 10 mail.example.com.
Alex
  • 3,129
  • 23
  • 28