DNS programming

Brian {Hamilton Kelly} bhk at dsl.co.uk
Wed Sep 1 16:29:15 UTC 1999


On 31 Aug, in article <37CC55A1.1CC7D16B at americasm01.nt.com>
     michael.sedlak at gmx.at "Michael Sedlak" wrote:

> Hi all!
> 
> I am working on a program that sends queries to a DNS and gets back its
> replies. So far, I studied the "DNS and BIND"-book published by
> O'reilly. 
> 
> What I could not find in this book is an explicit description how a
> query is built. As far as I know, all the parameters of the header and
> question are put into a character string that is sent to the DNS query.
> The same happens when the answer is received as a character string.

Try reading the relevant RFCs; the full details are laid out there quite
explicitly.  Your main problem is that the "character string" is actually
a sequence of binary bytes, words and longwords.  You need to create the
correct sequences and blast them out through an IP port (UDP or TCP).

> I would appreciate it very much if anybody could answer my questions.
> When you know any web-address where I can find source code dealing with
> this, please tell me so.

Just for amusement, I wrote something in REXX that would query a
nameserver (a sort-of cut-down "nslookup"); I could e-mail you that
source if you're interested.  (I did this because I was writing an SMTP
client in Rexx, and wanted to access the destinations' MX records from
within the code, using neither a smarthost, nor calling the local
resolver.)  It was quite an "interesting" exercise getting the correct
binary values into character strings (because the latter is the ONLY form
of variable that Rexx uses).  Nevertheless, it worked: I really must get
around to completing the SMTP client (I haven't touched it for a year:-)

Let me know an e-mailbox if you want it.

-- 
Brian {Hamilton Kelly}                                         bhk at dsl.co.uk
    "But we're a university.  We /have/ to have a library!..."said Ridcully,
         "What sort of people would we be if we didn't go into the library?"
    "Students", said the Senior Wrangler, morosely. [TP: The Last Continent]



More information about the bind-users mailing list