Why DNS uses UDP as the transport layer protocol?
18,149
Solution 1
- UDP is much faster. TCP is slow as it requires 3 way handshake. The load on DNS servers is also an important factor. DNS servers (since they use UDP) don’t have to keep connections.
- DNS requests are generally very small and fit well within UDP segments.
- UDP is not reliable, but reliability can be added on application layer. An application can use UDP and can be reliable by using timeout and resend at application layer.
You can read it here: https://www.geeksforgeeks.org/why-does-dns-use-udp-and-not-tcp/
Solution 2
UDP
is cheap. UDP
itself is not reliable, but higher level protocols — as DNS — may maintain reliability, e.g. by repeating the UDP
datagram in the case of no response.
But the last is not the case for DNS
. DNS
itself uses sometimes besides UDP
(as its primary protocol) the reliable Transmission Control Protocol (TCP
), too.
The last is used when the response data size exceeds 512
bytes, and for tasks which require the reliable delivery (e.g. zone transfers).
Moreover, there are some resolver implementations that use TCP
for all queries.
Related videos on Youtube
Author by
Ada S
Updated on June 15, 2022Comments
-
Ada S about 2 years
Why DNS uses UDP as the transport layer protocol?
-
Ry- over 7 yearsMost queries fit into one message. You can re-send the message if you don’t get an answer. Less overhead than TCP.
-
-
MarianD almost 7 years3 notes to your answer: 1)
DNS
uses not onlyUDP
- sometimes it usesTCP
, too. 2) The slowness ofTCP
lies mainly not in the connection establishment (which in turn is not only the 3-way handshake). 3) Reliability can be added on higher layers but it is not the case of DNS. -
Aman Gupta over 5 yearshow dns can use tcp. please explain @MarianD ??? As the response time will increase
-
MarianD over 5 years@AmanGupta, see the last two paragraphs in my answer, please.
-
Tom Burrows over 3 yearsThis answer has been plagiarised, typos included, here: geeksforgeeks.org/why-does-dns-use-udp-and-not-tcp
-
Matthias Hamann over 3 yearsYes I got it from another source, whether it was I don't remember. I could have named it.