<div dir="ltr"><div dir="ltr"><div><br></div></div><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Dec 19, 2024 at 1:25 PM Grant Taylor via bind-users <<a href="mailto:bind-users@lists.isc.org">bind-users@lists.isc.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I'd appreciate some help in getting just the PTR record from the <br>
following dig command:<br>
<br>
        dig +short -x 192.0.2.1<br>
<br>
With the following germane content from the respective zones:<br>
<br>
        1.2.0.192.in-addr.arpa. IN      CNAME   <a href="http://nic.host.example.net" rel="noreferrer" target="_blank">nic.host.example.net</a>.<br>
<br>
        <a href="http://nic.host.example.net" rel="noreferrer" target="_blank">nic.host.example.net</a>.   IN      PTR     <a href="http://host.example.net" rel="noreferrer" target="_blank">host.example.net</a>.<br>
        <a href="http://nic.host.example.net" rel="noreferrer" target="_blank">nic.host.example.net</a>.   IN      A       192.0.2.1<br>
        <a href="http://host.example.net" rel="noreferrer" target="_blank">host.example.net</a>.       IN      A       192.0.2.1<br>
<br>
When I run the dig command above, I get two lines of output:<br>
<br>
        <a href="http://nic.host.example.net" rel="noreferrer" target="_blank">nic.host.example.net</a>.<br>
        <a href="http://host.example.net" rel="noreferrer" target="_blank">host.example.net</a>.<br>
<br>
I'm looking at scripting the collection of the value of the PTR record; <br>
<a href="http://host.example.net" rel="noreferrer" target="_blank">host.example.net</a>.  But my old method of "$(dig +short -x 192.0.2.1)" <br>
isn't compatible with the RFC 2317 Classless IN-ADDR.ARPA Delegation / <br>
CNAME method.  As such, I'm looking to update it.<br>
<br>
Is there another -- hopefully -- simple command that I can run to get <br>
just the PTR value?<br>
<br>
I took a look at `drill` and it seems to do similar and comes with it's <br>
own complications.<br>
<br>
The venerable `host` also seems to produce multiple lines of output.<br>
<br>
Or am I looking at something to post-process the output from dig et al. <br>
or my own custom utility (Perl / Python code) to use beside dig et al.?<br>
<br></blockquote><div><br></div><div>I typically use something like:</div><div>dig +noall <a class="gmail_plusreply" id="gmail-plusReplyChip-1">+ans </a><span style="color:rgb(0,0,0)">-x 192.0.2.1 | awk '$4 == "PTR" {print $5;exit}'</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">That returns only the first PTR record if there are more than one.</span></div><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><br>--<br>Bob Harold</div><div><br></div></div></div></div></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
-- <br>
Grant. . . .<br>
unix || die<br>
--<br>
</blockquote></div></div>