DNS
It maps Domain name to IP address.
-
Root DNS Server
It returns IP address of "com", "org", "io", etc.
-
Top-level DNS Server
In
com
Top-level DNS Server, we can findapple.com
. -
Authoritative DNS Serve
In
apple.com
Authoritative DNS Serve, we can findwww.apple.com
.
server {
listen 80; #监听80端口
server_name time.geekbang.org; #主机名是time.geekbang.org
...
}
Caching
Once we visited a website, its IP address is cached.
-
Browser
-
Operation System
OS can not only cache the IP address of websites, but also that of local files. In
hosts
file, we can custom the domain name of local files. -
DNS
There are third-party DNS, too. It helps reduce the pressure of main DNS server. There are "8.8.8.8" (Google), "4.2.2.1" (Microsoft), etc.
resolver 8.8.8.8 valid=30s; #指定Google的DNS,缓存30秒
Load balancing based on domain name
If the server of "buy.tv" need maintain, we can switch to another server by telling DNS, mapping "buy.tv" to new server's IP address "4.5.6.7" instead of current IP address "1.2.3.4".
One domain name is mapped with multiple server machines.
What's more, we can create domain name of inner services. For example, we can create "mysql.inner.app" is for MySQL database service.