- Published on
Almost Everything About Domain Name System (2)
- Authors
- Name
- hwahyeon
At the request of a client, I terminated their existing domain and connected a new one. In this case, the client's hosting provider, domain registrar, email service provider, and previous web development company were all separate entities. This time, I unified all these elements into a single system as I started a new web development project for this company. While working on the project, I took the opportunity to organize and clarify the domain-related knowledge that had previously been tangled in my mind. So, I decided to write this series.
Through this series, you’ll gain a clear and comprehensive understanding of almost everything related to domains.
The table of contents for this series is as follows:
- Part 1: Covers domains, TLDs, registries, the process of finding a domain in a browser, and more.
- Part 2: Discusses A records, CNAME records, NS records, name servers, domain resellers, hosting providers, and more.
- Part 3: Explores caching, MX records, resolvers, and more.
Table of Contents
Contents of a Domain Server
Are the IP addresses and domain names stored in a domain server a type of database (DB)? At the very least, the information stored in a domain server clearly has the characteristics of a database. This is because DNS operates by mapping domain names (Keys) to IP addresses (Values), which is very similar to the Key-Value structure of a database.
However, domain servers do not store only IP addresses and domain names. There are various other types of records. Let’s explore them.
What is an A Record?
Before diving into the various types of records, let’s start with the most basic one: the A Record (Address Record).
As mentioned earlier, DNS servers map domain names to IP addresses. This mapping is precisely what the A Record does. The A Record maps a domain name to an IPv4 address and works as follows:
- Example:
www.google.com
→142.250.190.78
When a query is sent for www.google.com
, the DNS server returns 142.250.190.78
.
Additionally, if the domain uses an IPv6 address, the AAAA Record is used instead of an A Record.
What is a CNAME Record?
A CNAME Record maps one domain to another domain name. It acts as an alias, allowing multiple domains to point to the same IP address or server.
For example, if you want to connect www.example.com
to example.com
, you can use a CNAME Record. This way, accessing www.example.com
will automatically redirect users to example.com
.
- Example:
www.example.com
→example.com
Ultimately, a CNAME Record references an A Record or AAAA Record to retrieve the final IP address.
Overall Browser Request Process
When a browser connects to example.com
, the DNS server follows these steps.
- CNAME Record Check
The DNS server checks if there is a CNAME record for the requested domain. If a CNAME record exists, the query is redirected to the domain specified in the CNAME record (e.g., alias.example.net
).
- Recursive Query
If the CNAME record points to another CNAME record, the query continues recursively until an A record or another type of record is found. If a query needs to follow multiple CNAME records (CNAME chaining), the request might fail depending on the recursive query processing limits of the DNS server.
- A Record Retrieval
Once the A record is identified, the corresponding IP address is returned to the browser.
(If the domain uses IPv6, an AAAA record may be returned instead of an A record.)
DNS is a hierarchical and distributed system, unlike a simple spreadsheet structure, but for clarity, a spreadsheet-like representation of DNS records is used here.
Domain Name | Record Type | Value |
---|---|---|
example.com | A | 192.0.2.1 |
alias.example.com | CNAME | example.com |
In this example, alias.example.com
connects to example.com
via its CNAME record, and the A record for example.com
provides the final IP address: 192.0.2.1.
What is an NS Record?
Before diving into NS records, let’s revisit the concept of a name server. Any server involved in the process of converting a domain name into an IP address is called a "name server." Examples include the root name server, Top-Level Domain (TLD) name server, and authoritative name server, all of which are types of name servers. An NS Record (Name Server Record) specifies the location of the name servers responsible for managing a particular domain. In other words, an NS record contains information about where the domain's name servers are located.
For example:
- The root name server knows the location of TLD name servers (e.g.,
.com
,.net
,.org
).- If a
.com
domain is requested, the root name server returns the location of the.com
TLD name server.
- If a
- The TLD name server stores NS records for domains like
example.com
.- These NS records indicate the location of the authoritative name servers managing
example.com
(e.g.,ns1.provider.com
,ns2.provider.com
).
- These NS records indicate the location of the authoritative name servers managing
Summary of the Query Process
User Requests a Domain (example.com
)
- Root Name Server Query
- The browser asks the root name server, "Where is the TLD name server that manages
.com
?" - The root name server responds with the NS record for the
.com
TLD name server (e.g.,a.gtld-servers.net
) and its corresponding IP address to enable direct communication.
- TLD Name Server Query
- The browser then queries the
.com
TLD name server, "Where is the name server that managesexample.com
?" - The TLD name server responds with the NS records for
example.com
(e.g.,ns1.provider.com
,ns2.provider.com
).
- Authoritative Name Server Query
- The browser sends a query to one of the returned name servers (e.g.,
ns1.provider.com
). - The authoritative name server responds with the final data, such as the A record (IP address) or CNAME record.
Domain Resellers and TLD Name Servers
In the first post, it was explained that domains must be purchased through a reseller. It was also mentioned that TLD registries are organizations responsible for managing specific TLDs (e.g., .com
, .org
, .net
). A reseller acts as an intermediary that registers the domain purchased by a customer with the corresponding TLD registry.
For example, if a customer buys example.com
, the reseller forwards the domain information to the .com
TLD registry managed by Verisign. During this process, NS records (name server information) are configured, and the domain registration is completed. When example.com
is purchased, the initial name servers are typically the authoritative name servers provided by the domain registrar (reseller). In other words, this name server information (NS records) is stored in the .com
TLD registry's database, allowing the TLD name server to guide the query to the reseller's authoritative name server.
Example: Domain Registration and Connection Process
Let’s assume a customer registers the domain example.com
with GoDaddy.
- Domain Registration and NS Record Setup
- GoDaddy sets its own authoritative name servers as the NS records for
example.com
.
Example:
NS1.GODADDY.COM
NS2.GODADDY.COM
- Registration with the TLD Registry
- This NS record information is registered in the
.com
TLD registry, enabling the.com
TLD name server to know the location ofexample.com
's name servers.
- Browser Request Handling
- When a browser attempts to access
example.com
, the.com
TLD name server returns the NS record forNS1.GODADDY.COM
. - The browser queries GoDaddy's authoritative name server (
NS1.GODADDY.COM
), which responds with the IP address (A record) forexample.com
.
Example: 192.168.1.1
- Website Connection
- Using the returned IP address, the browser connects to the
example.com
website.
The Role of Hosting Providers
A hosting provider is a company that stores a website's files, data, and applications, making them accessible via the internet. Simply put, if a domain is a website's address, hosting is the place where the actual content (files, data, etc.) seen when visiting that address is stored. Additionally, hosting providers often offer their own name servers.
Example: Separating Domain Registrar and Hosting Provider
When the domain example.com
is registered with GoDaddy but the website data is hosted with Bluehost, the NS records can be updated. The default NS records provided by GoDaddy can be replaced with Bluehost's name servers (e.g., NS1.BLUEHOST.COM
, NS2.BLUEHOST.COM
).
During this process, the name servers initially provided by GoDaddy (e.g., NS1.GODADDY.COM
, NS2.GODADDY.COM
) are replaced in the .com
TLD registry's database with the new name servers (NS1.BLUEHOST.COM
, NS2.BLUEHOST.COM
).
Using the Registrar's Default Name Servers
If the domain remains on the registrar’s default name servers and only the hosting server's IP address is linked to the domain, there might be limitations depending on the registrar's DNS management features. For instance, some registrars offer limited DNS configuration options or charge extra fees for certain features, such as setting up MX records.
However, some registrars provide user-friendly DNS management tools that allow you to configure A records, CNAME records, and MX records without additional costs. Therefore, it’s possible to manage DNS settings without changing the name servers in some cases.
Despite this, using the hosting provider's name servers is recommended because it allows you to manage all DNS settings, including website data, email, and subdomains, in one place, which is much more convenient.