Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why DNS uses UDP as the transport layer protocol?

Why DNS uses UDP as the transport layer protocol?

like image 391
Ada S Avatar asked Oct 15 '16 19:10

Ada S


People also ask

Why is DNS UDP and not TCP?

DNS uses TCP for Zone transfer and UDP for name, and queries either regular (primary) or reverse. UDP can be used to exchange small information whereas TCP must be used to exchange information larger than 512 bytes.

Why do we use UDP in the transport layer?

UDP is used at the transport layer because it is a transport layer protocol. It provides "provides end-to-end communication services for applications" (RFC1122). Reliability services are optional for transport layer protocols.

Which protocol DNS use in transport layer?

Just like every application layer protocol, DNS uses the User Datagram Protocol (UDP) on the Transport layer of the TCP/IP model to transport data. UDP is preferred over TCP for DNS because of its speed and lightweight packets.

Why do DNS and DHCP use UDP?

Since DHCP is inherently connectionless, UDP makes more sense. Second, the DHCP client does not have an IP address assigned until the DHCP process is complete.


2 Answers

  • 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/

like image 62
Matthias Hamann Avatar answered Oct 10 '22 12:10

Matthias Hamann


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.

like image 29
MarianD Avatar answered Oct 10 '22 12:10

MarianD