Skip to main content

What protocol does DNS use?

DNS mainly runs over UDP, but in some cases it uses TCP.

In simpler terms: ordinary DNS requests go over UDP, and TCP is used in special situations.


The main protocol: UDP

Why DNS usually uses UDP

By default DNS works over UDP on port 53, because:

  • requests and responses are small
  • no connection needs to be established
  • the answer arrives quickly
  • there is less overhead

DNS is a short question and a short answer, so UDP is a perfect fit.


When DNS uses TCP

DNS switches to TCP (also port 53) in the following cases:

1. A large response size

If the DNS response:

  • does not fit in a UDP packet
  • contains many records (for example, with DNSSEC)

TCP is used.


2. DNS zone transfer

When synchronizing DNS zones between servers:

  • primary -> secondary

TCP is always used, because:

  • there is a lot of data
  • reliability matters

3. DNSSEC

When DNSSEC is used:

  • responses become larger
  • TCP is needed more often

Briefly, in a table

SituationProtocol
Ordinary DNS requestUDP
Large responseTCP
Zone transfer (AXFR)TCP
DNSSECOften TCP

An important point for an interview

If DNS is an application-layer protocol, why UDP/TCP here?

The answer:

  • DNS is an application-layer protocol
  • UDP and TCP are the transport
  • DNS uses transport protocols for delivery

Real-life example

UDP is like:

  • asking a short question and getting an answer

TCP is like:

  • sending a package of documents with delivery confirmation

Short interview answer

Remember this formulation:

DNS mainly runs over UDP on port 53, while TCP is used for large responses, DNSSEC, and for zone transfers between servers.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.