chiark / gitweb /
* chiark-named-conf improvements:
[chiark-utils.git] / scripts / named-conf.8
1 .\" Hey, Emacs!  This is an -*- nroff -*- source file.
2 .TH CHIARK\-NAMED\-CONF 8 "12th January 2002" "Greenend" "chiark utilities"
3 .SH NAME
4 chiark\-named\-conf \- check and generate nameserver configuration
5 .SH SYNOPSIS
6 .BR chiark\-named\-conf " [\fIoptions\fP] " \-n | \-y | \-f
7 .br
8 \fBchiark\-named\-conf\fP [\fIoptions\fP] \fIzone ...\fP
9 .SH DESCRIPTION
10 .B chiark\-named\-conf
11 is a tool for managing nameserver configurations and checking for
12 suspected DNS problems.  Its main functions are to check that
13 delegations are appropriate and working, that secondary zones are
14 slaved from the right places, and to generate a configuration for
15 .BR BIND ,
16 from its own input file.
17
18 By default, for each zone, in addition to any warnings, the output
19 lists the zone's configuration type.  If the zone is checked, the
20 serial number at each of the nameservers is shown, with any
21 unpublished primary having
22 .B *
23 after the serial number.
24 .SH OPTIONS
25
26 .SS MODE OPTIONS
27 If one of the options
28 .BR -n ", " -y ", or " -f
29 is supplied then chiark-named-conf will read its main configuration
30 file for the list of relevant zones.  It will then check the
31 configuration and delegation for each zone
32 and/or generate and install a new configuration file for
33 the nameserver:
34 .TP
35 .BR \-y | \-\-yes
36 Generate and install new nameserver config, as well as checking
37 configuration, for all listed zones.
38 .TP
39 .BR \-n | \-\-no
40 Check configuration, for all listed zones, but
41 do not generate new nameserver config.
42 .TP
43 .BR \-f | \-\-force
44 Generate and install new nameserver config, without doing any
45 configuration cross-checking.  (Syntax errors in our input
46 configuration will still abort this operation.)
47 .TP
48 .BR \-\-nothing
49 Do nothing: do no checks, and don't write a new config.  This can be
50 used to get a list of the zones being processed.
51 .TP
52 .BR \-\-mail\-first " | " \-\-mail\-middle " | " \-\-mail\-final
53 Send mails to zone SOA MNAMEs reporting zones with problems.  You must
54 call chiark\-named\-conf at least twice, once with \-\-mail\-first,
55 and later with \-\-mail\-final, and preferably with one or more calls
56 to \-\-mail\-middle in between.  All three options carry out a check
57 and store the results; \-\-mail\-final also sends a mail to the zone
58 SOA MNAME or local administrator, if too many of the calls had errors
59 or warnings (calls before the most recent \-\-mail\-first being
60 ignored).
61 .TP
62 .B \-mail\-final\-test
63 just like \-\-mail\-final except that it always sends mail to the
64 local server admin and never to remote zone contacts, adding
65 .B (testing!)
66 to the start of the To: field.
67 .LP
68 Alternatively, one or more zone names may be supplied as arguments, in
69 which case their delegations will be checked, and compared with the
70 data for that zone in the main configuration (if any).  In this case
71 no new configuration file for the nameserver will be made.
72
73 .SS ADDITIONAL OPTIONS
74 .TP
75 .BR \-A | \-\-all
76 Checks even zones known to be broken.  Ie, ignores the
77 .B ?
78 zone style modifier in the configuration.
79 .TP
80 .BR \-C | \-\-config " \fIconfig\-file\fP"
81 Use
82 .I config\-file
83 instead of
84 .BR /etc/bind/chiark-conf-gen.zones .
85 Also changes the default directory.
86 .TP
87 .BR \-D
88 Enables debugging.  Useful for debugging chiark\-named\-conf, but
89 probably not useful for debugging your DNS configuration.  Repeat to
90 increase the debugging level.  (Maximum is
91 .BR -DD .)
92 .TP
93 .BR \-g | \-\-glueless
94 Do not warn about glueless referrals (strictly, makes the zone style
95 modifier
96 .B ~
97 the default).  Not recommended - see the section GLUELESSNESS, below.
98 .TP
99 .BR \-l | \-\-local
100 Only checks for mistakes which are the responsibility of the local
101 administrator (to fix or get fixed).  This means that for published
102 and stealth zones we only check that we're slaving from the right
103 place and that any names and addresses for ourself are right.  For
104 primary zones all checks are still done.  It is a mistake to specify
105 .B \-l
106 with foreign zones (zones supplied explictly on the command line but
107 not relevant to the local server); doing so produces a warning.
108 .TP
109 .BI \-m group !*$@~?
110 Overrides a
111 .B modifiers
112 directive in the configuration file.  The modifiers specified in the
113 directive are completely replaced by those specified in this command
114 line option.  (Note that modifiers specified in per-zone directives
115 still override these per-group settings.)  If more than one
116 .B modifiers
117 directive specifies the same group, they are all affected.
118 .B modifiers
119 directives which don't specify a group cannot be affected.  It is an
120 error if the group does not appear in the config file.  See ZONE STYLE
121 MODIFIERS, below.
122 .PP
123 The special group
124 .B foreign
125 is used for zones which don't appear in the configuration file.
126 .TP
127 .BR \-q | \-\-quiet
128 Suppress the usual report of the list of nameservers for each zone and
129 the serial number from each.  When specified twice, do not print any
130 information except warnings.
131 .TP
132 .BR \-r | \-\-repeat
133 When a problem is detected, warn for all sources of the same imperfect
134 data, rather than only the first we come across
135 .TP
136 .BR \-v | \-\-verbose
137 Print additional information about what is being checked, as we go
138 along.
139 .SH USAGE
140 The file
141 .B /etc/bind/chiark-conf-gen.zones
142 (or other file specified with the
143 .B \-C
144 option) contains a sequence of directives, one per line.  Blank lines
145 are permitted.  Leading and trailing whitespace on each line is
146 ignored.  Comments are lines starting with
147 .BR # .
148 Ending a line with a
149 .BR \\
150 joins it to the next line, so that long directives can be split across
151 several physical lines.
152 .SS GENERAL DIRECTIVES
153 These directives specify general configuration details.  They should
154 appear before directives specifying zones, as each will affect only
155 later zone directives.
156 .TP
157 \fBadmin\fP \fIemail\-address\fP
158 Specifies the email address of the local administrator.  This is used
159 in the From: line of mails sent out, and will also receive copies of
160 the reports.  There is no default.
161 .TP
162 \fBdefault\-dir\fP \fIdirectory\fP
163 Makes
164 .I directory
165 be the default directory (which affects the interpretation of
166 relative filenames).  The default is the directory containing
167 the main configuration file, ie
168 .BR /etc/bind
169 if no
170 .B -C
171 option is specified.
172 .TP
173 \fBforbid\-addr\fP [\fIip-address ...\fP]
174 Specifies the list of addresses that are forbidden as any nameserver
175 for any zone.  The default is no such addresses.
176 .TP
177 \fBforbid\-addr\fP [\fIip-address ...\fP]
178 Specifies the list of addresses that are forbidden as a nameserver
179 for a zone for which we are the primary - ie, the list of our old or
180 to-be-obsoleted slaves.  The default is no such addresses.
181 .TP
182 \fBserverless\-glueless\fP \fIdomain ...\fP
183 Specifies a list of domains under which we do not expect to find any
184 nameservers; for these zones it is OK to find glueless referrals.
185 Each domain listed names a complete subtree of the DNS, starting at
186 the named point.  The default is
187 .BR "in\-addr.arpa ip6.arpa ip6.int" .
188
189 To avoid indefinitely long or even circularly glueless referrals
190 (which delay or prevent lookups) it is necessary for all sites to
191 effectively implement similar conventions; currently the author
192 believes that only the reverse lookup namespaces are conventionally
193 devoid of nameservers, and therefore fine to provide glueless
194 referrals for.  See GLUELESSNESS below.
195 .TP
196 \fBallow-\-indirect\-glue\fP \fInameserver-superdomain ...\fP
197 Specifies a list of domains under which we expect to find glueless
198 nameservers, with up to one layer of indirection.
199 For nameservers under these domains it is OK to to find glueless
200 referrals, but only when listed as a nameserver for a zone which is
201 not itself a subdomain of an \fBallow-indirect-glue\fR
202 \fInameserver-superdomain\fR.
203
204 This supports to common configuration style where DNS operator(s) set
205 up all of their nameservers with names within a small subsection of
206 the DNS (the portions under \fInameserver-superdomain\fRs), and
207 provide glueless referrals naming these nameservers for all other
208 zones.  This provides at most one level of missing glue.
209
210 Note that if the DNS administrators collectively able to influence the
211 service for some zone (including the admins for its superzones, the
212 zones containing its nameservers, and their superzones and so forth)
213 are not in sufficiently close communication do not all agree on the
214 proper set of \fInameserver-superdomain\fR then they might still set
215 up circular glue and \fBchiark-named-conf\fR would not necessarily be
216 able to detect this even if it was run on every relevant nameserver.
217 .TP
218 \fBmail\-state\-dir\fP \fIdirectory\fP
219 Uses
220 .I directory
221 for storing information about recent failures for mailing to zone
222 admins.  See \-\-mail\-first et al.  Old files in here should be
223 cleaned up periodically out of cron.  There is no default.
224 .TP
225 \fBmail\-max\-warnfreq\fP \fIpercentage\fP
226 When \-\-mail\-final is used, a mail will be sent to all zones which
227 had warnings or errors more than
228 .IR percentage %
229 of the times \-\-mail\-* was used (since the last \-\-mail\-first).
230 The default is 50%.
231 .TP
232 .BR modifiers " " !*$@~? "] [\fIgroup\fP]"
233 Applies the specified zone style modifiers (see below) to subsequently
234 declared zones (until the next
235 .B modifiers
236 directive), as if the modifiers specified were written out for
237 each zone.  You must specify at least one character for the modifiers;
238 if you want to reset everything to the default, just say
239 .BR ! .
240 If style modifiers specified in the zone directive
241 conflict with the
242 .B modifiers
243 directive, those specified in the zone directive take effect.
244 .I group
245 may contain alphanumerics and underscores, and is used for the
246 .B -m
247 command-line option.
248 .TP
249 \fBself\-addr\fP \fIip-address ...\fP
250 Specifies the list of addresses that this server may be known by in
251 A records.  There is no default.
252 .TP
253 \fBoutput\fP \fIformat\fP \fIfilename\fP [\fIformat\fP \fIfilename ...\fP]
254 Arranges that each
255 .I filename
256 will be overwritten when
257 .BR -y " or " -f
258 are used; its new contents will be configuration
259 directives for the zones which follow for the
260 nameserver in question.  Currently the only
261 .I format
262 supported is
263 .B bind8
264 which indicates new-style BIND 8.  If no zones follow, then each
265 file will still be overwritten, by an effectively empty file.
266 Default: if there is no
267 .B output
268 directive in the configuration then the default is to use
269 .BR bind8 " " chiark-conf-gen.bind8 ;
270 otherwise it is an error for there to be any zones in the
271 configuration before the first
272 .B output
273 directive.
274 .TP
275 \fBself\-ns\fP \fIfqdn ...\fP
276 Specifies the list of names that this server may be known by in NS
277 records.  There is no default.  Any trailing * is replaced by the name
278 of the zone being checked, so for example
279 .B self\-ns isp.ns.*
280 before the zone example.com would mean to expect us to be listed as
281 isp.ns.example.com
282 in the NS RRset.
283 .TP
284 \fBself\-soa\fP \fIfqdn ...\fP
285 Specifies the list of names that this server may be known by in
286 the ORIGIN field of SOA records.  There is no default.  Any trailing
287 * is replaced by the name of the zone, as for
288 .BR self\-ns .
289 .TP
290 .BI self " fqdn ..."
291 Equivalent to both
292 .B self\-ns " and " self\-soa
293 with the same set of names.
294 .TP
295 \fBslave\-dir\fP \fIdirectory\fP [[\fIprefix\fP] \fIsuffix\fP]
296 Specifies the directory in which slave (published and stealth)
297 zonefiles should be placed.  The default
298 .I directory
299 is
300 .BR /var/cache/bind/chiark-slave .
301 The default
302 .IR suffix " and " prefix
303 are empty; they also will be reset to these defaults by a
304 .B slave\-dir
305 directive which does not specify them.
306 .SS ZONE DIRECTIVES
307 These directives specify one or more zones.
308 .TP
309 .BR primary [ !*$@~? "] \fIzone filename\fP"
310 Specifies that this server is supposed to be the primary nameserver
311 for
312 .I zone
313 and that the zone data is to be found in
314 .IR filename .
315 .TP
316 .BR primary\-dir [ !*$@~? "] \fIdirectory\fP[" / "\fIprefix\fP] [\fIsuffix\fP[" / \fIsubfile\fP]]
317 Search
318 .I directory
319 for files whose names start with
320 .I prefix
321 and end with
322 .IR suffix .
323 Each such file is taken to represent a zone file for which this server
324 is supposed to be the primary; the part of the filename between
325 .IR prefix " and " suffix
326 is the name of the zone.
327
328 If
329 .BI / subfile
330 is specified, then instead of looking for files, we search for
331 directories containing
332 .IR subfile ;
333 directories which do not contain the subfile are simply skipped.
334
335 If
336 .IR directory [\fB/\fP prefix ]
337 exists as specified and is a directory then it is interpreted as
338 .I directory
339 with an empty prefix; otherwise the final path component is assumed to
340 be the prefix.  If no
341 .IB suffix / subfile
342 is specified then the default is
343 .BR _db .
344 .TP
345 .BR published [ !*$@~? "] \fIzone origin\-addr\fP"
346 Specifies that this server is supposed to be a published slave
347 nameserver for the zone in question.
348 .TP
349 .BR stealth [ !*$@~? "] \fIzone server\-addr ...\fP"
350 Specifies that this server is supposed to be an unpublished secondary
351 (aka stealth secondary) for the zone in question.
352 .SS ZONE STYLE MODIFIERS
353 Each of the zone directives may optionally be followed by one or more
354 of the following characters (each at most once):
355 .TP
356 .B !
357 Reverses the meaning of all style modifiers after the
358 .BR ! .
359 Only one
360 .BR !
361 must appear in the modifier list.  In this list, other modifiers which
362 default to `enabled' are described by describing the effect of their
363 inverse - see the description for
364 .B !@
365 below.
366 .TP
367 .B *
368 Indicates that the zone is unofficial, ie that it is not delegated as
369 part of the global Internet DNS and that no attempt should be made to
370 find the superzone and check delegations.  Note that unofficial, local
371 zones should be created with caution.  They should be in parts of the
372 namespace which are reserved for private use, or belong to the actual
373 zone maintainer.
374 .TP
375 .B $
376 Indicates that any mails should be sent about the zone to the
377 nameserver admin rather than to the zone SOA MNAME.  This is the
378 default unless we are supposedly a published server for the zone.
379 .TP
380 .B !@
381 Indicates that no mails should be sent about the zone to anyone.
382 .TP
383 .B ~
384 Indicates that the zone's delegation is known to be glueless, and that
385 lack of glue should not be flagged.  Not recommended - see the section
386 GLUELESSNESS, below.
387 .TP
388 .B ?
389 Indicates that the zone is known to be broken and no checks should be
390 carried out on it, unless the
391 .B \-A
392 option is specified.
393 .SS OTHER DIRECTIVES
394 .TP
395 \fBinclude\fP \fIfile\fP
396 Reads
397 .I file
398 as if it were included here.
399 .TP
400 \fBend\fP
401 Ends processing of this file; any data beyond this point is ignored.
402 .SH CHECKS
403 chiark\-named\-conf makes the following checks:
404
405 Delegations: Each delegation from a server for the superzone should
406 contain the same set of nameservers.  None of the delegations should
407 lack glue.  The glue addresses should be the same in each delegation,
408 and agree with the local default nameserver.
409
410 Delegated servers: Each server mentioned in the delegation should have
411 the same SOA record (and obviously, should be authoritative).
412
413 All published nameservers - including delegated servers and servers
414 named in the zone's nameserver set: All nameservers for the zone
415 should supply the same list of nameservers for the zone, and none of
416 this authority information should be glueless.  All the glue should
417 always give the same addresses.
418
419 Origin server's data: The set of nameservers in the origin server's
420 version of the zone should be a superset of those in the delegations.
421
422 Our zone configuration: For primary zones, the SOA origin should be
423 one of the names specified with
424 .BR self\-soa " (or " self ).
425 For published zones, the address should be that of the SOA origin.
426 For stealth zones, the address should be that of the SOA origin or one
427 of the published nameservers.
428 .SH GLUELESSNESS
429 Glue is the name given for the addresses of nameservers which are
430 often supplied in a referral.  In fact, it turns out that it is
431 important for the reliability and performance of the DNS that
432 referrals, in general, always come with glue.
433
434 Firstly, glueless referrals usually cause extra delays looking up
435 names.  BIND 8, when it receives a completely glueless referral and
436 does not have the nameservers' addresses in its cache, will start
437 queries for the nameserver addresses; but it will throw the original
438 client's question away, so that when these queries arrive, it won't
439 restart the query from where it left off.  This means that the client
440 won't get its answer until it retries, typically at least 1 second
441 later - longer if you have more than one nameserver listed.  Worse, if
442 the nameserver to which the glueless referral points is itself under
443 another glueless referral, another retry will be required.
444
445 Even for better resolvers than BIND 8, long chains of glueless
446 referrals can cause performance and reliability problems, turning a
447 simple two or three query exchange into something needing more than a
448 dozen queries.
449
450 Even worse, one might accidentally create a set of circularly glueless
451 referrals such as
452 .br
453 .B example.com NS ns0.example.net.uk
454 .br
455 .B example.com NS ns1.example.net.uk
456 .br
457 .B example.net.uk NS ns0.example.com
458 .br
459 .B example.net.uk NS ns1.example.com
460 .br
461 Here it is impossible to look up anything in either example.com or
462 example.net.uk.
463
464 There are, as far as the author is aware, no generally agreed
465 conventions or standards for avoiding unreasonably long glueless
466 chains, or even circular glueless situations.  The only way to
467 guarantee that things will work properly is therefore to always supply
468 glue.
469
470 However, the situation is further complicated by the fact that many
471 implementations (including BIND 8.2.3, and many registry systems),
472 will refuse to accept glue RRs for delegations in a parent zonefile
473 unless they are under the parent's zone apex.  In these cases it can
474 be necessary to create names for the child's nameservers which are
475 underneath the child's apex, so that the glue records are both in the
476 parent's bailiwick and obviously necessary.
477
478 In the past, the `shared registry system' managing .com, .net and .org
479 did not allow a single IPv4 address to be used for more than one
480 nameserver name.  However, at the time of writing (October 2002) this
481 problem seems to have been fixed, and the workaround I previously
482 recommended (creating a single name for your nameserver somewhere
483 in .com, .net or .org, and using that for all the delegations
484 from .com, .net and .org) should now be avoided.
485
486 Finally, a note about `reverse' zones, such as those in in-addr.arpa:
487 It does not seem at all common practice to create nameservers in
488 in-addr.arpa zones (ie, no NS RRs seem to point into in-addr.arpa,
489 even those for in-addr.arpa zones).  Current practice seems to be to
490 always use nameservers for in-addr.arpa which are in the normal,
491 forward, address space.  If everyone sticks to the rule of always
492 publishing nameservers names in the `main' part of the namespace, and
493 publishing glue for them, there is no chance of anything longer than a
494 1-step glueless chain might occur for a in-addr.arpa zone.  It is
495 probably best to maintain this as the status quo, despite the
496 performance problem this implies for BIND 8 caches.  This is what the
497 serverless\-glueless directive is for.
498
499 Dan Bernstein has some information and examples about this at
500 .UR http://cr.yp.to/djbdns/notes.html#gluelessness
501 http://cr.yp.to/djbdns/notes.html#gluelessness
502 .UE
503 but be warned that it is rather opinionated.
504 .SS GLUELESSNESS SUMMARY
505
506 I recommend that every nameserver should have its own name in every
507 forward zone that it serves.  For example:
508 .br
509 .B zone.example.com NS servus.ns.example.com
510 .br
511 .B servus.ns.example.com A 127.0.0.2
512 .br
513 .B 2.0.0.127.in-addr.arpa PTR servus.example.net
514 .br
515 .B servus.example.net A 127.0.0.2
516 .LP
517 Domain names in
518 .B in-addr.arpa
519 should not be used in the right hand side of NS records.
520 .SH SECURITY
521 chiark\-named\-conf is supposed to be resistant to malicious data in
522 the DNS.  It is not resistant to malicious data in its own options,
523 configuration file or environment.  It is not supposed to read its
524 stdin, but is not guaranteed to be safe if stdin is dangerous.
525 .LP
526 Killing chiark-named-conf suddenly should be safe, even with
527 .BR -y " or " -f
528 (though of course it may not complete its task if killed), provided
529 that only one invocation is made at once.
530 .LP
531 Slow remote nameservers will cause chiark-named-conf to take
532 excessively long.
533 .SH EXIT STATUS
534 .TP
535 .B 0
536 All went well and there were no warnings.
537 .TP
538 any other
539 There were warnings or errors.
540 .SH FILES
541 .TP
542 .B /etc/bind/chiark-conf-gen.zones
543 Default input configuration file.  (Override with
544 .BR -C .)
545 .TP
546 .B /etc/bind
547 Default directory.  (Override with
548 .BR -C " or " default\-dir .)
549 .TP
550 .IB dir /chiark-conf-gen.bind8
551 Default output file.
552 .TP
553 .B /var/cache/bind/chiark-slave
554 Default location for slave zones.
555 .SH ENVIRONMENT
556 .LP
557 Setting variables used by
558 .BR dig (1)
559 and
560 .BR adnshost (1)
561 will affect the operation of chiark\-named\-conf.  
562 Avoid messing with these if possible.
563 .LP
564 .B PATH
565 is used to find subprograms such as
566 .BR dig " and " adnshost .
567 .SH BUGS
568 The determination of the parent zone for each zone to be checked, and
569 its nameservers, is done simply using the system default nameserver.
570
571 The processing of output from
572 .B dig
573 is not very reliable or robust, but this is mainly the fault of dig.
574 This can lead to somewhat unhelpful error reporting for lookup
575 failures.
576 .SH AUTHOR
577 .B chiark\-named\-conf
578 and this manpage were written by Ian Jackson
579 <ian@chiark.greenend.org.uk>.  They are Copyright 2002 Ian Jackson.
580
581 chiark\-named\-conf and this manpage are free software; you can
582 redistribute it and/or modify it under the terms of the GNU General
583 Public License as published by the Free Software Foundation; either
584 version 2, or (at your option) any later version.
585
586 This is distributed in the hope that it will be useful, but WITHOUT ANY
587 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
588 FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
589 details.
590
591 You should have received a copy of the GNU General Public License along
592 with this program; if not, consult the Free Software Foundation's
593 website at www.fsf.org, or the GNU Project website at www.gnu.org.