In the world of the Internet, a domain name is the door number we use to access a website, and domain name resolution (DNS) is the key service that translates this memorable door number into an IP address that a computer can understand. Without proper DNS configuration, users will not be able to access your website through the domain name even if the server is running properly. Understanding the principles and configuration methods of domain name resolution is a must for every webmaster, developer and IT practitioner.
This article will systematically introduce the core knowledge of domain name analysis and DNS configuration, from basic concepts to advanced configuration, to help you fully grasp this network cornerstone technology.
What is domain name resolution and DNS?
Domain name resolution, in short, is a “translation” process. Every device on the Internet has a unique numeric identifier, an IP address (e.g. `192.0.2.1`). However, strings of numbers are difficult to memorize, so domain names were created (e.g. `example.com`). The Domain Name System (DNS) is the distributed database system responsible for converting human-readable domain names into machine-readable IP addresses.
Recommended Reading The Complete Guide to Domain Name Resolution and Configuration: The Complete Process from Registration to Go-Live。
DNS uses a tree-like hierarchical structure. At the top level are the root domain name servers, under which are the top-level domains (such as `.com`, `.org`, `.cn`), and further down are the second-level domains (i.e., the part of the domain name that we register, such as `example`), which can be further divided into sub-domains (such as `www`, `mail`). When you type a URL into your browser, your computer will initiate a query to the DNS recursive resolver, which will in turn query the root servers, the top-level domain servers, and the authoritative domain name servers, and ultimately obtain the IP address corresponding to the target domain name, which will be returned to your browser, thus completing the visit.
Core DNS Record Types Explained
Configuring DNS is mainly about adding and modifying various DNS records. Understanding what each record does is a prerequisite for proper configuration.
A records vs. AAAA records
An A record (Address Record) is the most basic and commonly used record type to point a domain name to an IPv4 address. For example, point `www.example.com` to `93.184.216.34`.
An AAAA record is the IPv6 version of an A record used to point a domain name to an IPv6 address. As IPv6 becomes more popular, configuring AAAA records becomes increasingly important.
CNAME records
CNAME Record (Canonical Name Record), or Alias Record. It allows you to map a domain name to another domain name instead of an IP address. For example, you can set `blog.example.com` to be the CNAME of `example.github.io` so that when the IP address of `example.github.io` changes, you don't need to update the record of `blog.example.com` because it will automatically follow the resolution of its target domain name. Note, however, that CNAME records cannot coexist with other record types (e.g. MX, TXT) on the same hostname.
Recommended Reading The Complete Guide to Domain Name Resolution and Configuration: From Basic Concepts to Hands-On Practice。
MX Records
The MX Record (Mail Exchanger Record) is used to specify the address of the mail server responsible for receiving e-mail for the domain. Its configuration contains a priority value, the smaller the value the higher the priority. When there are multiple mail servers, the sender will try to connect to the server with the higher priority first.
TXT record
Originally designed to hold arbitrary text messages, TXT records (Text Record) are now widely used for a variety of authentication and security configurations. The most common uses include: domain name ownership verification (for search engines, CDN services, etc.), email Sender Policy Framework (SPF) records to prevent spam, Domain Key Identified Mail (DKIM) signatures, and more.
Recommended Reading Domain Name Resolution and Configuration Guide: From Basic Concepts to Hands-On Operations。
NS Records
NS Record (Name Server Record) is used to specify which DNS server provides authoritative resolution for the domain name. When you register a domain name, you need to set the NS record at the domain name registrar to the server address of your DNS service provider (e.g. Cloudflare, Aliyun DNS), and the subsequent records such as A, CNAME, and so on can be configured and managed at your DNS service provider.
Domain name resolution configuration step by step
Having mastered the theory, we next practiced DNS configuration through a typical website deployment process.
Step 1: Obtain the server IP address and add an A record
When you purchase a cloud server and deploy your web application, you will first get one or more public IP addresses (IPv4 and/or IPv6). Log in to your DNS provider's management console and find the Domain Name Resolution Settings page.
Add an A record. The host record is usually filled with `@` (for the root domain `example.com`) or `www` (for `www.example.com`) and the record value is filled with the IPv4 address of your server. Similarly, if IPv6 support is required, add a corresponding AAAA record.
Step 2: Configure CNAME records for CDN or sub-sites
If you are using a content delivery network service, the CDN service provider will usually provide you with a domain name. In this case, you need to delete the A record of `www.example.com` or static resource subdomain (such as `static.example.com`) and add a CNAME record to point to the domain name provided by the CDN service provider. In this way, all access traffic will be accelerated and secured by the CDN network first.
For blogs hosted on third-party platforms (e.g. GitHub Pages), it is also necessary to point your subdomain (e.g. `blog.example.com`) to the address provided by the platform via a CNAME record.
Step 3: Set up MX records to enable enterprise email
If you are using enterprise mailbox services such as Google Workspace, Tencent Enterprise Mail, etc., you need to configure MX records according to the guidelines provided by the service provider. Usually you need to delete any old MX records that may exist, and then add multiple MX records specified by the service provider in order of priority, from highest to lowest. After the configuration takes effect, emails sent to `@example.com` will be routed to the corresponding enterprise mail server.
Step 4: Add TXT records to complete authentication and security configuration
When configuring mailbox services, search engine webmaster tools, or certain security services, it is often necessary to add specific TXT records to verify domain ownership. For example, an SPF record is a TXT record that declares which IP addresses or servers are allowed to send mail on behalf of your domain in a format similar to `v=spf1 include:_spf.google.com ~all`. Be sure to add the exact values provided by your service provider.
Advanced Resolution Strategies and Troubleshooting
On top of the basic configuration, some advanced strategies can improve the reliability, performance and user experience of your website.
Using DNS Load Balancing
Simple DNS polling load balancing can be achieved by adding multiple A records for the same hostname and pointing to multiple different IP addresses. When a user queries for a domain name, the DNS server returns a list of different IP addresses in a rotating fashion, thus spreading the traffic across multiple servers. However, this is a more rudimentary form of load balancing and cannot sense server health.
Configure TTL values to balance speed of entry into force with flexibility
TTL (Time to Live) determines how long (in seconds) DNS records are kept in caches at all levels. A shorter TTL (e.g., 300 seconds) means that record changes take effect globally sooner, which is suitable for frequent changes or failover scenarios. A longer TTL (e.g. 86400 seconds) reduces the number of DNS queries and speeds up resolution, but changes are slow to take effect. Before major changes such as server migration are planned, you can lower the TTL in advance and raise it after the migration is complete.
Common Analysis Troubleshooting
When a domain name is not accessible, you can follow the steps below to troubleshoot DNS issues:
1. Use the `nslookup` or `dig` command: Enter `nslookup yourdomain.com` or `dig yourdomain.com` into the command line tool and check that the IP address returned matches the one you configured. You can specify a public DNS (e.g. `8.8.8.8`) to lookup to troubleshoot local DNS caching issues.
2. Check DNS record configuration: Double-check the record type, hostname, and record value in the DNS console for misspellings or extra spaces.
3. Confirm NS servers are in effect: Use the `dig NS yourdomain.com` command to confirm whether the NS servers queried globally have been updated to the DNS service provider you are currently using. If not, you need to modify the NS records at your domain name registrar and wait for global synchronization (48 hours at most).
4. Check firewalls and security groups: Ensure that the server's security groups or firewall rules allow access from external port `53' (DNS lookup) and related service ports.
summarize
Domain name resolution and DNS configuration is the bridge connecting users and online services. From understanding core record types such as A record, CNAME, MX, etc., to completing step-by-step practical configurations of websites, CDNs, mailboxes, and then applying advanced strategies such as load balancing, TTL optimization, etc., it is crucial to master DNS knowledge systematically. Good DNS management not only ensures service accessibility, but also improves performance, enhances security and enables flexible architecture deployment. Remember, planning and reducing TTL in advance of any online change is the best practice to avoid long service interruptions.
FAQ Frequently Asked Questions
How long does it take to take effect after modifying DNS records?
The effective time of a DNS record depends on two factors: the TTL value set for the record, and the DNS cache refresh cycles of ISPs around the world. Theoretically, new records are not re-queried until after the TTL has expired. Typically, changes take effect globally within a few minutes to a few hours. However, switching a domain's NS records to a new DNS provider can take up to 24-48 hours to take full effect.
What is the difference between a CNAME record and an A record and how should I choose?
The A record points the domain name directly to an IP address and is the final destination resolution. the CNAME record treats the domain name as an alias for another domain name, and the resolution follows the target domain name. To choose, if you are pointing to a fixed IP address (e.g., your own server), use the A record. If you are pointing to another domain name (e.g., a CDN provider address, a third-party platform such as GitHub Pages), or if you wish to have the flexibility to switch back-end services without changing the DNS, use a CNAME record. Note that root domains (`@`) are sometimes not recommended or cannot be set with CNAME.
Why does my domain name resolve with “DNS_PROBE_FINISHED_NXDOMAIN”?
This error usually means that a DNS query could not find a valid record for your domain name. Possible reasons for this are: DNS records have not been configured or are misconfigured (e.g. hostname is filled in incorrectly); the domain's NS servers are not set up correctly or are not in effect globally; or you've just modified the records and the old error message is still in the local and upstream DNS caches. You can try to clear the local DNS cache and verify the global query using an online DNS checker tool.
How to configure MX records for multiple email service providers for the same domain?
It is usually not recommended to configure multiple MX records of different service providers for the same domain name, which will lead to random mail delivery to different servers and cause confusion. If you need to migrate mailbox service, the right way is to set up mail forwarding and backup in the old mailbox service provider, then modify the MX records in DNS to the configuration of the new service provider, and make sure that the old and new services coexist for a period of time, and then completely deactivate the old service after all the emails have been migrated.
What are SPF records? Why is my email marked as spam?
An SPF record is a DNS TXT record that declares which mail servers are authorized to send mail on behalf of your domain. If the IP of the outgoing mail server is not in the allowed list declared by the SPF record, the recipient's mail server may consider it as spam with a forged address and reject or mark it as spam. Ensuring that SPF records containing all legitimate outgoing mail sources (e.g. your web server, enterprise email service provider, email marketing platform, etc.) are properly configured for your domain is a critical step in improving email delivery rates.
What's next, what's next?
Extended reading and practical knowledge
The following are related to the topic of this article and are suitable for further in-depth reading. Prioritize starting with the article that is closest to your current problem, and gradually expanding to surrounding topics usually works better.
- Starting from scratch: A step-by-step guide on how to efficiently apply for and configure a personal website domain name
- The Five-Step Rule for Mastering Domain Name Security: A Comprehensive Guide to Protection from Registration to Management
- Domain Names: From Registration to Resolution – A Comprehensive Guide and Best Practices
- What is a domain name? A comprehensive guide for beginners to experts, from registration to resolution.
- A detailed explanation of the entire domain name resolution process: from entering a website address to the behind-the-scenes journey of loading the web page