Thursday, January 28, 2010

DNS -uses TCP or UDP Explain

port no 53 (both TCP and UDP)
DNS : DNS is used to resolve ip query this should be FAST enough so it uses UDP.
But there are some requirements where Reliability is of more concern in DNS like ZONE TRANSFER
also it is used when the response data size exceeds 512 bytes.
UDP DNS messages are limited to 512 bytes , longer messages are truncated and a special bit (TC) in the header is set to indicate that this has occurred. If a message being truncated causes a problem for its recipient, the query must be repeated using TCP, as described below.

ZONE Transfer (QTYPE: AXFR) : what happens there??
Whole data is replicated from server DNS to client DNS .
* Before sending the AXFR request, the AXFR client usually sends a preliminary SOA request to decide whether it wants to see the AXFR results. This SOA request may be sent through UDP or through TCP.
* TCP port 53 is simultaneously used by normal (non-AXFR) DNS clients requesting data that did not fit through UDP. A non-AXFR DNS client tries all queries through UDP first; however, if a UDP DNS server sets the ``TC'' bit in its response, the DNS client tries the query again through TCP.

The end of a zone transfer is marked by duplicating the SOA RR that started the zone.


REf:
http://www.tcpipguide.com/free/t_DNSMessageHeaderandQuestionSectionFormat.htm
http://technet.microsoft.com/en-us/library/cc781340(WS.10).aspx
http://cr.yp.to/djbdns/axfr-notes.html
http://www.faqs.org/rfcs/rfc1035.html