It was one of the many things which I didn’t quite get the first time. The reason for this is because everybody uses the same example about the phone book, so in this post, I will try a different approach to explain to all of you what is DNS.

DNS stands for Domain Name System, its function is to translate IP directions to domain names and vice versa so we dumb humans don’t have to remember complex numbers. On the Internet, every computer has a unique IP address. When you are visiting a website or watching a video on youtube you just retrieve data from data centres. Imagine that you have to search for 142.250.201.78 instead of youtube or 104.244.42.1 for Twitter, that would be complicated, isn’t it?

Imagine that you are a browser, like safari, firefox or chrome and you’re dumb user wants to retrieve the following page: https://anoobishacking.com/ (self-promotion as its finest). But because you are a computer program you understand zeros and ones only you don’t know where the user wants to go. That’s exactly why DNS was invented.

First, you check your local cache, maybe your dumb user wanted to reach out to this destination previously. If that resource has been visited frequently it should be in your browser cache.

If not then a request will be sent to the Recursive DNS server which is usually provided by your ISP, but you can also choose your own (8.8.8.8 for Google public DNS server for example). This server also has its local cache, if the desired IP for the website is found there then it sends back to the client and your request ends here.

If not then we will go on an adventure to find the Root DNS Servers, these servers are the DNS backbone of the Internet and their only job is redirecting your request to the appropriate Top Level Domain Server (TLD). So if you are looking up for my not-so-amazing but creative website https://anoobishacking.com/ the Root Server will recognise the Top Level Domain of .com and refer you to the correct TLD server that works with .com addresses.

The TLD server holds every record for where to find the authoritative server to answer the DNS request. We can refer to the authoritative servers as name servers also. You will often find multiple nameservers for a domain name to act as a backup in case anything happens to the other.

A nameserver or authoritative server function storing the DNS records for a particular domain name and where any updates to your domain name DNS records would be made.DNS records are then sent back to the Recursive DNS Server, where a local copy will be cached for future requests.DNS as IP packets also has a Time To Live (TTL) value which expires as time passes by and a new request should be made. With caching we can save having to make a DNS request whenever we want to reach out to a website.

DNS Record Types

Source: https://www.thousandeyes.com/blog/guide-to-dns-record-types

We are not going overcomplicate it, to have a general understanding you need to know the followings:

A Record:The simpliest and most common one, this type of record resolves to IPv4 addresses, like 142.250.184.174.

AAAA Record: I am shouting when I am writing this I promise, this type of record resolves to IPv6 addresses, like 2001:0db8:85a3:0000:0000:8a2e:0370:7334.

TXT Record: This type of record is a free text field where any text-based data can be stored.TXT records have multiple uses but the most common ones are list servers that have the authority to send an email on behalf of the domain and to verify ownership of the domain name when signing up for third party services.

MX Record: A mail exchange (MX) record, is a DNS record type that shows where emails for a domain should be routed to. In other words, an MX record makes it possible to direct emails to a mail server. This type of record comes with a priority flag, this tells the client which orders to try the servers, it’s a good option if the main server goes down and an email needs to be sent to the backup server.

CNAME Record: CNAME—or, in full, “canonical name”—is a DNS record that points a domain name (an alias) to another domain. In a CNAME record, the alias doesn’t point to an IP address. And the domain name that the alias points to is the canonical name. For example, the subdomain ng.example.com can point to example.com using CNAME. Here example.com points to the actual IP address using an A record.

NS record: Last one I promise :). A nameserver (NS) record specifies the authoritative DNS server for a domain. In other words, the NS record helps point to where internet applications like a web browser can find the IP address for a domain name. Usually, multiple nameservers are specified for a domain.

The NS record was the last one I wanted to mention but there are many others like DNAME, PTR record, SRV record, and SOA record, I highly recommend you do your research about the other type of records to become more as a professional.

Domain Hierarchy

Source: https://cloudinfrastructureservices.co.uk/what-is-dns-hierarchy/

At the top, we can see the Root Server, remember if the query couldn’t be resolved by looking up the domain in your local cache, or by forwarding it to the authoritative server the query will be forwarded to the Root Server where the location of the TLD servers is being stored.

TLD is the most righthand part of a domain name, and the original idea behind it was to tell us the purpose of the given website for example .edu for education or .gov for government purposes.Nowadays you can find TLDs like .club, .tech, .online..etc.if you want to see the full list of over 2000 TLDs click here.

SecondLevel Domain is the chosen name for the website, if we are analyzing this website then anoobishacking would be the second-level domain and .com would be the TLD. Here I would like to mention that when you are registering a domain name, the second-level domain is limited to 63 characters + the TLD.

Subdomain: A subdomain sits on the left-hand side of the Second-Level Domain using a period to separate it, for example, in the email.annobishacking.com the email part is the subdomain. You can use multiple subdomains split with periods to create longer names and there is no limit to the number of subdomains you can create for your domain name.

This was all for today, I hope that this post was a little bit entertaining and you could get something out of it. If you liked check out my other posts by clicking here.