Role of Domain Name Server (DNS)
- DNS is an application layer, connection-less, non-persistent, and stateless protocol.
- IP Addresses are not static and may change dynamically. So, a mapping is required which maps the domain names to the IP Addresses of their web servers.
- Also, IP Addresses are a complex series of numbers. So, it is difficult to remember IP Addresses directly while it is easy to remember names. Hence, alphanumeric addresses (URL) are introduced.
- Therefore, DNS is a hierarchical naming system built on a distributed database.
- This system transforms domain names to IP addresses, which are the real URLs.
- DNS uses UDP at the transport layer and port 53 at the transport layer.
- Once DNS translates the URL into IP address, the web browsers can communicate with the web server and ask for the specified file.
- Commonly used Top-Level Domains(TLD) are .com, .edu, .net, .org, .gov etc. and some country specific domains are .in, .uk, .ca, .de, .jp etc.
Working of DNS
- When users type a domain name (URL) such as google.com into a browser using a client computer operating system such as Windows or Apple OS.
- The client needs to find the IP address where the google.com search engine is located on the earth (typically all websites are hosted in the Internet data center).
- Then browser will send this query to the operating system.
- Each operating system is configured to query certain DNS Servers. Typically user's ISP or network administrator configures such DNS servers called Resolving Name Server.
- The resolving name server does not aware of the location of google.com, but it does know where the Root Servers are located.
- Next, the resolving name server finds the location of the Top Level Domain (TLD) name server to send a query for google.com. Each domain on the Internet has an Authoritative Name Server.
- Finally, the authoritative name server will give the user the exact IP address of google.com.
- This information will come back to the resolving name server, which caches the information and sends back an answer (answer to user query what is IP address of google.com) on the browser to the correct place.
- The end result user will see the google search engine home page.
DNS Record
- A DNS record is one type of database record used to map a URL, web address, or domain name to an IP address.
- DNS records are stored in DNS servers and work to help users connect their websites to the outside world.
- When the URL is entered and searched in the browser, that URL is forwarded to the DNS servers and then directed to the specific Web server.
- This Web server then serves the queried website outlined in the URL or directs the user to an email server that manages the incoming mail.
- There are many DNS record types, each with its own purpose in denoting how a query should be treated.
- The most common record types are A (address), CNAME (canonical name), MX (mail exchange), NS (name server), PTR (pointer), SOA (start of authority), and TXT (text record).
Different types of DNS records are as follows:
Name Server (NS) Record:
- It describes a name server for the domain that permits DNS lookups within several zones.
- These name server records denote which authoritative server is responsible for having all the information about a given domain.
- Every primary, as well as secondary name server, must be reported via this record.
- Therefore multiple NS records are used to direct queries to them.
Mail Exchange (MX) Record:
- It permits mail to be sent to the right mail servers located in the domain.
- Other than IP addresses, MX records include fully-qualified domain names.
- The MX record indicates how email messages should be routed in accordance with the Simple Mail Transfer Protocol (SMTP).
- Like CNAME records, an MX record must always point to another domain.
Address (A) Record:
- It is used to map a hostname to an IP address.
- Generally, A records are IP addresses. A records only apply to IPv4 addresses. IPv6 addresses have AAAA records instead, which use the longer format of IPv6 addresses.
- If a computer consists of multiple IP addresses, adapter cards, or both, it must possess multiple address records.
- Most websites only have one A record, but some larger sites have several, which helps with load balancing by serving different A records to different users in heavy traffic.
Canonical Name (CNAME) Record:
- Canonical name records are used instead of an A record when there is an alias.
- They are used to retry the query of the same IP address with two different domains.
- Like URL a CNAME record can map the web address www.ques10.com to the actual website for the domain ques10.com.
- CNAME records are typically used to map a subdomain such as www or mail to the domain hosting that subdomain’s content.
Text (TXT) Record:
- It permits the insertion of arbitrary text into a DNS record.
- TXT records enable administrators to enter text into DNS.
- TXT records are used to confirm domain ownership, secure email, and counter email spam.
Time-to-Live (TTL) Record:
- Time to live (TTL) refers to the amount of time or “hops” that a packet is set to exist inside a network before being discarded by a router.
- It is ideal with a recursive DNS server that queries the domain name information.
Start of Authority (SOA) Record:
- The DNS Start Of Authority (SOA) record stores important information about a domain or zone such as the email address of the administrator, when the domain was last updated, and how long the server should wait between refreshes.
- It declares the most authoritative host for the zone.
- Every zone file should include an SOA record, which is generated automatically when the user adds a zone. - SOA records are very important for zone transfers.
Pointer (PTR) Record:
- A DNS PTR record is exactly the opposite of the 'A' record.
- It provides the domain name associated with an IP address.
- Creates a pointer, which maps an IP address to the hostname in order to do reverse DNS lookups.
- Means query that starts with the IP address and looks up the domain name. Similar to Inverse domain where IP address is mapped into a domain name.