DNS

把主机名转换为ip地址

DNS查找步骤

  1. 用户在 Web 浏览器中键入 “example.com”,查询传输到 Internet 中,并被 DNS 递归解析器接收。

  2. 接着,解析器查询 DNS 根域名服务器(.)。

  3. 然后,根服务器使用存储其域信息的顶级域(TLD)DNS 服务器(例如 .com 或 .net)的地址响应该解析器。在搜索 example.com 时,我们的请求指向 .com TLD。

  4. 然后,解析器向 .com TLD 发出请求。

  5. TLD 服务器随后使用该域的域名服务器 example.com 的 IP 地址进行响应。

  6. 最后,递归解析器将查询发送到域的域名服务器。

  7. example.com 的 IP 地址而后从域名服务器返回解析器。

  8. 然后 DNS 解析器使用最初请求的域的 IP 地址响应 Web 浏览器。

  9. DNS 查找的这 8 个步骤返回 example.com 的 IP 地址后,浏览器便能发出对该网页的请求:

  10. 浏览器向该 IP 地址发出HTTP请求。

  11. 位于该 IP 的服务器返回将在浏览器中呈现的网页

dns

Domain name syntax

A domain name consists of one or more parts, delimited by dots, such as: example.com

域名的最右边部分表示top-level domain, 比如:www.example.com belongs the top level domain com

域名系统会把一个域名的每一个部分组成一个树形结构,右边的部分在树的根部,从右向左的左边部分成为这个根的子树。The hierarchy of domains descends from right to left; each label to the left specifies a subdivision, or subdomain of the domain to the right. For example, the label example specifies a subdomain of the com domain, and www is a subdomain of example.com. This tree of subdivisions may have up to 127 levels.

Name servers

Each domain has at least one authoritative DNS server that publishes information about that domain and the name servers of any domains subordinate(下级) to it. 至少一个name server包含domain的信息和它的下级domain

The top of the hierarchy is served by the root name servers, the servers to query when looking up (resolving) a TLD

Authoritative name server

这是位于 DNS 查找链底部的服务器,其将使用所查询的资源记录进行响应,从而最终允许发出请求的 Web 浏览器达到访问网站或其他 Web 资源所需的 IP 地址。权威性域名服务器从自身数据满足查询需求,无需查询其他来源,因为这是某些 DNS 记录的最终真实来源。

就是可以直接查到域名的服务器,而不需要再请求别的服务器。

wiki:An authoritative name server is a name server that only gives answers to DNS queries from data that has been configured by an original source, for example, the domain administrator or by dynamic DNS methods, in contrast to answers obtained via a query to another name server that only maintains a cache of data.

Recursive and cache name server

DNS查找从root服务器开始查找一直递归查找直到从Authoritative name server得到ip地址,进行这个查找过程的服务器叫Recursive server.

Recursive server查找到域名信息时可以把这些信息缓存到本地,这个操作叫cache, 这个服务器就叫做cache name server

一般Recursive servercache name server是同一台服务器

DNS resolvers

The client side of the dns is called a dns reolver

DNS resolvers 有很多种类型:recursive, none-recursive and iterative. 一次dns查找可能会用到这几种方式

non-recursive: 这个dns服务器本身就是authoritavie,就是说它自己本身就有相关的dns记录可以直接返回给查询者

recursive: 为了查找某个dns,要去别的服务器找找这个dns

iterative:为了查看找某个dns,会依次查询好几个dns服务器直到找到这个dns

dns resolvers

Record caching

管理员可以在authoritavie dns server为域名设置一个TTL表示缓存超时

Reverse lookup

dns反查,通过ip地址查询域名

List of DNS record types

List_of_DNS_record_types

  • A address record
  • AAAA ipv6 address record
  • NS Name server record, Delegates a DNS zone to use the given authoritative name servers

参考

what is dns