Setting Prerequisites in a Dynamic Update
5.22.1 Problem
You want to set a prerequisite in a dynamic update.
5.22.2 Solution
Use nsupdate and specify the prerequisite you want as an argument to the prereq command. Then specify the update with an update command. nsupdate supports the following kinds of prerequisites:
nxdomain
The following domain name doesn't exist.
yxdomain
The following domain name exists.
nxrrset
The following domain name doesn't own records of the specified type.
yxrrset
The following domain name owns records of the specified type. If the RDATA is specified, it must match, too.
For example, you could use this nsupdate command to add an A record to foo.example only if foo.example doesn't already have an A record:
$ nsupdate > prereq nxrrset foo.example A > update add foo.example. 3600 A 192.168.0.86 > send
In order to change www.foo.example's A record to 192.168.0.86 only if it's currently 192.168.0.99, you could use:
$ nsupdate > prereq yxrrset www.foo.example A 192.168.0.99 > update delete www.foo.example A 192.168.0.99 > update add www.foo.example 3600 A 192.168.0.86 > send
5.22.3 Discussion
Remember that the BIND 8 version of nsupdate doesn't support the send command. Instead, just type a blank line.
5.22.4 See Also
nsupdate(8) and "DNS Dynamic Update" in Chapter 10 of DNS and BIND.