Top 20 Domain Name System(DNS) questions and answers which are commonly asked in an interview.
1. What is DNS?
Domain Name Systems(DNS) maps domain names with Internet Protocol(IP) address, thus helping computer for translating human-readable(domain name) to machine-readable language(IP address).
2. What is Nameserver?
It is used for storing the information for the domain name to IP and IP to the domain name. In other words, the name server is used for storing records of the domain names, Name servers help for convert domain name to IP address.
3. What is DNS Spoofing?
DNS Spoofing occurs when a hacker is redirecting website traffic maliciously to spread the malware or to compromise the user’s data through forged DNS record.
When a user visits a website(like freshersemploy.com) in a browser, it needs to be resolved from human-readable to machine-readable(i.e. IP addresses) using DNS resolver. To decrease the time and resolve faster, DNS resolvers cache the data and store for a specific time(until it expires). An attacker can inject forged DNS entry, thus causing DNS Cache Poisoning and instead of freshersemploy.com, the attacker will redirect it to the wrong domain or fake website.
4. How can we prevent DNS Spoofing?
DNS Spoofing or DNS Cache Poisoning can be avoided by following guidelines:
- From a users point of view, it is almost impossible for users to detect whether the DNS records are compromised, but users should be alerted when accessing the sites like banking, payment website where credit card details are used by checking the domain name in the browser and does it have a valid SSL certificate.
- Domain owner and DNS provider cannot avoid DNS Spoofing but surely can take protective measures to avoid the compromise of DNS records.
- Using Domain Name System Security Extensions(DNSSEC) which helps in determining the DNS records authenticity by signing each request with certified signature and this is recommended by ICANN. Still this in process of implementation.
5. What is Round Robin DNS? What is the purpose of it?
Round Robin DNS is a technique for load distribution, load balancing, fault-tolerance service such as mail server, FTP server etc. which enables distribution of load evenly among multiple servers using various DNS A addresses.
Suppose a domain abc.com is configured with Round robin DNS which has 3 potential IP mapping to the same domain(i.e. freshersemploy.com) as follows:
- freshersemploy.com – 104.28.26.01
- freshersemploy.com – 104.28.26.02
- freshersemploy.com – 104.28.26.03
Then the first request will go to 104.28.26.01, the second request will go to 104.28.26.02 and the third request will go to 104.28.26.03, thus DNS queries are responded by returning IP addresses in a rotation.
6. What is primary and secondary name server?
Primary name server reads the data from the domain zone, it has DNS records of domain names and it replicates the data with the secondary name server.
A secondary name server is the back up of primary name server which is used for high reliability, in case the primary name server is having an issue or not reachable.
7. What is DNS resolver?
DNS resolvers are being used by ISP(Internet service provider) for the user request to resolve the domain name. If a user request for google.com, DNS resolver needs to contact TLD(Top Level Domain) i.e. .com, for translation of domain name to IP address and it caches the data if the user again queries for the same domain, thus reducing the loads on the server and response time.
8. What is the difference between URL and Domain?
URL stands for Uniform Resource Locator. URL specifies the full address of a webpage. It consists of three components: protocol(like HTTP, mailto, ftp), domain name(like freshersemploy.com) and file name(eg. homepage.html)
A domain is the name of a website with the top-level domain(like .com, .org etc.). A domain is a part of URL.
9. What is DNS server?
DNS servers resolve IP address to respective hostnames and it maintains directory or database to store the information.
When we try to access the website (like freshersemploy.com), DNS servers help to translate to machine-readable language i.e. IP address(like 18.104.22.168).
10. What are the different types of records in DNS?
Some of commonly used of DNS records are A, CNAME, NS, MX, PTR, SOA etc.
11. Explain SOA record?
Start of Authority(SOA) records stores essential information(like refresh rate, expiry, TTL etc) in domain name system(DNS) in a zone file.
; name TTL class rr Nameserver email–address
freshersemploy.com. 12000 IN SOA
2098163206 ; Serial number
12000 ; Refresh rate in seconds
3600 ; Update Retry in seconds
5788864; Expiry in seconds
100 ; minimum in seconds )
- Serial Number: It has the serial number, which gets increments whenever there is a change in the DNS records.
- Refresh interval: It gets refresh at the specific interval and if there any changes in the records, data is replicated.
- Retry: If the propagation gets failed, it will retry after specific time which is defined in the zone file.
- Expire: It is set to have an expiry date, as specified in the zone file. Also used for secondary server how long it should be active in case the primary DNS server is down.
- TTL: It has the default time-to-live(TTL),
A zone file should have only one SOA record and it must be at the top of it.
12. What is the use of PTR in DNS?
PTR(Pointer) records are used for mapping IP addresses which are associated with hostname name. It is also called has reverse DNS lookup as it resolves IP address to domain or hostname. There must be A record for every PTR record. PTR is mainly used for the mail server.
13. Explain CNAME record?
CNAME record stands for Canonical Name record. It used as the alias for domain or the Canonical name(another name) for a domain.
For example, suppose someone incorrectly types(or misspelled the website name) like freshersemploy.com as fresheremploy.com(we should also own this domain), then using CNAME record, we can redirect to freshersemploy.com
It is a type of resource record in DNS which is specified in the zone file. CNAME records should always point to another domain and never directly points to IP address.
14. Explain Dynamic DNS?
Dynamic DNS helps for automatically updating the name servers whenever there is a change in the IP address in the Domain Name System(DNS).
15. What is Resource Record?
Resource Record(RR) defines the elements or attributes of a domain name in DNS zone file like Address(A) record, Mail Exchange(MX) record etc. which helps in name resolutions.
Some of the most common Resource Records are:
- A – IPv4 Address record
- AAAA – IPv6 Address record
- CNAME – Canonical Name
- MX – Mail Exchange
- PTR – Pointer
- SOA – Start of Authority
- NS – Name Server
16. What is DNS Zone?
A DNS zone file contains the mapping between a domain name, IP address, recourse records etc. in text representative format. Also, DNS zone refers to the administrative responsibility in the DNS.
17. Define TTL?
Time-to-live caches the DNS records for a specific period of time(when TTL expires, it has to query new record). It helps in queries the records faster, eventually reducing the load on the DNS server.
18. Explain MX record?
Mail Exchange(MX) record is a type of resource record which is used for email sending and delivery. It must be specified in the DNS zone files mails for the domain.
19. What is Forward Lookup?
Forward Lookup is used to find the IP address through the domain name.
20. What is Reverse Lookup?
Reverse Lookup is used for finding the domain name through it IP.