DNS Record Types Explained
How browser know where a website live
DNS record explained in very easy words
When I type a website name like google.com in browser and press enter, the website open very fast I never write any IP address Still the website comes So one question come in mind that how does the browser knows where the Website live and the answer is known as DNS
What is DNS
Its fullform is Domain Name Stystem DNS is like phonebook of internet People like to remember names like eg : google.com but computer only understand numbers like: 142.250.78.63. DNS change website name into number so computer can find the website. Like in phone we save name and phone save number inside, DNS also save website name with number.
Without DNS, internet will be very confusing.
Why DNS records are needed
DNS is not only one thing. Website need many things like:
website address
email address
who control domain
some verification
So DNS use records DNS is like a folder and records are files inside it.
Each record do one work.
What is NS record
NS means Name server NS record tell who will control the domain example:-
chaicode.com -> ns1.cloudfare
This mean Cloudflare control the DNS of this website.
eg:- like telling The house is under the office NS record tell who is boss of domain.
Browser → DNS → Server (high-level flow)
User->>DNS: Where is example.com? DNS-->User: It's at 192.0.2.1 User->Server: HTTP Request to 192.0.2.1 Server-->User: Returns website data
What is A record
A record means Address record. It is use to tell the browser what is the IP address of a website When we type a domain name in browser, the browser cannot understand name it only understand number. A record change the domain name into IPv4 address so browser can reach the correct server for eg you can think A record like home address of a person without address nobody can find the house.
eg :- chaicode.com→ 104.21.44.88
What is AAAA record
AAAA record is same like A record but it give IPv6 address instead of IPv4. IPv6 is new type of IP address because old IPv4 address are getting finished slowly. Some websites use both A and AAAA record. If browser support IPv6 then it use AAAA record, otherwise it use A record. AAAA record help internet work in future also.
for eg:- chaicode.com → 2606:4700; :6815 : 2c59
What is CNAME record
CNAME record means Canonical Name. It is used when one domain name is pointing to another domain name. For example www.example.com can point to example.com. This means both names are same website. CNAME is useful because we do not need to create many A records again and again. It make DNS management more easy.
for eg:- www.pyushsirfullstackaiudemy.com → pyushsirfullstackaiudemy.com
What is MX record
MX record means Mail Exchange record. It is used to decide where the emails of a domain should go. When someone send email to name@domain.comMX record tell which mail server will receive that email. Website server and email server are different so MX record make sure email not go to website server by mistake. Without MX record, emails will not work properly.
for eg:- hitesh.aicohort.com → mail.google.com
sequence diagram:
Sender->DNS: Who handles emails for @example.com? DNS-->Sender: MX Record: mail.example.com (Priority 10) Sender->DNS: What is the IP of mail.example.com? DNS→Sender: A Record: 198.51.100.1 Sender->MailServer: delivers Email
What is TXT record
TXT record store simple text information related to domain. It is mostly used for verification and security purpose many services ask to add TXT record to prove that you are owner of domain TXT record is also used for email security like preventing spam you can think TXT record like proof paper of a website.
eg:- take it as an identity card for domain
How all DNS records work together
For one website many DNS records work together NS record decide who control the DNS A and AAAA record tell where the website server is CNAME record handle other names of website MX record manage emails and TXT record help in verification and security. All records have different work but together they make website and email work smoothly.