I'm configuring DNS server for the first time.

My hostname is: mail.example.com

I've added these into named.conf:

zone "example.com" IN {
    type master;
    file "example.com.forw.zone"
    allow-update {none;};

zone "1.10.in-addr.arpa" IN {
    type master;
    file "example.com.rev.zone"
    allow-update {none;};

In forward zone file, I've added these:

@       IN    NS      @
mail    IN    A
        IN    MX 1   mail.example.com

And if I want to add other mail servers from other domains, it gives me error after adding these lines into my forward zone file:

mail.branchcompany.com. IN A
     branchcompany.com  IN MX mail.branchcompany.com

What am I doing wrong? Error is: out of zone data branchcompany.com

  • 1
    1. you need a separate zone file for each domain - you can't put entries for branchcompany.com in a zone file for example.com. 2. it's been a while since I needed to look up the exact spec for an NS record, but I'm pretty sure that an @ on the right-hand-side of an NS record is wrong - there should be a hostname (fully-qualified, with a trailing .) on the RHS (you can't even use an IP address there). – cas Jan 17 '18 at 7:48
  • @cas, but I saw one configuration file that all domains are in one zone file – it dev Jan 17 '18 at 8:10
  • i've seen lots of things. doesn't mean they were right. or that i correctly understood what it was that i was seeing. – cas Jan 17 '18 at 8:17
  • @cas, no idea what you are talking about – it dev Jan 18 '18 at 4:02
  • You can put a parent domain and its sub-domains into one zone file if you want, but putting multiple unrelated domains into a single zone file will be rejected. Modern BIND is also more strict about zone file contents than older versions: if you saw something weird using an ancient BIND 4.x, it won't necessarily be acceptable for a modern BIND 9.x. – telcoM Mar 19 '18 at 13:08

If you want to specify mail.branchcompany.com as an alternate mail server for example.com (i.e. for email addresses of the form Some.Name@example.com), you can do it this way in the example.com zone file (all names written in explicit long form):

example.com. IN MX 1 mail.example.com.
example.com. IN MX 2 mail.branchcompany.com.

mail.example.com. IN A

The names in the left side of a DNS zone file must all be in the domain the zone file is for, or in one of its sub-domains. The right side can be anything.

If you refer to mail.branchcompany.com in the example.com zone file, then the mail.branchcompany.com name may only appear in the right side of the records.

You don't declare the IP address of mail.branchcompany.com in example.com zone file: all information about branchcompany.com names will be queried from the zone branchcompany.com, in the DNS servers authoritative for branchcompany.com. Such out-of-zone information in the example.com zone would only be used by the clients that have been configured to use this specific server as their resolver.

Also, since the example.com zone file is not necessarily accessible to the branchcompany.com DNS administrator, any branchcompany.com records in example.com zone file would be at risk of becoming out-of-sync with reality. That's why modern DNS servers will generally treat such out-of-zone records as errors.

Also, you should be very careful about the presence/absence of the trailing dot in DNS names in zone files. Your example

@       IN    NS      @
mail    IN    A
        IN    MX 1   mail.example.com

would (with the default $ORIGIN, also known as @, defined by the zone directive) expand to:

example.com.      IN NS example.com.
mail.example.com. IN A
mail.example.com. IN MX 1 mail.example.com.example.com.

Note the last line: since it did not have the trailing dot, the default origin gets appended.

Likewise, this line

branchcompany.com  IN MX 1 mail.branchcompany.com

would in the same zone file get interpreted like this:

branchcompany.com.example.com. IN MX 1 mail.branchcompany.com.example.com.

In other words, "email addresses of form Some.Name@branchcompany.com.example.com are handled by the mailserver mail.branchcompany.com.example.com". Most likely not what you meant!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.