Saturday, November 23, 2013

Why DNS works on top of UDP? ..It’s just a wrong question! No More!


Yes DNS works on top of UDP, and there is a good reason for that. But it also works on top of TCP.  When and why?

Ok then, DNS, the number one application, will always prefer to use UDP, for the same reason we all know, that UDP is less overhead on the network, especially when the packets of both DNS queries and DNS responses not exceeding 512 bytes in size (size of a maximum UDP packet). It’s a matter of efficiency.

Q: What if the DNS response message was lost when it’s on the way back to the requesting client?
A: The client simply will query the DNS server again.

However, DNS server (aka, resolver) will communicate over TCP in case of large replies or zone transfers only. In other words, when the reply takes more than 512 bytes in size, TCP connection is established with the client in order to send the response back.
We can configure DNS to always run on top of TCP, but this is not recommended!


In a nutshell, DNS queries are always UDP based, because they are less than 512 bytes, whereas DNS responses can be either UDP or TCP.

No comments:

Post a Comment