12 Aug: UDP or TCP DNS

DNS servers accept requests on both UDP and TCP port 53. UDP is ideal since its faster (lower overhead). This also means lower load on the DNS server. TCP is required where the data payload is going to exceed the UDP maximum of 512 bytes. The 512 byte limit is to ensure the packet fits within the maximum size that IPv4 guarentees can be reassembled after fragmentation. There is an extension to the protocol which amongst other things, allows 4096 byte UDP packets - Extension Mechanisms for DNS (EDNS0). The server and client would both need to specifically support this. You can check whether EDNS is supported by the name server in the dig output:
$ dig
; EDNS: version: 0, flags:; udp: 1500
This says EDNS version 0 (EDNS0) is supported, and that the maximum supported length of a UDP query is 1500 bytes. You can force dig to send a request over TCP with the +tcp flag no matter what the size.
           Use [do not use] TCP when querying name servers. The default behavior is to use UDP
           unless an ixfr=N query is requested, in which case the default is TCP. AXFR queries
           always use TCP.
© 2017