Thuta Learning
BasicDevOps & Toolsbeginner

Domains and DNS Basics

What you'll walk away with

  • Explain the core ideas behind Domains and DNS Basics
  • Read the diagram and trace how a request or data flows through the architecture
  • Explain what this means for your own project's decisions

Build the mental model

A domain like thutatech.com is really made of labeled pieces, and learning to read them helps everything else about hosting make sense.

PieceMeaning
com (rightmost)The top-level domain (TLD) -- a category like org, io, uk, or mm.
thutatech (middle)The domain itself, registered and owned by an organization.
learn (front)A subdomain -- a free subdivision of the domain the owner can create.

DNS is the system that maps these human-readable names to real servers. The two record types you will run into constantly are A records, pointing a name at an IP address, and CNAME records, pointing a name at another name. The Networking tutorial on this site covers the full record type list and resolution mechanics in depth.

  • Registrar -- where you buy and legally own a domain name (Namecheap, GoDaddy)
  • Host -- where your actual application or files live
  • DNS -- the bridge connecting the registrar's domain to the host
Domain
The registered name an organization owns -- like thutatech in thutatech.com.
Subdomain
A free subdivision of a domain -- like learn in learn.thutatech.com.
DNS
The system that maps domain names to real internet resources like IP addresses.
text
ANATOMY OF A HOSTNAME
---------------------
      learn   .   thutatech   .   com
        |            |            |
    subdomain      domain         TLD
   (optional)    (registered)  (top-level)

 REGISTRAR (you own the name)   vs   HOST (app lives here)
   e.g. Namecheap, GoDaddy             e.g. Vercel, AWS, DigitalOcean
              |                                    |
              +--------- DNS record links them ----+

Connect it to a real scenario

The parseHostname function below takes a full hostname string and splits it into its subdomain, domain, and top-level domain pieces, the same breakdown this lesson just walked through in prose. It splits the hostname on every dot, then reasons from the right side: the very last piece is always the TLD, the piece before that is the domain, and anything left over at the front, possibly more than one label, is treated as the subdomain. Running it against thutatech. com, learn. thutatech.

com, and api. staging. thutatech. com shows the pattern clearly: a bare domain has no subdomain at all, a single label like learn becomes the subdomain, and multiple labels like api.

staging get joined back together as one subdomain value. This is a simplified parser meant to build intuition, not a production-grade implementation; real hostname parsing has extra edge cases, such as TLDs that are themselves two labels like co. uk, which this simple version does not handle. The goal here is pattern recognition: once you can mentally split any hostname into these three pieces on sight, DNS records and hosting configuration both make noticeably more sense.

Try the working example

javascript
function parseHostname(hostname) {
  const parts = hostname.split(".");
  if (parts.length <= 2) {
    return { subdomain: null, domain: parts[0], tld: parts[1] };
  }
  const tld = parts[parts.length - 1];
  const domain = parts[parts.length - 2];
  const subdomain = parts.slice(0, parts.length - 2).join(".");
  return { subdomain, domain, tld };
}

const hosts = ["thutatech.com", "learn.thutatech.com", "api.staging.thutatech.com"];

for (const host of hosts) {
  const { subdomain, domain, tld } = parseHostname(host);
  console.log(`${host} -> subdomain: ${subdomain}, domain: ${domain}, tld: ${tld}`);
}
You should see
thutatech.com -> subdomain: null, domain: thutatech, tld: com
learn.thutatech.com -> subdomain: learn, domain: thutatech, tld: com
api.staging.thutatech.com -> subdomain: api.staging, domain: thutatech, tld: com

5-minute try-it

Add a new hostname, "blog.learn.thutatech.com", to the hosts array, run it, and confirm the subdomain value comes back with two labels joined together.

One important caution

Assuming buying a domain automatically includes hosting -- confusing a registrar with a host

Treating a subdomain as an entirely separate domain, ignoring that its DNS configuration still depends on the parent domain

MDN Glossary: Domain nameCloud & Deployment

Easy traps

  • Assuming buying a domain automatically includes hosting -- confusing a registrar with a host
  • Treating a subdomain as an entirely separate domain, ignoring that its DNS configuration still depends on the parent domain
  • Never assume that working on localhost means it will work in production -- environment, network, database, and security differences can all bite.

Exercise

Add a new hostname, "blog.learn.thutatech.com", to the hosts array, run it, and confirm the subdomain value comes back with two labels joined together.

You'll know it worked when: thutatech.com -> subdomain: null, domain: thutatech, tld: com learn.thutatech.com -> subdomain: learn, domain: thutatech, tld: com api.staging.thutatech.com -> subdomain: api.staging, domain: thutatech, tld: com

Domains and DNS Basics | Thuta Learning