尝试利用刚学的计算机网络知识对域名绑定和解析作出解释

以前写过一篇博文,利用github pages五分钟建好我的网站+我的博客 ,在这篇
博文里,作了一件什么事呢?git

  1. 利用github pagesJekyll建立了我的网站,这个我的网站的原始域名是: logos23333.github.io
  2. 在aliyun购买了logos23333.top域名
  3. logos23333.toplogos23333.github.io绑定,当用户在浏览器键入logos23333.top时,自动解析到logos23333.github.io

我如今是大二下,开了computer networking 这门课程,因此我就想着用所学的知识具体解释一下这个第3点是怎么实现的,若是有不对的地方请不吝赐教!github

当初咱们绑定域名时作了两件事情:浏览器

  1. 在aliyun的域名管理界面,找到了本身购买的域名logos23333.top,对其进行解析,添加了三条记录。
    0
  2. 在仓库(服务器)里建立名为CNAME的文件,并将其内容改成logos23333.top

第一步有什么做用呢?缓存

Computer Networking A Top-Down Approach 一书中,咱们对于一条DNS记录有如下的认识:服务器

A resource record is a four-tuple that contains the following fields: (Name, Value, Type, TTL)
TTL is the time to live of the resource record; it determines when a resource should be removed from a cache.app

TTL决定了一条记录在缓存中存在的时间,也就是说,TTL时间越长,缓存时间越长,更新越不容易及时生效,增长TTL值,能够加速网站访问速度,节约域名解析时间,相反,TTL时间越短,缓存时间越短,生效时间也就更快。
在下面的讨论中,咱们忽略TTL,只关注Name ValueTypedom

If Type=A, then Name is a hostname and Value is the IP address for the hostname. Thus, a Type A record provides the standard hostname-to-IP address mapping. As an example, (relay1.bar.foo.com, 145.37.93.126, A)
is a Type A record.
If Type=NS, then Name is a domain (such as foo.com) and Value is the hostname of an authoritative DNS server that knows how to obtain the IP addresses
for hosts in the domain. This record is used to route DNS queries further along in the query chain. As an example, (foo.com, dns.foo.com, NS) is a Type
NS record.
If Type=CNAME, then Value is a canonical hostname for the alias hostname Name. This record can provide querying hosts the canonical name for a hostname. As an example, (foo.com, relay1.bar.foo.com, CNAME) is a
CNAME record.
If Type=MX, then Value is the canonical name of a mail server that has an alias hostname Name. As an example, (foo.com, mail.bar.foo.com, MX) is an MX record. MX records allow the hostnames of mail servers to have simple aliases. Note that by using the MX record, a company can have the same
aliased name for its mail server and for one of its other servers (such as its Web server). To obtain the canonical name for the mail server, a DNS client would query for an MX record; to obtain the canonical name for the other server, the
DNS client would query for the CNAME record.ide

再来分析咱们添加的三条记录:网站

  1. CNAME @ logos23333.github.io,这条DNS记录的type是CNAME,也就是添加一个别名@的意思是直接解析,也就是说当咱们解析logos23333.top时,会自动去解析logos23333.github.io的ip地址。
  2. A www 192.30.252.153,这条DNS记录的type是A,这里的192.30.252.153是github服务器的名字。第3条记录也是同样的意思。

我如今有如下几个点不明白:code

  1. 添加那两条A类型的记录有什么意义?若是我只是想实现解析logos23333.top时去解析logos23333.github.io这样的功能,只提供一个CNAME记录不就能够了?
  2. 我在github仓库添加一个CNAME文件,里面写着logos23333.top的意义在哪?彷佛只添加那一条CNAME记录就能实现了。

2018/3/12 23:51 在github pages的帮助界面,彷佛官方并非经过建立CNAME文件这种方式,而是直接在仓库的settings里改,好像是同样的效果。

相关文章
相关标签/搜索