You want to set a prerequisite in a dynamic update.
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:
The following domain name doesn't exist.
The following domain name exists.
The following domain name doesn't own records of the specified type.
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
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.
BIND Name Server Configuration
BIND Name Server Operations
Delegation and Registration
Interoperability and Upgrading
Resolvers and Programming
Logging and Troubleshooting