本文中我们讨论了域名是什么,域名是如何被构建的,以及如何获得一个域名。

前提: 首先你得知道 互联网是怎么工作的 并理解 什么是URL
目标: 学习域名是什么,域名的工作方式,以及域名的重要性。

概述

域名(Domain names)是互联网基础架构的关键部分。它们为互联网上任何可用的网页服务器提供了人类可读的地址。

任何连上互联网的电脑都可以通过一个公共IP地址访问到,对于IPv4来说,这个地址由32位组成(它们通常写成四个范围在0~255以内,由点分隔的数字组成,比如173.194.121.32),而对于IPv6来说,这个地址由128位组成,通常写成八组由冒号分隔的四进制数(e.g., 2027:0da8:8b73:0000:0000:8a2e:0370:1337). 计算机可以很容易地处理这些IP地址, 但是对一个人来说很难找出谁在操控这些服务器以及这些网站提供什么服务。IP 地址很难记忆而且可能会随着时间的推移发生改变 。为了解决这些问题,我们使用人类可读的地址,称作域名。

Active Learning

There is no active learning available yet. Please, consider contributing.

Deeper dive

域名的结构

一个域名是由几部分(有可能只是一部分,也许是两部分,三部分...)组成的简单结构,它被点分隔,并需要从右到左阅读

Anatomy of the MDN domain name

每一部分都提供了整个域名的特定信息。

TLD (Top-Level Domain,顶级域名)
顶级域名提供了最多的信息。顶级域名告诉用户通用服务背后的域名。最通用的顶级域名(.com, .org, .net)不需要web服务器满足严格的标准,但一些顶级域名则执行更严格的政策。比如本地的顶级域名,如.us,.fr,或.sh,可以要求必须提供给定语言的服务器或者托管在指定国家。
Label (or component)
The labels are what follow the TLD. A label can be anything, from one letter to a full sentence. The label located right before the TLD can also be referred as a Secondary Level Domain (SLD). A domain name can have many labels (or components), it is not mandatory nor necessary to have 3 labels to form a domain name. For instance, www.inf.ed.ac.uk is a correct domain name. When controlling the "upper" part of a domain name (e.g. mozilla.org), one can create other domain names (sometimes called "subdomains") (e.g. developer.mozilla.org).

购买域名

谁拥有域名?

你不能 “购买一个域名”,你只能花钱获得一个域名在一年或多年内的使用权。你可以更新你的使用权,然后你的更新将优先于其他人的使用申请。但你从来都没有拥有过域名。

Companies called registrars use domain name registries to keep track of technical and administrative information connecting you to your domain name.

提示 : For some domain name, it might not be a registrar which is in charge of keeping track. For instance, every domain name under .fire is managed by Amazon.

找个可用的域名

想要知道一个给定的域名是否可用,

  • 去域名注册商的网站。它们大多会提供"whois"服务,告诉你一个域名是否可用。
  • 另外,如果你使用系统的内置shell,在里面输入whois命令,下面显示的是mozilla.org网站的结果:
$ whois mozilla.org
Domain Name:MOZILLA.ORG
Domain ID: D1409563-LROR
Creation Date: 1998-01-24T05:00:00Z
Updated Date: 2013-12-08T01:16:57Z
Registry Expiry Date: 2015-01-23T05:00:00Z
Sponsoring Registrar:MarkMonitor Inc. (R37-LROR)
Sponsoring Registrar IANA ID: 292
WHOIS Server:
Referral URL:
Domain Status: clientDeleteProhibited
Domain Status: clientTransferProhibited
Domain Status: clientUpdateProhibited
Registrant ID:mmr-33684
Registrant Name:DNS Admin
Registrant Organization:Mozilla Foundation
Registrant Street: 650 Castro St Ste 300
Registrant City:Mountain View
Registrant State/Province:CA
Registrant Postal Code:94041
Registrant Country:US
Registrant Phone:+1.6509030800

正如你所见,我不能注册mozilla.org,因为Mozilla基金会已经注册它了。

另外,如果你想看看我能不能注册afunkydomainname.org:

$ whois afunkydomainname.org
NOT FOUND

正如你所见,(在本文写作时)这个域名在whois数据库中不存在,所以我们可以要求去注册它。祝你好运吧!

获得一个域名

过程很简单:

  1. 去域名注册商的网站。
  2. 通常那些网站上都有突出的"获得域名"宣传,点击它。
  3. 按要求仔细填表。一定要仔细检查你是否有将你想要的域名拼错。一旦你给错误域名付款了,便为时已晚!
  4. 注册商将会在域名正确注册后通知你。数小时之内,所有DNS服务器都会收到你的DNS信息。

提示: In this process the registrar asks you for your real-world address. Make sure you fill it properly, since in some countries registrars may be forced to close the domain if they cannot provide a valid address.

DNS refreshing

DNS databases are stored on every DNS server worldwide, and all these servers refer to a few ones called “authoritative name server” or “top-level DNS servers.” Whenever your registrar creates or updates any information for a given domain, the information must be refreshed in every DNS database. Each DNS server that knows about a given domain stores the information for some time before it is automatically invalidated and then refreshed (the DNS server queries an authoritative server again). Thus, it takes some time for DNS servers that know about this domain name to get the up-to-date information.

Note : This time is often called propagation time. However this term is not precise since the update is not propagating itself (top → down). DNS servers queried by your computer (down) are the ones that fetch the information from the authoritative server (top) when they need it.

DNS请求如何工作?

As we already saw, when you want to display a webpage in your browser it's easier to type a domain name than an IP address. Let's take a look at the process:

  1. 在你的浏览器地址栏输入mozilla.org。
  2. Your browser asks your computer if it already recognizes the IP address identified by this domain name (using a local DNS cache). If it does, the name is translated to the IP address and the browser negotiates contents with the web server. End of story.
  3. If your computer does not know which IP is behind the mozilla.org name, it goes on to ask a DNS server, whose job is precisely to tell your computer which IP address matches each registered domain name.
  4. Now that the computer knows the requested IP address, your browser can negotiate contents with the web server.

Explanation of the steps needed to obtain the result to a DNS request

下一步

Okay, we talked a lot about processes and architecture. Time to move on.

文档标签和贡献者

 此页面的贡献者: zhangjy90, ziyunfei, wth
 最后编辑者: zhangjy90,