Search code examples
unixdnsreverseforwardzone

Modify reverse lookup with forward lookup


I have a CLI script that runs through NSUPDATE for a DDNS unix server. It accepts user input and adds/modifies/deletes records as needed. I'm not sure how to, or if you can, modify a reverse zone record when a forward zone record is being change. Say

nslookup host1.zone1 = 1.2.3.4
nslookup 1.2.3.4  = host.zone1

I want to run nsupdate as follows.

nsupdate
server info ....
update add host1.zone1 86400 IN A 5.6.7.8
send

I'm wondering if there is a way to link the reverse record to the forward record so just editing the forward zone record changes both.

nslookup host1.zone1 = 5.6.7.8
nslookup 5.6.7.8 = not found (want this to show host1.zone1)
nslookup 1.2.3.4 = host1.zone1 (want this to show not found)

Solution

  • from first link of googling "man nsupdate reverse":

    Adding records

    Here are examples of how to add A, CNAME, and PTR records. One must specify the TTL (time-to-live) of records (in seconds) when they are added.

    update add www1.example.com 86400 a 172.16.1.1
    update add www.example.com 600 cname www1.example.com.
    send
    
    update add 1.1.16.172.in-addr.arpa 86400 ptr www1.example.com.
    send 
    

    Note that I have taken care to use two separate "send" commands to handle the A and PTR updates of www1.example.com since the changes apply to two different zones, example.com and 1.16.172.in-addr.arpa.

    Keep in mind that reverse records are PTR, not A. There's no method I'm aware of where you can link them so that one command does both as they are separate records. But, if you're scripting the forward, you already have the information for the PTR.