Linux – Fixing Bind Zone Error: Unexpected End of Input

bindlinuxUbuntu

Everyting seems OK but I get Unexpected end of input for this:

$TTL    10800
@       IN      SOA     ns1.riddimdub.com.
admin.radiohost.riddimdub.com. (
        1        ; Serial
        10800       ; Refresh after 3 hours
        3600       ; Retry after 1 hour
        604800       ; Expire after 1 week
        3600 )     ; Negative caching TTL of 1 day
@       IN      NS      ns1.riddimdub.com.
@       IN      NS      ns2.riddimdub.com.
radiohost.riddimdub.com.        IN       MX     10      radiohost.riddimdub.com.
radiohost.riddimdub.com.        IN      A       185.40.20.124
ns1     IN      A       185.40.20.124
ns2     IN      A       185.40.20.124
www     IN      CNAME   radiohost.riddimdub.com.
mail    IN      A       185.40.20.124
ftp     IN      CNAME   radiohost.riddimdub.com.

I also get Unexpected RR type 10800.

What could be the problem?

Best Answer

As a human, I can identify this part of the file as what is supposed to be the SOA record:

@       IN      SOA     ns1.riddimdub.com.
admin.radiohost.riddimdub.com. (
        1        ; Serial
        10800       ; Refresh after 3 hours
        3600       ; Retry after 1 hour
        604800       ; Expire after 1 week
        3600 )     ; Negative caching TTL of 1 day

But that is not how the above actually means if these lines are parsed properly.

The problems

Since the master file format uses line breaks as the separator between records*, the line break after the first field of record data means that this is supposed to be the SOA record:

 @       IN      SOA     ns1.riddimdub.com.

*) With the exception that one can get fancy and use parenthesis (( )) in order to format a single record in ways that span multiple lines (purely for style/human readability reasons).

Since a SOA record must have seven fields of record data, but this supposed SOA record only has one field, you get an "unexpected end of input" error.
(I fully expect that the original error message also referenced the line number where this occurred.)

Next up, you get a secondary failure when what should have been the rest of the SOA record data starts on the next line and is treated as the next record.
There you used parenthesis, so that whole bit is read as a single record split across multiple lines.

That supposed "next record" is then interpreted like this:

admin.radiohost.riddimdub.com.    1            10800     ...
^                                 ^            ^
owner name                        ttl          "must be the record type, I guess"?!

Which leads to the "unknown RR type 10800" error message.
This error is not all that relevant, it will go away as soon as you fix the first problem, which left half a SOA record worth of stuff floating around in the wrong context.

The fix

There are multiple ways of writing this:

Simplest (uses no fancy syntax, may be the most intuitive as to what the SOA record actually consists of):

@       IN      SOA     ns1.riddimdub.com. admin.radiohost.riddimdub.com. 1 10800 3600 604800 3600

Quite common multi-line formatting, to make space for annotating the serial and timers:

@       IN      SOA     ns1.riddimdub.com. admin.radiohost.riddimdub.com. (
        1        ; Serial
        10800    ; Refresh after 3 hours
        3600     ; Retry after 1 hour
        604800   ; Expire after 1 week
        3600 )   ; Negative caching TTL of 1 hour

Another option, if you want to annotate everything:

@       IN      SOA     ns1.riddimdub.com. ( ; Mname (master nameserver)
        admin.radiohost.riddimdub.com. ; Rname (email address)
        1        ; Serial
        10800    ; Refresh after 3 hours
        3600     ; Retry after 1 hour
        604800   ; Expire after 1 week
        3600 )   ; Negative caching TTL of 1 hour

Do note how you either write the fields of the record on the same line (typical way of writing records), or you have to use parenthesis to specify how you have split the record across multiple lines.