以前写过一篇博文,利用github pages五分钟建好我的网站+我的博客 ,在这篇
博文里,作了一件什么事呢?git
github pages
和Jekyll
建立了我的网站,这个我的网站的原始域名是: logos23333.github.io
logos23333.top
域名logos23333.top
与logos23333.github.io
绑定,当用户在浏览器键入logos23333.top
时,自动解析到logos23333.github.io
我如今是大二下,开了computer networking 这门课程,因此我就想着用所学的知识具体解释一下这个第3点是怎么实现的,若是有不对的地方请不吝赐教!github
当初咱们绑定域名时作了两件事情:浏览器
域名管理
界面,找到了本身购买的域名logos23333.top
,对其进行解析,添加了三条记录。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
Value
和 Type
。dom
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
再来分析咱们添加的三条记录:网站
@
的意思是直接解析,也就是说当咱们解析logos23333.top
时,会自动去解析logos23333.github.io
的ip地址。192.30.252.153
是github服务器的名字。第3条记录也是同样的意思。我如今有如下几个点不明白:code
logos23333.top
的意义在哪?彷佛只添加那一条CNAME记录就能实现了。2018/3/12 23:51 在github pages的帮助界面,彷佛官方并非经过建立CNAME文件这种方式,而是直接在仓库的settings里改,好像是同样的效果。