askvity

Is DNS TCP or UDP?

Published in DNS Protocols 3 mins read

DNS utilizes both UDP and TCP protocols on port 53, with UDP being the primary method and TCP acting as a fallback.

DNS Protocol Usage: UDP and TCP

Domain Name System (DNS) resolution, which translates human-readable domain names into IP addresses, can operate over both UDP and TCP, but they have different purposes and applications.

UDP for DNS

  • Default Protocol: UDP (User Datagram Protocol) is the primary transport protocol for DNS queries.
  • Speed and Efficiency: UDP is connectionless, making it faster and more efficient for typical, smaller DNS requests.
  • Lightweight: UDP packets are smaller, which is suitable for most regular DNS lookups.
  • Limitations: UDP has a limit to packet size, which can lead to truncation issues with larger responses.
  • Typical Use Cases: Standard DNS queries for web browsing, email, etc.

TCP for DNS

  • Fallback Protocol: When a DNS response exceeds the size limit of a UDP packet, the DNS client will re-attempt the query using TCP (Transmission Control Protocol).
  • Reliability: TCP is a connection-oriented protocol, ensuring reliable delivery of large DNS responses.
  • Overcoming Size Limits: TCP overcomes UDP's size limitation, making it necessary for some DNS responses.
  • More Complex: TCP uses a three-way handshake, resulting in more overhead compared to UDP.
  • Typical Use Cases: Zone transfers, DNSSEC (Domain Name System Security Extensions), and any other large DNS response.
    • Zone Transfers: Used by secondary DNS servers to sync DNS records from primary servers.
    • DNSSEC: DNSSEC is a security enhancement that uses cryptography to sign records to enhance security of DNS records which results in larger response sizes.

Summary of DNS Protocol Use

Feature UDP TCP
Purpose Primary for most DNS requests Fallback for large responses
Connection Connectionless Connection-oriented
Speed Faster Slower
Reliability Less reliable More reliable
Overhead Lower Higher
Packet Size Limited No practical limit
Use Cases Normal DNS lookups Zone transfers, DNSSEC, large responses

The Reference Explained

The provided reference, "DNS has always been designed to use both UDP and TCP port 53 from the start 1, with UDP being the default, and fall back to using TCP when it is unable to communicate on UDP, typically when the packet size is too large to push through in a single UDP packet," highlights that DNS has always used both protocols (UDP and TCP) on port 53. However, UDP is the default, and if the response to a UDP request is too large, the resolver will attempt over TCP.

Related Articles