If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Domain Name System (DNS)

IP addresses are how computers identify other computers on the Internet. IP addresses aren't particularly human-friendly, though. Who wants to memorize an address like 74.125.20.113? Or the even longer IP v6 addresses?
The Domain Name System (DNS) gives us humans an easy way to identify where we want to go on the Internet.
We simply type in a domain name like "www.wikipedia.org", and our computer connects us to the computers powering Wikipedia:
Screenshot of browser with www.wikipedia.org in the URL bar.
A domain name is a human-friendly address for a website, something that's easy for us to remember and type in.

Anatomy of a domain name

Each domain name is made up of parts:
[third-level-domain].[second-level-domain].[top-level-domain]
There are a limited set of top level domains (TLDs), and many websites use the most common TLDs, ".com", ".org", and ".edu".
The second level domain is unique to the company or organization that registers it, like "wikipedia" or "khanacademy".
The third level domain is also called a subdomain, because it's owned by the same group and that URL often directs you to a subset of the website, like "m.wikipedia.org" (mobile-optimized Wikipedia) or "es.khanacademy.org" (Spanish-language Khan Academy).

Domains ↔ IP addresses

Behind the scenes, each domain name maps to an IP address. When we type a URL in the address bar of our browser, the computer has to figure out its IP address.
Diagram of computer with a browser open. The browser displays "www.wikipedia.org" in the URL bar, and the computer has a thought bubble which says "www.wikipedia.org = ?".
The computer can't store a database of more than 300 million domain names locally, so it goes through a multi-step process to find out the IP address.

Step 1: Check the local cache

If you've visited a website once, there's a fairly good chance you'll visit it again. That's why computers keep their own local cache of domain name to IP mappings. The cache stays small, because it kicks out domains you haven't visited in a while or domains that send down expiration dates.
🔍 In the Chrome browser, you can view the database yourself. Just type "chrome://net-internals/#dns" in the address bar.
Here's a snippet from my browser's cache:
Screenshot of DNS cache from Google Chrome, showing 4 URLs mapped to IP addresses

Step 2: Ask the ISP cache

Every ISP (Internet Service Provider) provides a domain name resolving service and keeps its own cache. Perhaps you've never visited a particular website but your neighbor just did, so the ISP can lookup the domain name mapping from their visit.
If it's not in the ISP's cache, then it's off to the next step.

Step 3: Ask the name servers

There are domain name servers scattered around the globe that are responsible for keeping track of a subset of the millions of domain names.
The servers are ordered in a hierarchy:
Root name servers → TLD name servers → Host name servers.
The ISP starts by asking the root name servers: "hey, which name server knows about .org domains?" The root name server responds with the IP address of a TLD name server that tracks ".org" domains.
Diagram with two servers, ISP Domain Resolver on left and Root Name Servers on right. An arrow from the ISP Domain Resolver contains message ".org domains?" and an arrow back from the Root Name Servers contains IP address "199.19.54.1".
Next, the ISP asks the TLD name server: "so, who knows about wikipedia domains?" The TLD name server responds with the IP address of a host name server that contains the "wikipedia" records.
Diagram with two servers, ISP Domain Resolver on left and TLD Name Servers on right. An arrow from the ISP Domain Resolver contains message "wikipedia domains?" and an arrow back from the TLD Name Servers contains IP address "208.80.154.238".
Finally, the ISP asks the host name server: "okay, so where's www.wikipedia.org?" The host name server responds with an exact IP address.
Diagram with two servers, ISP Domain Resolver on left and Host Name Servers on right. An arrow from the ISP Domain Resolver contains message "www.wikipedia.org?" and an arrow back from the Host Name Servers contains IP address "91.198.174.192".
The ISP sends the IP address back to the requesting computer, and now our computer can successfully connect with the computer powering that domain.
Diagram with laptop on left side and ISP server on right side. Arrow from laptop to ISP server has message "www.wikipedia.org?" Arrow from ISP server to laptop has message "91.198.174.192". Laptop shows Wikipedia page loaded.
If that sounds like quite a process: yes, it is! But don't worry, it's not done that often. A lot of information is cached along the way, so it's rare that a DNS lookup has to go through so many steps.
When a lookup does have to go through all the steps, there are multiple name servers that can answer each question, so a computer doesn't have to wait too long for a response or worry about a name server going down.
We've had the domain name system since 1985, and it's scaled impressively to match the growth of the Internet, thanks to its hierarchy, redundancy, and caching.

🙋🏽🙋🏻‍♀️🙋🏿‍♂️Do you have any questions about this topic? We'd love to answer—just ask in the questions area below!

Want to join the conversation?

  • blobby green style avatar for user Tessie Testcase
    when I look at chrome://net-internals/#dns it doesn't show anything beyond a button that says 'Clear host cache' -- nothing like what you have in the lecture. Does this mean that nothing is cached? If so, why would that be the case?
    (29 votes)
    Default Khan Academy avatar avatar for user
  • leaf red style avatar for user layaz7717
    What is the difference between a URL and a domain name?
    (6 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user Shane McGookey
      URL stands for Uniform Resource Locator; a URL is used to identify a resource on a network. A domain name is generally specified in a URL. For example, the URL https://www.khanacademy.org/computing specifies a protocol (Hypertext Transfer Protocol Secure - HTTPS), a domain name (khanacademy.org), and a resource (/computing).

      A domain name is resolved through DNS (Domain Name System) which maps it to an Internet Protocol address. Once the I.P. address has been resolved, your device can locate the resource it wishes to request.
      (12 votes)
  • blobby green style avatar for user Qianqian
    Am I the only person confusing about the TLDs name and root name? As the lecture writes: There are a limited set of top level domains (TLDs), and many websites use the most common TLDs, ".com", ".org", and ".edu", why is that ISP domain resolver needs to ask a root name server about ¨.org¨?
    And finally, is that host name is the same domain name?
    (5 votes)
    Default Khan Academy avatar avatar for user
    • aqualine ultimate style avatar for user Martin
      Think of the web address as a tree with the root being the last part (org, com, and so on) and then growing from there to the left.
      Root name servers are responsible for keeping track of the servers that keep track of the e.g. org domains.
      The process is basically to start at the most general part of the webadress and from there working your way down to the more specific parts. You would probably work the same way if I asked you to search for lyon, france on a map (start by finding europe, then look for france and then you search for lyon).

      In this case yes, there are the same.
      (9 votes)
  • mr pants purple style avatar for user CRTalks
    Why does the ISP domain resolver have to go through 3 steps? Couldn't it just ask what's the IP address for wikipedia.org?
    (5 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user cdias123
    So to understand correctly, essentially when we type in a domain name, the computer we are using is connecting straight to the computer/servers of the site we are accessing? Routed of course through multiple, well, routers (lol).

    I suppose this seems obvious but until a tangible definition was presented I always wondered how that worked. With that information now, it's really quite astounding and fascinating!
    (6 votes)
    Default Khan Academy avatar avatar for user
  • sneak peak green style avatar for user Malycia | Peace
    Why wouldn't the ISP Domain Resolver only ask the hostname server, instead of going through all of the steps to get to asking the hostname server?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • starky tree style avatar for user ro11
    what does it means when some websites blocked?
    and why it can be accessed by using public dns?
    i know this is basic lesson so maybe what im asking not in the right place
    (3 votes)
    Default Khan Academy avatar avatar for user
    • aqualine ultimate style avatar for user Martin
      It might mean that you have a content blocker on your system, that prevents you from accessing certain websites. That's done by specifying those sites, if the blocker is badly implemented you might circumvent the blocker in which case a DNS will just point you to the site.
      (3 votes)
  • blobby green style avatar for user 24deshpande3
    What is the difference between local cache and ISP cache?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • sneak peak yellow style avatar for user just coding coding coding
    Is cache stored on Ram.
    (2 votes)
    Default Khan Academy avatar avatar for user
  • leaf orange style avatar for user 005319114naw
    what is DNS over Http? Also Does it safe to use third-party DNS and how to use third-party DNS?
    (1 vote)
    Default Khan Academy avatar avatar for user