tags:

views:

135

answers:

2

I want to encode DNS protocol header using C and create a UDP datagram. Lets say I have a query www.google.com.

Can anyone suggest how to go about it?

You can find the header format here - http://www.nersc.gov/~scottc/software/snort/dns%5Fhead.html

+2  A: 

RFC 1035 explains the DNS packet format in full detail. Note that the format is designed to be as compact as possible, so there are a lot of bit- and byte-level optimisations that you will have to pay attention to. A proper, robust DNS encoder and decoder is not for the faint of heart.

Greg Hewgill
Can you suggest any website or book where I can get any help
Bruce
What do you need help with? Have you read and understood that RFC document?
Greg Hewgill
yes I have...how to I do the encoding?
Bruce
The encoding is fully specified in that RFC....
Carl Norum
I mean how do I code it in C
Bruce
+2  A: 

+1 to RFC 1035. You can take a look on Wireshark: http://www.wireshark.org/ It shows packets in both - binary and decoded view + contains source code in C so you can check how decoding is implemented.

Oleg
Welcome to Stack Overflow! You're pretty new here, so I thought I'd point out that "+1" means that you would click the up arrow beside a helpful post to increase its vote count. Others will do the same for your posts and that is how you gain reputation.
Greg Hewgill
Greg, thank you for the tip.
Oleg
@Greg. You know that the only way you can leave a comment before 50 rep is to make an answer, right?
Ewan Todd
Right, but you can upvote at 15 rep.
Greg Hewgill
thnx you for the help...I have installed wireshark and I am working on it now
Bruce