brainax

Domain and DNS

Lesson 14 of 26 in the course “Vibe coding”. Free, with animations and a quiz.

A domain: a site name you rent

A domain is a human-friendly site name, like mysite.com. You don't buy it forever: you rent it for a year or several from a registrar, a company that sells domains. Forget to renew and the name can go to someone else. Example: you run a sticker shop. The hosting link is long and ugly, while your own domain is easy to remember and put in your bio. Check whether paying the registrar works in your country.

DNS: the internet's address book

Computers on the network find each other by IP address, a set of numbers. Example from the figure: 203.0.113.10, a range set aside just for teaching examples. Numbers like that are hard to remember. DNS is the internet's address book. Someone types mysite.com, the browser asks DNS where that is, gets the IP address and goes to the right server. That's the path in the figure: browser → DNS card → server.

Three main records: A, CNAME, TXT

A DNS record is one line in the address book. A: a name points to a server's IP address. CNAME: a name points to another name. Example from the figure: www.mysite.com points to your project on the hosting. Subdomains work the same way, meaning names in front of the main one, like shop.mysite.com: each has its own record. TXT: a text note used to prove the domain is yours and to set up email.

Connecting the domain to hosting

Step 1: add your domain in the hosting dashboard. Step 2: the hosting shows which records to create, like A or CNAME, and with what values. Step 3: create them at your DNS provider, the service that stores your domain's records. Often that's the registrar or Cloudflare. Step 4: wait, changes usually spread across the internet in anywhere from minutes to a few hours. Then the hosting issues SSL by itself and the lock appears.

Two beginner mistakes

First: deleting records you don't understand. If the domain has email, it relies on MX records (they say where to deliver mail) and TXT. Delete them and mail stops arriving. Before editing, take a screenshot of all records so you can put things back. Second: taking a domain with a famous brand's name, like someone else's sneaker store. The brand owner can take the domain away through a dispute. Come up with your own name.

Check yourself

  1. What does a CNAME record do?
    Correct answer: Points one name to another name. CNAME is name → name, like www → your project on the hosting. Name → IP address is what an A record does.
  2. You added the records, but the domain doesn't open the site yet. Why?
    Correct answer: DNS changes can take up to a few hours to spread. DNS records don't spread across the internet instantly: usually minutes to a few hours. Wait and check again.
  3. Why screenshot your DNS records before editing?
    Correct answer: To restore things if email breaks. MX and TXT records keep email working. If you delete them by accident, the screenshot lets you restore everything exactly.

← Vercel: import in a minute Database and sign-in →