Skip to content

Web & Internet

DNS (Domain Name System)

O(1) lookup in a simple table like ours. Real DNS involves several hops between servers, but it works the same way underneath.

The idea, in plain English

DNS (Domain Name System) is the internet's phone book. Computers don't actually go to 'example.com'. They go to a numeric address called an IP (Internet Protocol) address, like 93.184.216.34. DNS is the lookup service that turns the easy-to-remember name you type into the number your computer needs to connect.

How it works

  1. 1You type a domain name, like example.com, into your browser.
  2. 2Your computer asks a DNS server: 'What is the IP address for this name?'
  3. 3The DNS server looks it up in its records and returns the matching IP address.
  4. 4Your browser then connects directly to that IP address to load the page.

When you'd use it

This happens every time you visit a website by typing its name instead of a raw IP address. That's almost always, since nobody memorizes strings of numbers.

Common beginner mistakes

  • Don't forget that DNS results can be cached, meaning remembered for a while. That's why a site can 'still work' briefly right after its DNS record changes, or why a change can take time to spread to everyone.
  • Don't confuse a domain name with the website itself. The domain is just a label. DNS's only job is to point that label at an address.

Try it — edit and run

Click the code to edit · press ⌘/Ctrl+↵ to run

Editable code. Tab and Shift+Tab indent. Press Escape, then Tab, to move focus out of the editor.

Expected output — hit Run to try it
example.com -> 93.184.216.34
devpath.app -> 127.0.0.1
unknown.test -> not found

Not sure this is the right topic? See the learning paths → or where this leads →