Amazon Interview Question

How does DNS work?

Interview Answer

Anonymous

Jun 1, 2019

DNS process: First we can mention about what DNS is: Domain Name System running on port 53 for tcp and UDP. Now, So what is DNS or a name server: its something which has entires of hostnames with respective ip addresses. There are 2 advantages: 1. its easier to remember a name that the numerical ip address 24 bit long. 2. If you need to change the ip address for a respective host name, you can do so without affecting the name based queries. The structure starts with '.' which is the root name server. which is at the top. Then there is the top level domain nameservers suchas : com, edu, net etc. Then there are subdomian name servers like example, abc etc. This will then have www, or apache server or mail server etc. So every nameserve will have its zone, zone will store all the information records that will help the name server. It will have the records such as A, AAAA, CNAME, MX, NS, PTR, SOA, SRV So there 2 types of nameservers: 1. Athoritative, 2. Recursive 1. Authoritative: They answer Resource Records(RR) that are part of their respective zones only. They include Master Slave nameserver. 2. Recursive: They answer all resolutions , they cache it in their memory for a fixed period of time. When your client machine asks for a particular domain: eg. xyz.com then here are the first few step: 1. client resolver will contact the your namspace server who will check enteries using your zone files. 2. if not found then client resolver will contact the root namspace server. 3., The root server will check for the 'com' top level domian server(TLD), and tell your nameserver to go to the TLD .com and ask your question. 3. The 'com' top level server will check for any entries for xyz, and its ip address. 4. once that has been confirmed the (TLD) will provide that information to your nameserver will give it to the you or your recursor. Thats a brief overview. Now, this is just of my head, I could be wrong.