Re: Query a DNS in C

phil-news-nospam_at_ipal.net
Date: 04/14/04


Date: 14 Apr 2004 20:17:05 GMT

On 14 Apr 2004 16:22:53 GMT Jens.Toerring@physik.fu-berlin.de wrote:
| Christian <cgregoir99@yahoo.com> wrote:
|> I want to query a DNS within a C program to get the mail server associated
|> to a domain name, ie, the equivalent of the command 'host -t mx
|> <domain_name>'.
|
|> I've had a look at the bind-utils sources, and also run 'host' under gdb but
|> giving that it runs multiple threads, i'm lost.
|
|> Can anyone point any explicit doc (that is, not the RFC 1035), or the
|> specific source files inside the bind-utils tree that manage the
|> request-response stuff ?
|
| While I can send you some (not very well tested) source code that does
| that I guess it would be completely incomprehensible without understan-
| ding RFC 1035 (and possibly a few related RFC, like 974 and 1123). I
| would say that the RFCs are the _most_ explicit documentation you can
| find. What else are you looking for exactly?

I think what the OP is really wanting is a simple set of tools (e.g. that
do this function and not much else) that encapsulates the details (what is
in RFC 1035) and lets the caller use a simple API to send queries and read
the results. Whether that API would simply be a "build and breakdown" API
for DNS datagrams, or a more sophisticated system that waits for multiple
events and does timesout, would be a design decision.

I have been thinking of writing just such a set of functions myself, but it
is still in the "surveying what others might need" phase for now (which this
thread might well contribute to).

I think BIND's tools are overkill for what the OP wants.

-- 
-----------------------------------------------------------------------------
| Phil Howard KA9WGN       | http://linuxhomepage.com/      http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/   http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------


Relevant Pages

  • Re: Zeroconfig and Multicast DNS
    ... come further up to speed on the subject of multicast DNS in general, ... it's API compatible (client wise) with mDNSResponder. ... be available where you can configure "static" dns records. ...
    (freebsd-net)
  • Re: SPF Records
    ... I found RFC 1035. ... There are also absolute limits beyond which at least ... Various objects and parameters in the DNS have size limits. ... John had a point earlier on about keeping response records less than 512, ...
    (microsoft.public.win2000.dns)
  • Re: DNS/RFC and includes
    ... > in the Myzone.dns file to ask the DNS service to include all the records ... You might supply the RFC number -- the DNS developers ... rather than how the DNS server interacts on the network. ... > If you check the DNS RFCs, you can see that we can use a $INCLUDE parameter> in the Myzone.dns file to ask the DNS service to include all the records that> are in an external file ...
    (microsoft.public.win2000.dns)
  • Re: SPF Records
    ... I dropped the character count to 255 without spaces. ... I found RFC 1035. ... Various objects and parameters in the DNS have size limits. ... John had a point earlier on about keeping response records less than 512, ...
    (microsoft.public.win2000.dns)
  • Re: solution: MS02-015 (Q319182) breaks intranet cookies
    ... Sorry about this RFC chatter, ... "The underscore character should not be used in dns names in the first ... Only applies to some DNS records. ... protocol and service labels are prepended with an underscore, ...
    (NT-Bugtraq)