Skip to content

Under the hood

What is DNS? How domain names work, explained simply

DNS is the internet's phone book: it turns domain names into the IP addresses computers use. How DNS works, the parts of a domain, and why you rent one.

By the GenKid team · · Updated · Facts checked · 5 min read

Key takeaways

  • DNS (the Domain Name System) is the internet's phone book: it turns domain names like example.com into the numeric IP addresses computers use to find each other.
  • Domain names exist because IP addresses are hard to remember and can change.
  • Domains are read from right to left: the top-level domain (like .com or .uk), then the name, then any subdomains.
  • You don't buy a domain outright: you rent it from a registrar for a year or more and renew it.
  • DNS changes can take a while to reach everyone, usually minutes to a few hours, because answers are cached.

What is DNS?

DNS, the Domain Name System, is the internet's phone book: it turns a domain name like `example.com` into the numeric IP address that computers use to find the server behind it. Every time you visit a website, your device uses DNS to look up where to connect.

Every server on the internet has an IP address, a number like 192.0.2.172. Computers use these to find each other. But numbers are hard to remember and can change. So we use domain names, like genkid.app or developer.mozilla.org, as human-friendly labels, and DNS keeps track of which label points to which number. The server at the other end is where an app's back end runs.

How a DNS lookup works

DNS is a huge, distributed directory, spread across many servers. Here's what happens when you visit a site, as MDN explains:

  1. Your browser checks whether it already knows the IP address (from a recent visit; this is called the cache).
  2. If not, your computer asks a DNS server: "What's the address for this domain?"
  3. The DNS server finds the answer (asking other servers if needed) and replies with the IP address.
  4. Your browser connects to that address and requests the page.

All of this usually takes a fraction of a second.

Because DNS servers keep (cache) answers for a set time, called the record's TTL (time to live), changes to a domain's settings take a while to reach everyone: usually minutes to a few hours, depending on the TTL. MDN says that, for a new registration, all DNS servers will have the information within a few hours. That's why developers sometimes say "wait for DNS to propagate".

The parts of a domain

Domains are read from right to left:

developer.mozilla.org
   │        │      └── top-level domain (TLD)
   │        └───────── the main name
   └────────────────── subdomain
  • Top-level domain (TLD) — the last part, like .com, .org, .app or a country code like .uk or .fr. Some TLDs have rules: names ending in .gov are for government bodies, for example.
  • The main name — the part you choose, like mozilla.
  • Subdomains — extra labels on the left, like developer, which the domain's owner can create freely.

Each label can contain letters, numbers and hyphens, but can't start or end with a hyphen.

You rent, you don't buy

You can't buy a domain forever. You pay a registrar — a company that sells domain registrations — for the right to use a domain for one or more years. You can renew it, and current owners get priority. If you stop paying, it eventually becomes available to someone else.

MDN explains the reasoning: it stops unused names being locked up forever. It also means it's worth setting renewal reminders for any domain you care about.

Connecting a domain to a website

To use a domain for your site, you add DNS records that point it at your hosting service. The most common are:

RecordWhat it does
APoints a name to an IPv4 address
AAAAPoints a name to an IPv6 address
CNAMEPoints a name to another name (for example your host's address)
TXTStores text, for example email security settings or a code that proves you control the domain

Hosting services usually tell you exactly which records to add. Every record also has a TTL, which sets how long DNS servers may keep a copy before checking again (Cloudflare's guide to DNS records explains each type).

Domains, safety and honesty

  • Watch for look-alike domains. Scammers register names that look like real ones, swapping letters or adding extra words, to trick people. Check addresses carefully, especially before signing in. The same trick is used with code: see fake packages and supply-chain attacks.
  • Registering a domain is an adult's job. It involves a contract with a registrar, payments and personal details such as a real postal address, so it's a decision for a parent or guardian.
  • HTTPS — the padlock — means the connection is encrypted, not that the site is trustworthy. Scam sites can have padlocks too. Most hosting services set up HTTPS for you.

Learning about domains

GenKid covers domains, DNS and HTTPS in its Level 4 course on domains and security, with any real registration left to a parent or guardian. Younger learners meet the same ideas through simulated deploys. See the pathway or read more about front end vs back end.

Frequently asked questions

How long does DNS propagation take?

Usually minutes to a few hours. Each DNS server keeps a copy of a record for as long as its TTL allows, then checks again, so how quickly a change reaches everyone depends on the TTL that was set. If a change still hasn't shown up after a day, check the records for typos.

What's the difference between a domain registrar and a web host?

A registrar rents you the domain name; a [web host](/blog/what-is-web-hosting) runs the computer that stores and serves your site. They can be the same company or different ones. DNS records are what connect the two, by pointing your domain at your host.

What is a DNS server?

A computer whose job is to answer "which IP address goes with this domain?". Your internet provider, school or a public service usually runs the one your device asks first, and it asks other DNS servers if it doesn't already know the answer.

Can I get a domain for free?

Not a full domain of your own: those are rented from a registrar. But many hosting services give each project a free address on their own domain, such as a subdomain ending in the host's name, which is enough for learning and sharing with family.

Sources

  1. What is a domain name? (opens in a new tab) — MDN Web Docs
  2. What is DNS? (opens in a new tab) — Cloudflare Learning Center
  3. What is a DNS record? (opens in a new tab) — Cloudflare Learning Center

How we write: GenKid articles are researched and drafted with the help of AI tools, then checked in a separate review step against the sources listed above before they are published, and re-checked when they are updated. Rules and products change, so check official pages for your country before acting on anything here. This article is general information, not legal advice. Spotted a mistake? Email hello@genkid.app.

Under the hood

Front end vs back end: what's the difference?

The front end is the part of an app you see and use; the back end runs on a server and stores data. A simple guide, and why the split matters for safety.

5 min read

Safety & privacy

What is slopsquatting? Fake AI packages explained

Slopsquatting is when attackers publish malicious packages under names AI coding tools invent. Learn why it happens and six checks before installing a package.

4 min read