DNS works on Both TCP and UDP why?

In interview, I have been asked many times - on which protocol DNS works? I say: TCP and UDP both. They ask: why it works on both protocols...that's it! I say: sorry cound't answer this question but I know that it works on both protocols. Here is the answer I have retreived from many resources on the web. The answer is very simple: TCP is a connection-oriented protocol and it requires data to be consistent at the destination and UDP is connection-less protocol and doesn't require data to be consistent or don't need a connection to be established with host for consistency of data.

UDP packets are smaller in size. Can't be greater then 512 bytes. So any application needs data to be transffered greter than 512 bytes uses TCP 

We often discuss why services use both the protocols i.e. TCP and UDP. These services can also realy on TCP instead of UDP because TCP is a connection-oriented protocol whereas UDP is connection-less! then why use UDP?

For example, DNS uses both TCP and UDP for valid reasons described below. Note that UDP messages are not larger than 512 Bytes and are trucncted when greater than this size. So DNS uses TCP for Zone transfer and UDP for name 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. If a client doesn't get response from DNS it must retransmit the data using TCP after 3-5 seconds of interval.

We all know that there shouldn't be any inconsistency in DNS zones - to make this happen DNS always transfer Zone data using TCP because TCP is reliable and make sure zone data is consistent by transffering the full zone to other DNS servers who has requested the data.

Shouting more on this...

The problem occurs when Windows 2000 server and Advanced Server products uses Dynamic ports for all above 1023. In this case your DNS server should not be internet facing ie. doing all standard queries for client machines on the network. The router (ACLs) must permitted all UDP inbound traffic to access any high UDP ports for it to work.

Now talk about LDAP. It always uses TCP - this is true and why not UDP. because a secure connection is established between client and server to send the data and this can be done only using TCP not UDP. UDP is only used when finding a domain controller (Kerberos) for authentication.

Published Sat, Dec 23 2006 1:42 by Nirmal
Filed under: ,

Comments

# re: DNS works on Both TCP and UDP why?

You may wnat to review the DNS RFC a bit further. It is legal to do a name lookup over TCP. Rarely happens but it's part of the spec.

--Brian

Saturday, December 23, 2006 9:08 PM by Brian Desmond

# re: DNS works on Both TCP and UDP why?

Well, I have seen a number of times that it works on UDP for standard queries.

Didn't get a chance to get through RFC. Could you please tell me which RFC talks about this.

Nirmal

Sunday, January 07, 2007 10:07 AM by Nirmal

# When DNS use TCP to transfer data?

i have one question to you

Sunday, December 28, 2008 10:08 PM by seyha.sam

# re: DNS works on Both TCP and UDP why?

DNS is described in RFC's 1034 and 1035

Sunday, January 18, 2009 4:03 PM by Kirpa Gulati

# re: DNS works on Both TCP and UDP why?

UDP max size is  65535 bytes.

i think reason is only reliability .

Thursday, January 28, 2010 7:27 AM by jasoos

# re: DNS works on Both TCP and UDP why?

what to do to run the dns only on TCP not on udp ?

is there any  provision

Sunday, April 25, 2010 9:01 AM by Mohsinul

# re: DNS works on Both TCP and UDP why?

what to do to run the dns only on TCP not on udp ?

is there any  provision

Sunday, April 25, 2010 9:05 AM by Mohsinul

# re: DNS works on Both TCP and UDP why?

Well, I think DNS works on UDP usually because it requires a great speed. Only a connection-less proctol can fulfil its requirements ..

Tuesday, July 06, 2010 1:49 PM by Mubashir

# re: DNS works on Both TCP and UDP why?

This answer was really help full..But there were a lot of deatails need to be ful filled..like, Where DNS requires TCP and where it requires UDP..

Wednesday, April 06, 2011 11:22 AM by Mani Muthu-Bangalore

# re: DNS works on Both TCP and UDP why?

can you describe this line in much more easier explanation "So DNS uses TCP for Zone transfer and UDP for name queries either regular (primary) or revers"

Wednesday, April 20, 2011 5:17 AM by Abdullah

# re: DNS works on Both TCP and UDP why?

thanks

Monday, May 09, 2011 3:31 AM by swagat

# re: DNS works on Both TCP and UDP why?

Thanks.

Good Breifing..

Wednesday, June 22, 2011 11:18 PM by Bhaskar

# re: DNS works on Both TCP and UDP why?

Thanx Its very useful information to me

Saturday, August 06, 2011 5:42 AM by sathish

# re: DNS works on Both TCP and UDP why?

Thanks. This information was very helpful.

Tuesday, September 27, 2011 5:53 AM by ewurah

# re: DNS works on Both TCP and UDP why?

Thanks Nirmal.....

Friday, December 09, 2011 2:10 AM by Bhaskar

# re: DNS works on Both TCP and UDP why?

in fact dns should used both t. l protocols (TCP &UDP)

where tcp is used for transmission session

which is the update files between primary servers and secondary servers also it happened between levels.

even udp is use for client request and reply for gain time.

Thursday, December 20, 2012 4:31 PM by mustafa aljuboori

# re: DNS works on Both TCP and UDP why?

DNS and some other Services work on both the TCP and UDP Protocols. Two protocols are different from each other. TCP is a connection-oriented protocol whereas UDP is a connection-less protocol. TCP requires the data to be consistent at the destination and UDP does not require the data to be consistent or does not need to establish the connection with the host for data accuracy.

DNS uses TCP for Zone Transfer over Port: 53

It is necessary to maintain a consistent DNS database between DNS Servers. This is achieved by the TCP protocol. This communication happens between DNS Servers only. The Zone Transfer feature of DNS Server will always use TCP protocol. The connection is established between the DNS Server to transfer the zone data and Source and Destination DNS Servers will make sure that data is consistent by using TCP ACK bit.

DNS uses UDP for DNS Queries over Port: 53

A client computer will always send a DNS Query using UDP Protocol over Port 53. If a client computer does not get response from a DNS Server, it must re-transmit the DNS Query using the TCP after 3-5 seconds of interval.

Thursday, December 20, 2012 7:41 PM by Noor

Leave a Comment

(required) 
(required) 
(optional)
(required) 
If you can't read this number refresh your screen
Enter the numbers above: