If we want to access the content on another machine when we surf the Internet, we usually only need to directly enter a string of addresses, such as: www.upyun.com, and then we can accurately access the website we want to visit. But in fact this is just a character form of network identification that is convenient for us to remember. What really allows our machine to communicate with another machine is the IP address. It's just that IP addresses are very troublesome to input and remember, so the Domain Name System was born. So how does the domain name connect to the IP of that server? This is related to the domain name system DNS that we are going to talk about today.
What is DNS?
Because a meaningful name can represent the host's account, work nature, region and organization, etc., it is easy to remember and use. Therefore, users are more inclined to identify hosts by name, and DNS was developed for this need. DNS stands for Domain Name System. The system translates the domain name (example.com) into an actual IP address.
The logical structure of DNS is a hierarchical domain name tree. The root of the domain name tree is managed by the Internet Network Information Center (InterNIC), which is called "root domain". The root domain is represented by a period ".", but this is usually omitted. It should be noted that there are only 13 IPv4 root name servers in the world.
Below the root domain are top-level domains (TLDs), which are divided into country top-level domains (ccTLDs) and generic top-level domains (gTLDs). Country top-level domains use abbreviated country codes, such as "cn" for China. The generic top-level domain is our common com/net/org and so on.
Below the top-level domain is the second-level domain, which is the only name officially registered to organizations and individuals. For example, upyun in www.upyun.com is the domain name registered by Paiyun. Under the second-level domain, organizations can also divide sub-domains for use by various branches. However, the standard stipulates that the length of a domain name is usually no more than 63 characters, and can not exceed 255 characters at most.
Of course, DNS can not only point to IP addresses, but also supports other forms of records. Common forms of DNS records are:
- A record: A record of the domain's IPv4 address.
- AAAA record: A record of the domain's IPv6 address.
- CNAME record: An alias that forwards one domain or subdomain to another without providing an IP address.
- MX records: Direct mail to an email server.
- TXT records: Enables administrators to store text comments in records.
- NS records: Name servers that store DNS entries.
A distinctive domain name can allow users to "deeply imprint" the company's brand in their minds. While a domain name may be immutable, the addresses the records point to and the DNS servers used can change frequently based on demand. Sometimes we also encounter a situation where the address actually accessed is not updated after the DNS record is modified, which involves DNS propagation.
What is DNS propagation?
Generally, after we change the domain name resolution record or DNS service provider of the website, it takes a period of time for all servers in the world to adopt the new record value. This period may be a few hours or a few days. This transition period is DNS propagation.
DNS propagation varies depending on the load on the DNS server. The older the server, the longer it takes to update. Therefore, during the transition period, other providers may have used the new address, but some service providers of the old server may not have been updated. This is because the continuous query for new addresses will cause a high load, so the DNS server will not temporarily store the updated information in the cache, and only when all servers have updated this cache will the new address be synchronized everywhere.
In addition to server load, there are factors that affect DNS propagation.
Factors Affecting DNS Propagation
DNS zone and TTL value
DNS is divided into many different zones, which are part of the DNS namespace and are managed by specific organizations or administrators. A zone file is a plain text file stored on a DNS server that contains the actual representation of the zone, and all records for each domain within the zone.
We can set TTL for each DNS in the domain name zone file. TTL stands for "Time To Live" and is the period of time that the server caches DNS information. It can define settings for temporary caching, how long to store it, and when to update it. The TTL value is critical for DNS propagation, if the TTL value is 24 hours, it will take 1 day for the change to take effect. Of course, in order for the update to take effect faster, we can adjust the TTL value. However, this adjustment must be done before the update, because adjusting the TTL is also DNS propagation and takes a while to take effect. Also be careful not to set the DNS TTL to 0 as the number 0 is not defined in the standard and it may cause DNS information to be ignored or rejected.
If you use cloud DNS to modify the resolution record of a domain name, the final effective time depends on the cache refresh time of the DNS server of the local operator, which is generally equivalent to the TTL time when setting the resolution. For example, the TTL value in the parsing setting is 10 minutes. After the parsing is modified, it will take effect globally within 10 minutes.
If the DNS server is modified, the effective time depends on the TTL time of the domain name DNS server name in the local DNS cache. For example, the ".com" top-level domain is 48 hours, and the ".cn" is 24 hours. Because the TTL time of different top-level domain DNS servers is different, theoretically, it takes up to 48 hours to modify the global resolution of the domain name DNS server to take effect.
ISP (Internet Service Provider)
Another factor that affects the duration of DNS propagation is the Internet Service Provider (ISP) used. ISPs cache DNS data locally, and each request retrieves the data from the cache rather than the DNS server. The benefit of this approach is faster response, while also reducing the generation of data traffic. However, this may have an impact on DNS propagation. Also, some ISPs simply ignore the TTL setting and only update cache records every two to three days.
The location of the server also affects DNS propagation. Changes to records can take effect at the nearest DNS server for a short period of time, but usually take longer to reach a server on the other side of the world. Because different servers need to notify each other of record changes one by one. And as mentioned in the second point, since some servers may only be updated at specific time intervals, it will take a long time for all updates to be completed.
DNS propagation time
How long does the actual DNS propagation take? Local servers are usually updated within minutes or hours. However, it can take a considerable amount of time for these changes to be made known to all servers around the world and to take effect, usually within 1-2 days is possible. And depending on the service provider's settings, it may take 72 hours for all updates to occur. Therefore, it is important to schedule DNS propagation in advance when records need to be changed or switched.
In some cases, DNS propagation can have an impact on website access, which cannot be completely avoided, but there are ways to minimize the duration. For example, before changing the DNS server, we can modify the TTL value in the resolution record and set it to a smaller value. After the TTL value is updated, modify the DNS server. However, even if it is not finished, it does not affect the modification of the domain name resolution records. Even if the DNS server is still old, the resolution records will be updated in real time and the website content will be up to date.
Of course, if after the resolution record is modified, it is found that the old record is still accessed after the TTL time, you can try to clear the local DNS cache. Or change it locally to public DNS (220.127.116.11/18.104.22.168) and try again.
DNS propagation check
If there is no tool to determine if DNS propagation of a website is complete. This can be confirmed by checking the local DNS for DNS propagation in several ways. For example, Windows, macOS, and Linux have nslookup installed by default, which displays the current DNS server resolution status. Dig tools are also a good option.
In addition to local queries, other external DNS checks need to be tested by choosing a random server and querying the DNS information there. Since the servers are spread all over the world, it's not 100% sure that DNS propagation has been done everywhere, but at least a rough estimate. For example, using Myssl's DNS detection tool ( https://myssl.com/dns_check.html#dns_check ), you can quickly find out the speed of domain name resolution and domain name DNS information under different networks in different regions.
After reading this, do you have an answer to the problem that the DNS modification does not take effect? DNS propagation is still a priority when making DNS server or Domain Name System related changes. Although the propagation time can be shortened with TTL, it still takes some time for every server in the world to be up-to-date due to some instability.
一文读懂 Kubernetes 存储设计
jenemy赞 46阅读 5.8k评论 12
从零搭建 Node.js 企业级 Web 服务器（十五）：总结与展望
乌柏木赞 65阅读 6k评论 16
再也不学AJAX了！（二）使用AJAX ① XMLHttpRequest
libinfs赞 39阅读 6.3k评论 12
从零搭建 Node.js 企业级 Web 服务器（一）：接口与分层
乌柏木赞 42阅读 7.2k评论 6
XboxYan赞 42阅读 2.9k评论 14
从零搭建 Node.js 企业级 Web 服务器（二）：校验
乌柏木赞 33阅读 6.1k评论 9