Net::DNS packet construction

Kevin Darcy kcd at daimlerchrysler.com
Wed Aug 22 21:17:22 UTC 2007


Vishwas wrote:
> Hi,
>
> Am using Net::DNS to generate & update DNS packets.
>
> Please correct me in the following:
> 1. A typical DNS packet (query or response) over the internet has
> following structure
>     {IP {UDP {DNS {header, question, answer, authority, additional}}}}
>     That is, outermost layer - IP: carrying packet from one host to
> the other over the Internet -- let's say IP_data
>      below IP layer - UDP: telling about the source and destination
> ports -- let's say UDP_data
>      innermost layer - DNS: real data that is useful for end hosts  --
> let's say DNS_data
>
> 2. Net::DNS   allows to construct/modify DNS_data and to construct
> UDP_data and IP_data sections of the packet one needs to use something
> else [e.g., NetPAcket::UDP, NetPacket::IP]
>   
No, you don't need to use those. Net::DNS takes care of all of that 
under the covers. See, for example, blib/lib/Net/DNS/Resolver/Base.pm; 
the send_udp() routine (which is subsidiary to the main send() routine) 
uses the IO::Socket module to create the socket, and a straight 
getaddrinfo() call to actually send the query, along with its own 
timeout/retry logic. Users of Net::DNS don't need to get into the 
particulars of formatting the packet at the IP or TCP/UDP layers.
> 3. Net::DNS::Resolver has some methods like srcport, port, srcaddr -
> can they be of any help?
>   
If you need control over those parameters, sure. Otherwise just let 
Net::DNS handle it.

                                                                         
                              - Kevin



More information about the bind-users mailing list