Support >
  About cybersecurity >
  DNS Resolution: How to Understand A/CNAME/MX/TXT Records

DNS Resolution: How to Understand A/CNAME/MX/TXT Records

Time : 2026-03-03 13:54:35
Edit : DNS.COM

  In website construction and server maintenance, DNS resolution is an essential foundation. Many novice website owners often encounter A records, CNAME records, MX records, and TXT records when configuring domain names, but are unclear about their differences and application scenarios. Understanding the principles of DNS resolution and common record types can not only help you build a website correctly but also prevent problems such as inaccessible domains, email sending and receiving errors, and SSL certificate failures.

  Simply put, the role of DNS is to translate "domain names" into "IP addresses." Because communication between computers relies on IP addresses, and humans are more likely to remember domain names, such as example.com, when a user enters a domain name in a browser, the system uses DNS to look up the corresponding server IP address before establishing a connection and loading the webpage.

  The DNS lookup process is roughly as follows: User enters domain name → Local DNS cache lookup → Request from ISP's DNS server → Query root servers step by step → Top-level domain server → Authoritative DNS server → Return of the final IP address. The entire process is usually completed within tens of milliseconds.

  Having understood the role of DNS, we can now move on to the core part: DNS record types. First, let's look at A records. A records are the most basic and commonly used type of DNS record. A stands for Address, and its function is to directly resolve a domain name to an IPv4 address. You need to use an A record when you want accessing a domain name to point directly to a server's IP address.

  For example, if you have a cloud server with a public IP address of 203.0.113.10, you can configure the A record like this:

  Host record: @

  Record type: A

  Record value: 203.0.113.10

  TTL: 600

  This means the root domain example.com will resolve to 203.0.113.10. If you want to configure a www subdomain, you can do this:

  Host record: www

  Record type: A

  Record value: 203.0.113.10

  In Linux systems, you can use the `dig` command to test if the A record is working:

dig example.com A

  If you see the corresponding IP address in the ANSWER SECTION in the returned results, the DNS resolution is successful.

  The advantages of A records are their intuitiveness, stability, and fast resolution speed. However, the disadvantage is that if the server IP changes, the DNS record needs to be manually modified. For scenarios with frequent IP changes, the maintenance cost is relatively high.

  Next is the CNAME record. CNAME stands for Canonical Name, which is an "alias record." Its purpose is to point a domain name to another domain name, rather than directly to an IP address.

  For example, if your website uses an acceleration service provided by a CDN, and the provider offers a domain name cdn.provider.com, you can configure it like this:

  Host record: www

  Record type: CNAME

  Record value: cdn.provider.com

  When a user accesses www.example.com, the DNS will first resolve to cdn.provider.com, and then that domain name will resolve to the actual IP address.

  You can use the following command to verify:

dig www.example.com CNAME

  The advantage of CNAME records lies in their flexibility. When the target domain's IP address changes, you don't need to manually modify it because the DNS resolution is handled by the other party. However, it's important to note that a hostname cannot have both an A record and a CNAME record simultaneously. Furthermore, root domains typically cannot directly set CNAME records (some DNS providers address this through ALIAS or ANAME mechanisms).

  Next is the MX record. MX stands for Mail Exchange, used to specify the mail server for a domain. When someone sends you an email, the mail system queries the MX record to determine which server the email should be delivered to.

  For example, if you use a business email service, your email provider might provide the following information:

  Server address: mail.examplemail.com

  Priority: 10

  DNS configuration:

  Host record: @

  Record type: MX

  Record value: mail.examplemail.com

  Priority: 10

  If you have multiple MX records, you can set different priorities; the smaller the number, the higher the priority. For example:

  Priority 10: Primary mail server

  Priority 20: Secondary mail server

  The MX record can be queried using the `dig` command:

dig example.com MX

  Incorrect MX record configuration will prevent emails from being received. Therefore, when configuring a corporate email account, the MX record must be filled in strictly according to the information provided by the service provider.

  Finally, there are TXT records. Originally used to store text information, TXT records are now widely used for domain verification, security authentication, and other scenarios. For example, SPF, spam prevention, Google verification, and SSL certificate verification all rely on TXT records.

  The most common application of TXT records is in SPF, used to prevent email spoofing. For example:

v=spf1 ip4:203.0.113.10 include:mail.examplemail.com -all

  The DNS configuration is as follows:

  Host record: @

  Record type: TXT

  Record value: v=spf1 ip4:203.0.113.10 include:mail.examplemail.com -all

  You can also use dig to query TXT records:

dig example.com TXT

  In addition, many SSL certificates require DNS verification during the application process. For example, Let's Encrypt requires the addition of a TXT record:

  Host record: _acme-challenge

  Record type: TXT

  Record value: Random string

  After adding the record, wait for it to take effect to complete the verification.

  Functionally, the differences between the four record types are summarized as follows:

  A Record: Domain Name → IPv4 Address

  CNAME Record: Domain Name → Domain Name

  MX Record: Domain Name → Mail Server

  TXT Record: Domain Name → Text Information (Authentication, Security, Policy)

  In practical applications, website access typically relies on A or CNAME records, mail systems rely on MX records, and security verification relies on TXT records. Understanding the relationships between them can avoid many common problems.

  For example, if a website is inaccessible, first check if the A record is correct; if using CDN acceleration, prioritize CNAME records; if emails cannot be received, check the MX record; if the mailbox is marked as spam, check the SPF TXT record.

  In operational practice, it is recommended to follow these best practices:

  First, set the TTL value appropriately. TTL represents the cache time, measured in seconds. During the testing phase, a timeout period of 300 or 600 seconds can be set; for production runs, a timeout period of 3600 seconds or more can be used to reduce DNS lookup pressure.

  Second, avoid conflicting configurations. Do not allow both A and CNAME records for the same hostname to exist simultaneously.

  Third, after modifying the DNS, verify the changes using tools like `dig` or `nslookup`.

nslookup example.com

  Fourth, pay attention to DNS propagation time. Global DNS updates typically take anywhere from a few minutes to 24 hours to take effect.

  While DNS resolution is fundamental knowledge, it is the foundation for stable website operation. A records determine the website access path, CNAME records provide flexible scalability, MX records ensure email communication, and TXT records provide security and authentication support. Only by truly understanding the role and configuration logic of these records can you navigate website building, cloud server deployment, corporate email configuration, CDN acceleration, and SSL certificate application with ease.

DNS Luna
DNS Amy
DNS Becky
DNS NOC
Title
Email Address
Type
Information
Code
Submit