DNS Protocol – Communication via UDP and TCP

  DNS, DNS Protocols, DNS Theory

DNS servers communicate with other DNS servers and clients (resolvers) over TCP and UDP protocols, in both cases on port 53. For common queries, the request is sent by one UDP packet and the response is returned in a UDP packet. This protocol was chosen for its simplicity and minimal overhead, when it is not neccessary to establish a connection over TCP for small data.

If it happens that the whole response (which can contain either a large response itself or other data in additional sections) does not fit into one UDP packet (the DNS response size is limited to 512 bytes by default, UDP and IP protocol headers are not counted), a partial response is sent (the maximum that will fit in the packet) and a flag is set in the header to announce this fact (truncated). The requester can now decide whether the data received is sufficient for them. If not, they should send the same query again, but this time using the TCP protocol, through which they can download the entire response in the required number of packets.

However, the UDP protocol does not solve packet loss along the way, so queries are repeated after a few seconds, after a certain number of unsuccessful attempts, the DNS server is considered unreachable. That all depends on the resolver settings.

Děkujeme za zpětnou vazbu!