On Thu, Dec 19, 2024 at 1:25 PM Grant Taylor via bind-users < bind-users@lists.isc.org> wrote:
> Hi, > > I'd appreciate some help in getting just the PTR record from the > following dig command: > > dig +short -x 192.0.2.1 > > With the following germane content from the respective zones: > > 1.2.0.192.in-addr.arpa. IN CNAME nic.host.example.net. > > nic.host.example.net. IN PTR host.example.net. > nic.host.example.net. IN A 192.0.2.1 > host.example.net. IN A 192.0.2.1 > > When I run the dig command above, I get two lines of output: > > nic.host.example.net. > host.example.net. > > I'm looking at scripting the collection of the value of the PTR record; > host.example.net. But my old method of "$(dig +short -x 192.0.2.1)" > isn't compatible with the RFC 2317 Classless IN-ADDR.ARPA Delegation / > CNAME method. As such, I'm looking to update it. > > Is there another -- hopefully -- simple command that I can run to get > just the PTR value? > > I took a look at `drill` and it seems to do similar and comes with it's > own complications. > > The venerable `host` also seems to produce multiple lines of output. > > Or am I looking at something to post-process the output from dig et al. > or my own custom utility (Perl / Python code) to use beside dig et al.? > > I typically use something like: dig +noall +ans -x 192.0.2.1 | awk '$4 == "PTR" {print $5;exit}' That returns only the first PTR record if there are more than one. -- Bob Harold > -- > Grant. . . . > unix || die > -- >
-- Visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe from this list ISC funds the development of this software with paid support subscriptions. Contact us at https://www.isc.org/contact/ for more information. bind-users mailing list bind-users@lists.isc.org https://lists.isc.org/mailman/listinfo/bind-users