.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "NSDIFF 1p" .TH NSDIFF 1p 2024-04-21 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME nsdiff \- create "nsupdate" script from DNS zone file differences .SH SYNOPSIS .IX Header "SYNOPSIS" nsdiff [\fB\-hV\fR] [\fB\-b\fR \fIaddress\fR] [\fB\-k\fR \fIkeyfile\fR] [\fB\-y\fR [\fIhmac\fR:]\fIname\fR:\fIkey\fR] [\fB\-0\fR|\fB\-1\fR] [\fB\-q\fR|\fB\-v\fR [q][r]] [\fB\-cCdD\fR] [\fB\-i\fR \fIregex\fR] [\fB\-S\fR \fImode\fR|\fInum\fR] [\fB\-u\fR] [\fB\-s\fR \fIserver\fR] [\fB\-m\fR \fIserver\fR] <\fIzone\fR> [\fIold\fR] [\fInew\fR] .SH DESCRIPTION .IX Header "DESCRIPTION" The \fBnsdiff\fR program examines the \fIold\fR and \fInew\fR versions of a DNS zone, and outputs the differences as a script for use by BIND's \&\fBnsupdate\fR program. It ignores DNSSEC-related differences, assuming that the name server has sole control over zone keys and signatures. .PP The input files are typically in standard DNS zone file format. They are passed through BIND's \fBnamed-compilezone\fR program to convert them to canonical form, so they may also be in BIND's "raw" format and may have \fI.jnl\fR update journals. .PP If the \fIold\fR file is not specified, \fBnsdiff\fR will use \fBdig\fR to transfer the zone from the server given by the \fB\-s\fR option, or if the \fB\-s\fR option is missing it will get the server from the zone's SOA MNAME field. If both \&\fIold\fR and \fInew\fR files are not specified, \fBnsdiff\fR will transfer the new version of the zone from the server given by the \fB\-m\fR option. .PP The SOA serial number has special handling: any difference between the \&\fIold\fR and \fInew\fR serial numbers is ignored (except in \fB\-S file\fR mode), because background DNSSEC signing activity can increment the serial number unpredictably. When the zones differ, \fBnsdiff\fR sets the serial number according to the \fB\-S\fR option, and it uses the \fIold\fR serial number to protect against conflicting updates. .SH OPTIONS .IX Header "OPTIONS" .IP \fB\-h\fR 4 .IX Item "-h" Display this documentation. .IP \fB\-V\fR 4 .IX Item "-V" Display version information. .IP \fB\-0\fR 4 .IX Item "-0" Allow very large updates affecting one domain name to be split across multiple requests. .IP \fB\-1\fR 4 .IX Item "-1" Abort if update does not fit in one request packet. .IP \fB\-C\fR 4 .IX Item "-C" Do not ignore CDS or CDNSKEY records. They are normally managed by \&\fBdnssec-settime\fR with the \f(CW\*(C`\-P sync\*(C'\fR and \f(CW\*(C`\-D sync\*(C'\fR options, but you can use this option if you are managing them some other way. In that case, your un-signed zone file should include the complete CDS and/or CDNSKEY RRset(s); if not, \fBnsdiff\fR will delete the records. .IP \fB\-c\fR 4 .IX Item "-c" Compare records case-insensitively. Can be helpful if the \fBnsupdate\fR target server does not preserve the case of domain names. However with this option, \fBnsdiff\fR does not correctly handle records that only differ in case. .IP \fB\-D\fR 4 .IX Item "-D" Do not ignore DNSKEY records. It is sometimes necessary to take manual control over a zone's DNSKEY RRset, for instance to include a foreign DNSKEY records during migration to or from another hosting provider. If you use this option your un-signed zone file should include the complete DNSKEY RRset; if not, nsdiff will try to delete the DNSKEY records. Normally \fBnamed\fR will reject the update, unless the zone is configured with the \fIdnssec-secure-to-insecure\fR option. .IP \fB\-d\fR 4 .IX Item "-d" Ignore DS records. This option is useful if you are managing secure delegations on the signing server (via nsupdate) rather than in the source zone. .IP "\fB\-i\fR \fIregex\fR" 4 .IX Item "-i regex" Ignore more DNS records. By default, \fBnsdiff\fR strips out DNSSEC RRs (except for DS) before comparing zones. You can exclude irrelevant changes from the diff by supplying a \fIregex\fR that matches the unwanted RRs. .IP "\fB\-m\fR \fIserver\fR[#\fIport\fR]" 4 .IX Item "-m server[#port]" Transfer the new version of the zone from the server given in this option, for example, a back-end hidden primary server. You can specify the server host name or IP address, optionally followed by a "#" and the port number. .IP "\fB\-s\fR \fIserver\fR[#\fIport\fR]" 4 .IX Item "-s server[#port]" Transfer the old version of the zone from the server given in this option, using the same syntax as the \fB\-m\fR option. .IP "\fB\-S\fR \fBdate\fR|\fBfile\fR|\fBserial\fR|\fBunix\fR|\fInum\fR" 4 .IX Item "-S date|file|serial|unix|num" Choose the SOA serial number update mode: the default \fIfile\fR takes the serial number from the \fInew\fR input zone; \fIdate\fR uses a number of the form YYYYMMDDnn and allows for up to 100 updates per day; \&\fIserial\fR just increments the serial number in the \fIold\fR input zone; \&\fIunix\fR uses the UNIX "seconds since the epoch" value. You can also specify an explicit serial number value. In all cases, if the \fIold\fR input zone serial number is larger than the target value it is just incremented. Serial number wrap-around is not supported. .IP \fB\-q\fR 4 .IX Item "-q" Quiet / quick check. Output is suppressed unless the zones differ, in which case a short note is printed instead of an \fBnsupdate\fR script. .IP \fB\-u\fR 4 .IX Item "-u" Tell \fBnsupdate\fR to send the update message to the server specified in the \&\fB\-s\fR option. .IP "\fB\-v\fR [q][r]" 4 .IX Item "-v [q][r]" Control verbosity. The \fBq\fR flag causes queries to be printed. The \fBr\fR flag causes responses to be printed. To make \fBnsdiff\fR quiet, use \fB\-v\ ''\fR. .PP The following options are passed to \fBdig\fR to modify its SOA and AXFR queries: .IP "\fB\-b\fR \fIaddress\fR" 4 .IX Item "-b address" Source address for \fBdig\fR queries .IP "\fB\-k\fR \fIkeyfile\fR" 4 .IX Item "-k keyfile" TSIG key file for \fBdig\fR queries. .IP "\fB\-y\fR [\fIhmac\fR:]\fIname\fR:\fIkey\fR" 4 .IX Item "-y [hmac:]name:key" Literal TSIG key for \fBdig\fR queries. .SH "EXIT STATUS" .IX Header "EXIT STATUS" The \fBnsdiff\fR utility returns 0 if the zones are the same, 1 if they differ, and 2 if there was an error. .SH DIAGNOSTICS .IX Header "DIAGNOSTICS" .ie n .IP """usage: ...""" 4 .el .IP "\f(CWusage: ...\fR" 4 .IX Item "usage: ..." .PD 0 .ie n .IP """not a domain name: \fI\fR""" 4 .el .IP "\f(CWnot a domain name: \fR\f(CI\fR\f(CW\fR" 4 .IX Item "not a domain name: " .PD Errors in the command line. .ie n .IP """could not get SOA record for \fI\fR""" 4 .el .IP "\f(CWcould not get SOA record for \fR\f(CI\fR\f(CW\fR" 4 .IX Item "could not get SOA record for " Failed to retreive the zone's SOA using \fBdig\fR when trying to obtain the server MNAME from which to AXFR the zone. .ie n .IP """missing SOA record""" 4 .el .IP "\f(CWmissing SOA record\fR" 4 .IX Item "missing SOA record" The output of \fBnamed-compilezone\fR is incomplete, usually because the input file is erroneous. .ie n .IP """\fI\fR has changes""" 4 .el .IP "\f(CW\fR\f(CI\fR\f(CW has changes\fR" 4 .IX Item " has changes" Printed instead of an \fBnsupdate\fR script when the \fB\-q\fR option is used. .ie n .IP """update does not fit in packet""" 4 .el .IP "\f(CWupdate does not fit in packet\fR" 4 .IX Item "update does not fit in packet" The changes for one domain name did not fit in 64 KiB, or the \fB\-1\fR option was specified and all the changes did not fit in 64 KiB. .ie n .IP """ignoring dig options when loading zones from files""" 4 .el .IP "\f(CWignoring dig options when loading zones from files\fR" 4 .IX Item "ignoring dig options when loading zones from files" Warning emitted when the command line includes options for \fBdig\fR as well as zone source files. .ie n .IP """ignoring \-m option when loading new zone from file""" 4 .el .IP "\f(CWignoring \-m option when loading new zone from file\fR" 4 .IX Item "ignoring -m option when loading new zone from file" .PD 0 .ie n .IP """need \-m option when there are no input files""" 4 .el .IP "\f(CWneed \-m option when there are no input files\fR" 4 .IX Item "need -m option when there are no input files" .PD The \fB\-m\fR \fIserver\fR option is required when there are no file arguments, and ignored otherwise. .ie n .IP """loading zone \fI\fR via AXFR from \fIserver\fR""" 4 .el .IP "\f(CWloading zone \fR\f(CI\fR\f(CW via AXFR from \fR\f(CIserver\fR\f(CW\fR" 4 .IX Item "loading zone via AXFR from server" .PD 0 .ie n .IP """loading zone \fI\fR from file \fIfile\fR""" 4 .el .IP "\f(CWloading zone \fR\f(CI\fR\f(CW from file \fR\f(CIfile\fR\f(CW\fR" 4 .IX Item "loading zone from file file" .PD Normal progress messages emitted before \fBnsdiff\fR invokes \&\fBnamed-compilezone\fR, to explain the latter's diagnostics. .SH "EXAMPLE \- DNSSEC" .IX Header "EXAMPLE - DNSSEC" It is easiest to deploy DNSSEC if you allow \fBnamed\fR to manage zone keys and signatures automatically, and feed in changes to zones using DNS update requests. However this is very different from the traditional way of manually maintaining zones in standard DNS zone file format. The \&\fBnsdiff\fR program bridges the gap between the two operational styles. .PP To support this workflow you need BIND\-9.7 or newer. You will continue maintaining your zone file \f(CW$sourcefile\fR as before, but it is no longer the same as the \f(CW$workingfile\fR used by \fBnamed\fR. After you make a change, instead of using \f(CW\*(C`rndc reload $zone\*(C'\fR, run \f(CW\*(C`nsdiff $zone $sourcefile | nsupdate \-l\*(C'\fR. .PP Configure your zone as follows, to support DNSSEC and local dynamic updates: .PP .Vb 6 \& zone $zone { \& type primary; \& file "$workingfile"; \& auto\-dnssec maintain; \& update\-policy local; \& }; .Ve .PP To create DNSSEC keys for your zone, change to named's working directory and run these commands: .PP .Vb 2 \& dnssec\-keygen \-f KSK $zone \& dnssec\-keygen $zone .Ve .SH "EXAMPLE \- bump-in-the-wire signing" .IX Header "EXAMPLE - bump-in-the-wire signing" A common arrangement for DNSSEC is to have a primary server that is oblivious to DNSSEC, a signing server which transfers the zone from the primary and adds the DNSSEC records, and a number of secondary servers which transfer the zone from the signer and which are the public authoritative servers. .PP You can implement this with \fBnsdiff\fR, which handles the transfer of the zone from the primary to the signer. No modifications to the primary are necessary. You set up the signer as in the previous section. To transfer changes from the primary to the signer, run the following on the signer: .PP .Vb 1 \& nsdiff \-m $primary \-s $signer $zone | nsupdate \-l .Ve .SH "EXAMPLE \- dynamic reverse DNS" .IX Header "EXAMPLE - dynamic reverse DNS" You have a reverse zone such as \f(CW\*(C`2.0.192.in\-addr.arpa\*(C'\fR which is mostly managed dynamically by a DHCP server, but which also has some static records (for network equipment, say). You can maintain the static part in a DNS zone file and feed any changes into the live dynamic zone by telling \fBnsdiff\fR to ignore the dynamic entries. Say all the static equipment has IP addresses between 192.0.2.250 and 192.0.2.255, then you can run the command pipeline: .PP .Vb 2 \& nsdiff \-i \*(Aq^(?!25\ed\e.)\*(Aq 2.0.192.in\-addr.arpa 2.0.192.static | \& nsupdate \-l .Ve .SH CAVEATS .IX Header "CAVEATS" By default \fBnsdiff\fR does not maintain the transactional semantics of native DNS update requests when the diff is big: it applies large changes in multiple update requests. To minimise the problems this may cause, \&\fBnsdiff\fR ensures each domain name's changes are all in the same update request. There is still a small risk of clients not seeing a change applied atomically when that matters (e.g. altering an MX and creating the new target in the same transaction). You can avoid the risk by using the \fB\-1\fR option to prevent multi-packet updates, or by being careful about changes that depend on multiple domain names. .PP The update requests emitted by \fBnsdiff\fR include SOA serial number prerequisite checks to ensure that the zone has not changed while it is running. This can happen even in simple setups if \fBnamed\fR happens to be re-signing the zone at the time you make an update. Unfortunately the DNS update protocol does not allow for good error reporting when a prerequisite check fails. You can use \fBnspatch\fR to cope with this problem. .SH BUGS .IX Header "BUGS" When updating a name's DNS records, \fBnsdiff\fR first deletes the old ones then adds the new ones. This ensures that CNAME replacements and TTL changes work correctly. However, this update strategy prevents you from replacing every record in a zone's apex NS RRset in one update, because it isn't possible to delete all a zone's name servers. .SH VERSION .IX Header "VERSION" .Vb 1 \& This is nsdiff\-1.85 \& \& Written by Tony Finch \& at Cambridge University Information Services. \& You may do anything with this. It has no warranty. .Ve .SH ACKNOWLEDGMENTS .IX Header "ACKNOWLEDGMENTS" Thanks to Athanasius, Mike Bristow, Piete Brooks (University of Cambridge Computer Laboratory), Terry Burton (University of Leicester), Owen Dunn (University of Cambridge Faculty of Mathematics), Martin Hartl (Barracuda), JP Mens, Mohamad Shidiq Purnama (PANDI), and Jordan Rieger (webnames.ca) for providing useful feedback. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBnspatch\fR\|(1), \fBnsupdate\fR\|(1), \fBnsvi\fR\|(1), \fBdig\fR\|(1), \&\fBnamed\fR\|(8), \fBnamed\-compilezone\fR\|(8), \fBperlre\fR\|(1)