Kodokon kodokon.com

URLs, domain names and DNS

Take a web address apart and meet the giant directory that turns names into IP addresses.

7 min · 3 questions

Open this lesson in Kodokon

A URL is the full address of a resource on the web. Like a postal address, it reads in pieces, from the most general to the most specific: the country, the city, the street, the number, the floor. Each piece of a URL has a name and a precise role, and being able to name them will serve you every single day.

TEXT
https://en.wikipedia.org/wiki/HTML?action=history#History

protocol    : https
domain      : en.wikipedia.org
path        : /wiki/HTML
parameters  : ?action=history
fragment    : #History
The five pieces of a URL. Only the protocol and the domain are required.

The protocol (https) states which language the two machines are going to speak. The domain says which machine to talk to. The path points to the exact resource on that machine, just like a path through folders. The parameters, introduced by a question mark, pass information to the server (a search term, a page number). The fragment, introduced by a hash sign, is never sent to the server at all: it only tells the browser where to scroll on the page.

The domain name itself reads right to left. In en.wikipedia.org, the rightmost part, org, is the extension (also called the top-level domain). Then wikipedia is the name the organization bought. Finally en is a subdomain, which the owner is free to add to point at a particular machine or service. That is why wikipedia.org and en.wikipedia.org belong to the same owner, whereas wikipedia.org.example.net belongs to whoever owns example.net.

One problem: the network only understands IP addresses. So we need a directory able to translate wikipedia.org into 185.15.59.224. That worldwide directory is called DNS (Domain Name System). Before every visit, your machine queries a DNS server, gets the IP address back, and only then contacts the site. You can run that translation by hand.

BASH
dig +short wikipedia.org

185.15.59.224
On Windows, use nslookup wikipedia.org. The address you get back may vary by country.

Knowledge check

Make sure you remember the key points of this lesson.

  1. Fill in the URL: you want to pass the parameter id=12 to the server.
    curl -s "https://example.com/page___id=12"
    • #
    • ?
    • &
    • :
  2. What is DNS for?
    • Encrypting the exchange between the browser and the server
    • Translating a domain name into an IP address
    • Storing the web pages of the sites you visit
  3. You get a link to https://taxoffice.gov.refund-2026.top/form. Which site will you land on?
    • On taxoffice.gov, the official site
    • On refund-2026.top, a third-party site
    • On both, the link is shared