In: Computer Science
What is DNS and what is it used for? How is it structured? What are the implications of this structure? Describe an example DNS query.
DNS - It stands for Domain Name System.
It is used to provide names to all the IP Adresses.
A computer never understands human language. So if we want to open a website in a browser we type in english which is a human language. So how does the computer loads it, if it doesn't understands the human language. This happens with the help of DNS. All the websites have their own unique IP addresses. As we want to search for a website the DNS looks for its IP address in the data and loads the IP address of that particular website.
For eg. If A is a person who can speak English and B is a person who can speak french. So they both can't talk to each other. They need a translator in between them.
A (English) ----> Translator ----> B(French)
Same is the case with DNS. We humans can speak english but the computer cannot understand. Therefore, DNS acts as a translator in between us.
Humans(English) ----> DNS ----> Computer(IP Address)
DNS maintains a table where Names are mapped into Numbers(IP Addresses).
The proper websites domain names are mapped into the ip addresses.
If we want to access www.google.com and we type it in the web browser. The DNS converts the name to the respective IP address and loads it to the web browser. Then the web browserunderstands that we want to access google.com. So it contacts the google server and loads google.com.
How DNS works internally? OR What is its structure?
To understand this we need to understand DNS Servers.
There are 4 types of DNS servers:
1. DNS resolver
2. Root Name Server
3. Top Level Domain/TLD name Server
4. Authoritative Name Server
Zoom in the Picture for a better understanding.
If we want load www.xyz.com on the web browser.
1. The web browser will ask the Computer's Operating System(Windows, Linux, Ubuntu) for the IP address.
The computer OS is configured to forward the query of IP address to the DNS Resolver.
2. The DNS Resolver first check its Cache memory for the IP address. If not present then it contacts the root name server for the IP.
3. The root name server then checks the extension of the website, i.e. .com, .org, .edu etc.
It replies with the IP address of the TLD name server of the extension. In our case it is (.com).
4. Then the resolver contacts the TLD server. It provides the resolver with the Authoritative Name server of the extension(.com).
5. Then it contacts Authoritative name server. Which provides with the IP address of the website, and it also stores the IP address of any new website to its local cache memor So as not to repeat the whole process again.
This is how a website is loaded.
Implication is the connection of the structure or the conclusion.
We studied the connection of the whole process as mentioned above.
Conclusion: If the IP of the website is not in the local cache of the DNS resolver only then it will be proceeding for the whole process and in the last will also store the IP of in the Cache For the next time.
The queries are the websites to be loaded. All the websites we ask for are queries.
There are three types of DNS Queries:
1. Recursive Query: In this type of query, when the DNS client provides a website then the resolver looks for it in it's local memory as well as the through the servers, if not found it flashes an error "it can't be found" or provides information which is most relevant to the website.
2. Iterative query: If the website's IP is found through the whole process then it is an iterative query. This means the query between the DNS Resolver and the DNS servers is known as an iterative query.
3. Non-Recursive Query: It is a type of query in which the resolver already knows the answer. i.e. The IP address of the website is already stored in it's local cache memory.