Why DNS uses UDP as the transport layer protocol?
Asked
Active
Viewed 2.0k times
2 Answers
25
- 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.
Answer reproduced from [1] under the CCBY-SA license.

Dzamo Norton
- 1,194
- 11
- 17

Matthias Hamann
- 719
- 8
- 27
-
63 notes to your answer: 1) `DNS` uses **not** only `UDP` - sometimes it uses `TCP`, too. 2) The slowness of `TCP` 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. – MarianD Sep 12 '17 at 17:43
-
how dns can use tcp. please explain @MarianD ??? As the response time will increase – Aman Gupta Feb 22 '19 at 15:42
-
1
-
This answer has been plagiarised, typos included, here: https://www.geeksforgeeks.org/why-does-dns-use-udp-and-not-tcp/ – Tom Burrows Mar 11 '21 at 13:45
-
Yes I got it from another source, whether it was I don't remember. I could have named it. – Matthias Hamann Mar 15 '21 at 08:42
11
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.

MarianD
- 13,096
- 12
- 42
- 54