Re: NS rr set from libdns
Richard Sexton <[email protected]>
| Newsgroups | gmane.network.djbdns |
|---|---|
| Message-ID | <[email protected]> |
Thanks this is what I'm looking for. I just want a C program to be able to say "tell me what you think the NS records are for this" for a diagnostic tool and don't care how or what it has to do to get the answer. Like I would do with dig, if dig wern't so horribly broken. At 08:30 PM 03/08/2009 +0200, Laurent Bercot wrote: >> Hello; >> I recently began using the libdns routines to make my C program to >> DNS lookups. As advertised, it's fun! It's easy! > > Depending on what you're doing, you might be interested in skadns: > http://www.skarnet.org/software/skadns/ > > It's built upon DJB's libdns. > The difference with using libdns directly is that with libdns, you >have to include all of your DNS queries into your main loop, which >might be impractical if said loop is already handling a lot of different >sources of file descriptors. skadns hides the internal DNS stuff from >you; it gives you one file descriptor to select on, and only triggers it >on completed queries. > > Of course, it won't help you at all if you're interested in sending >basic iterative queries more than in just getting the result of standard >recursive queries. In other words, skadns allows you to perform several >"dnsqr" simultaneously, but if you want to perform several "dnsq" >simultaneously, you'll still have to do it by hand with libdns. > > >> What would you do to get NS records with libdns? > > As Paul said, your best bet is to construct a packet by hand, taking >inspiration from the internals of dns_ip4() and friends. You can have >a look at how dnscache does. > > If using skadns, the right way to send a NS query for "example.com" >would be something like: > > #include "dns.h" > #include "skadns.h" > > ... > > char *domain = "example.com." ; > char *q = 0 ; > uint16 id ; > > ... > > if (!dns_domain_fromdot(q, domain, strlen(domain))) die() ; > id = skadns_send(a, q, DNS_T_NS) ; /* a being your skadns stuff pointer */ > >-- > Laurent > >