Let go through each of the fields of the header: ID - A 16 bit identifier assigned by the program that generated the query. Here is a detailed explanation of each of the fields in the header. When sending dns queries, we shall need to construct this header structure in our program. The following is the structure of the DNS header. All RR's stand in a queue and certain fields of the header tell that how many of the RR's are answers, how many authority and how many additionals. When a DNS server replies it sends the question as it is and along with that are a bunch of RR's or resource records. All type of queries and response packets are build nearly on the same structure depicted above. DNS queries are used for a variety of purpose.Īpart from getting the ipv4 address of a host we also use DNS for getting the mail exchange/server of a specified domain and etc. Next task is to receive the reply which is expected to contain the information we are expecting. So the first thing is to send a query containing the hostname. Pretty simple to understand that queries wont have the answer, authority and additional fields.Packets are of course UDP and DNS servers feel comfortable to operate on port 53. | Additional | RRs holding additional information | Authority | RRs pointing toward an authority | Question | the question for the name server RFC 1035 shows the structure of DNS message as follows: +-+ DNS packetsīefore writing the code to perform dns query, its important to understand the structure of a dns packet. We shall be sending DNS queries and receive the reply and extract the ipv4 address of the specified hostname. In this article we shall do this simple thing without the help of gethostbyname(). In winsock applications we achieve this by gethostbyname() and things are pretty simple. When we type a web url or domain in our browser a dns request is immediately send by our browser to a DNS server to get the IP address of that web address.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |