Addressing and routingIntermediate24 min read

What Is CNAME record in Networking?

Reviewed byJohnson Ajibi· Senior Network & Security Engineer · MSc IT Security

This page mentions older exam versions. See the Current Exam Context and Legacy Exam Context sections below for the updated mapping.

On This Page

Quick Definition

A CNAME record is like a nickname for a website. It lets one domain name (like blog.example.com) point to another domain name (like example.com). When someone visits the alias, the DNS system looks up the real domain and sends them to the right place.

Commonly Confused With

CNAME recordvsA record

An A record maps a domain name directly to an IPv4 address, while a CNAME record maps a domain name to another domain name. The A record returns an IP address; the CNAME record returns a domain name that must then be resolved. If you know the IP address and it rarely changes, use an A record. If you need to point to an external service with a changing IP, use a CNAME.

A record: www.example.com => 192.0.2.1. CNAME record: blog.example.com => www.example.com.

CNAME recordvsAAAA record

An AAAA record is the IPv6 equivalent of an A record. It maps a domain name to a 128-bit IPv6 address. A CNAME record maps to another domain name, regardless of whether that target resolves to IPv4 or IPv6. The key difference is that AAAA directly gives an IP, while CNAME gives a name.

AAAA record: ipv6.example.com => 2001:db8::1. CNAME record: old.example.com => ipv6.example.com.

CNAME recordvsALIAS record

An ALIAS record (sometimes called ANAME) behaves like a CNAME but can be used at the zone apex and can coexist with other record types. While a CNAME is a standard RFC record, ALIAS is a proprietary extension offered by many DNS providers. The exam typically only covers standard CNAME, but knowing about ALIAS can help avoid confusion.

You want example.com (apex) to point to a CDN. You cannot use CNAME, but you can use an ALIAS record provided by your DNS host. Many cloud DNS services offer this.

Must Know for Exams

The CNAME record is a core topic in the CompTIA Network+ (N10-008) exam, which is the primary certification for which this term is relevant. The exam objectives explicitly list DNS record types under Objective 1.6: 'Given a scenario, configure the appropriate IP addressing components.' Candidates must be able to differentiate between A, AAAA, CNAME, MX, TXT, and other record types. The CNAME record appears frequently in both multiple-choice and simulation-based questions.

In the Network+ exam, you can expect questions that ask you to select the correct DNS record type for a given scenario. For example, a question might describe a company that wants to point its blog subdomain to a third-party hosting provider and asks which DNS record should be used. The correct answer is CNAME, and the distractors might include A record (which requires an IP), MX record (for mail exchange), or TXT record (for text data). Another common question format presents a DNS zone configuration and asks you to identify an error, such as a CNAME record coexisting with an MX record for the same name.

The exam also tests your understanding of the limitations of CNAME records. For instance, a scenario might ask: 'A network administrator is trying to configure a CNAME record for the root domain example.com. Why does this fail?' The answer is that CNAME records are not allowed at the zone apex because the apex needs SOA, NS, and other record types. Similarly, questions may ask about the DNS resolution process for a CNAME, where a resolver first receives the CNAME response and then performs a second query for the target.

For the performance-based simulations (PBQs), you might be given a scenario and a blank DNS zone file, and asked to add the appropriate records. You could be required to add a CNAME record for www that points to the same domain, or to add a CNAME for mail that points to an external mail provider. Understanding the syntax and the fact that the target must be a fully qualified domain name (with a trailing dot in many configurations) is crucial.

for Network+, you should memorize the following: CNAME is for aliasing one domain to another, it cannot be used at the zone apex, it cannot coexist with other records at the same name, and it resolves to a domain name, not an IP address. These points are directly testable and appear regularly. Although this term is also useful for other exams like Security+ or CySA+ (where DNS concepts appear peripherally), its primary relevance is Network+.

Simple Meaning

Think of a CNAME record like a forwarding address at the post office. You move to a new house, but you want mail sent to your old address to still reach you. You fill out a form that tells the post office: 'Any mail for 123 Old Street should be forwarded to 456 New Street.' The post office then redirects all that mail to your new home without you having to tell every single sender your new address. In the world of the internet, a CNAME record works exactly the same way. It tells the Domain Name System (DNS): 'When someone asks for this alias domain, go look up the real domain and give them that answer instead.'

For example, imagine your company's main website is at www.example.com. You also want shop.example.com to lead customers to the same shopping platform that is hosted at a different provider, say myshop.example.com. Instead of creating a separate A record with the IP address for shop.example.com, you create a CNAME record that points shop.example.com to myshop.example.com. When a customer types shop.example.com into their browser, the DNS system follows the CNAME chain, finds the actual IP address of myshop.example.com, and connects the customer.

CNAME records are very common for services like content delivery networks (CDNs) and cloud platforms, where the actual IP address of a server may change frequently. By using a CNAME, you avoid having to update the DNS every time the IP changes. The alias always points to the canonical name, and the canonical name’s DNS records are maintained by the provider. This makes CNAME records flexible and efficient for many modern web architectures. However, there is one important rule: a CNAME record cannot coexist with any other record type for the same name. It must be the only record at that DNS node.

Full Technical Definition

A CNAME (Canonical Name) record is a standard resource record type defined in RFC 1035. Its purpose is to alias one domain name to another, effectively creating a domain name redirection at the DNS level. When a DNS resolver receives a query for a domain name that has a CNAME record, it does not return an IP address directly. Instead, it returns the alias target domain name. The resolver must then perform a new query for that target domain name to obtain the A or AAAA record that contains the IP address. This process is called CNAME chasing or CNAME resolution.

The CNAME record format includes the owner name (the alias), the type (CNAME), the TTL (time-to-live), the class (usually IN for Internet), and the canonical name (the target domain). The target domain must be a fully qualified domain name (FQDN) and should not be an IP address. CNAME records are used in many real-world scenarios: pointing www.example.com to example.com, directing a blog subdomain to a third-party blogging platform, or setting up custom domains for cloud services like AWS, Azure, or GitHub Pages.

One critical technical constraint is that a CNAME record must be the only record type at a DNS node. This means you cannot have a CNAME and an A record, or a CNAME and an MX record, for the same domain name. Violating this rule causes undefined behavior and is a common source of DNS configuration errors. CNAME records cannot be placed at the zone apex (the root of a domain, like example.com) because the zone apex requires other records such as SOA, NS, and often MX. To work around this, many DNS providers support ALIAS or ANAME records, which act like CNAME records but can coexist with other record types and can be used at the zone apex.

From a performance perspective, CNAME records add latency because they require multiple DNS queries. Some resolvers cache the CNAME results, and the final A/AAAA record can be cached separately. Modern DNS best practices recommend using CNAME records for subdomains that need to point to external services, because it decouples the alias from the underlying IP address. When the target IP changes, only the provider’s DNS needs to be updated, not your own. However, because of the additional query overhead, you should avoid chaining multiple CNAME records, as each link adds another lookup cycle. In exam contexts, the CompTIA Network+ (N10-008) objectives cover DNS record types including CNAME, A, AAAA, MX, and TXT. Understanding the difference between a CNAME record and an A record is a common exam topic.

Real-Life Example

Imagine you run a small bakery called Sweet Treats. Your main storefront is located at 123 Main Street. You also have a separate entrance for your cake shop around the corner at 456 Elm Street, but you want people who have always used the 123 Main Street address to still find you. So you put up a sign on the door at 123 Main Street that says: 'If you are looking for the cake shop, please go to 456 Elm Street.' That sign is like a CNAME record. It doesn't give the exact location by itself; it just points to the real address.

Now, let's map this to the internet. Your main website is hosted at your primary domain, example.com. You also decide to create a separate section for your blog, so you register blog.example.com. Instead of buying a separate web server and IP address, you set up a blog on a third-party platform like WordPress.com, and they give you a URL like sweet-treats-blog.wordpress.com. To make it easier for your customers, you want them to type blog.example.com and see your blog. So you create a CNAME record that says 'blog.example.com is actually sweet-treats-blog.wordpress.com.' When a customer types blog.example.com, the DNS system looks up the CNAME record, finds the alias target, then looks up the IP address of sweet-treats-blog.wordpress.com, and the customer’s browser loads the blog from the third-party service.

Why not just use a redirect to the third-party URL? Because a CNAME record works at the DNS level, before the browser even connects to the server. It is seamless and faster than an HTTP redirect, and it allows the third-party service to handle SSL certificates and content delivery. If the blog platform later changes its IP address, the CNAME record still works because the IP is resolved from the target domain’s DNS, which the blog platform maintains. This is exactly why CNAME records are so popular for services like CDNs and cloud hosting, they abstract away the underlying infrastructure and make scaling easier.

The only downside is that you cannot have other DNS records (like an A record or MX record) for blog.example.com if you use a CNAME there. That is why many companies use separate subdomains for different services. For example, they might use mail.example.com for email and blog.example.com for the blog, each with its own DNS records.

Why This Term Matters

In the real world of IT, the CNAME record is a fundamental tool for managing DNS without being tied to a fixed IP address. Most modern websites use some form of content delivery network (CDN), cloud hosting, or third-party service. These services often provide a domain name (like cdn.cloudfront.net) and ask you to point your subdomain to them using a CNAME record. This is crucial because CDNs need to deliver content from the nearest edge server, and their IP addresses change often. If you used a static A record, you would have to manually update the IP every time the CDN changed its edge nodes, which is not practical.

For IT professionals, understanding CNAME records is essential for configuring custom domains for software as a service (SaaS) applications, email services, load balancers, and web applications. For example, when you use Office 365 or Google Workspace for email, you often need to add CNAME records to verify domain ownership or to enable services like autodiscover. Without CNAME records, these integrations would be much more complex.

Another practical consideration is that CNAME records help with rebranding or domain migrations. If your company changes its primary domain from old-company.com to new-company.com, you can set up a CNAME at the old subdomains to point to the new ones. Users who still visit the old URL will be redirected without breaking links. However, you must be careful with the zone apex limitation. Since you cannot put a CNAME at the root domain, you cannot point example.com directly to a CDN using a CNAME. Many DNS providers solve this with an ALIAS record or by using an A record with a dynamic IP.

CNAME records are a core DNS feature that support flexibility, scalability, and ease of management. For the Network+ exam, you need to know that CNAME maps one name to another, that it cannot coexist with other record types at the same node, and that it is not allowed at the zone apex. These are the kinds of facts that appear directly in multiple-choice questions and performance-based simulations.

How It Appears in Exam Questions

CNAME record questions on the Network+ exam come in several distinct patterns. The first and most common is the 'Select the record type' question. For example: 'An organization wants to point its 'app.example.com' subdomain to a cloud provider's domain 'app.cloudprovider.com'. Which DNS record type should be used?' The answer is CNAME. The distractors will be A (because it expects an IP address), MX (for mail), and TXT (for verification). You need to recognize that the target is a domain name, not an IP.

The second pattern involves troubleshooting a DNS configuration. A question might show a partial zone file with an error, such as a CNAME record along with an MX record for the same hostname. The question asks: 'Why is the email for mail.example.com not being delivered?' The answer is that a CNAME record exists at the same node as the MX record, which is not allowed. The fix would be to either remove the CNAME or use a different hostname.

A third pattern tests your understanding of CNAME resolution process. A question might say: 'A user types www.example.com and receives an IP address. The DNS server returns a CNAME record for www.example.com pointing to example.com. What does the resolver do next?' The correct answer is that the resolver performs a new query for example.com to obtain its A record. This tests whether you know that a CNAME does not itself contain an IP address.

A fourth pattern is the performance-based simulation. You might be given a scenario where you need to configure a custom domain for a service like GitHub Pages. You will be shown a DNS management interface and asked to add a CNAME record with the correct hostname and target. You may also be asked to validate the configuration by performing an nslookup or dig command and interpreting the results. For example, the output might show 'answer: www.example.com canonical name = example.com' and then the A record for example.com. You would need to recognize that the CNAME resolution is working correctly.

A fifth pattern involves understanding the limitations. A scenario might describe a company that wants to use a CNAME for the root domain (example.com) to point to a load balancer. The question asks: 'What is the problem with this configuration?' The answer is that CNAME records cannot be placed at the zone apex. A good alternative would be to use an ALIAS record or to redirect via HTTP.

Finally, some questions might combine CNAME with security concepts, such as using a CNAME for a phishing domain. But on Network+, the focus is purely on DNS configuration and troubleshooting. Practice with these question patterns using command-line tools like nslookup set type=cname and dig to solidify your understanding.

Practise CNAME record Questions

Test your understanding with exam-style practice questions.

Practise

Example Scenario

You are a junior network administrator for a medium-sized company called TechLearn Inc. The company’s main website is hosted at www.techlearn.com, which resolves to the IP 192.0.2.10 via an A record. The marketing department wants to launch a new learning portal at learn.techlearn.com. Instead of hosting the portal on your own servers, you decide to use a third-party educational platform called LearnFast that provides a domain like techlearn.learnfast.com.

Your task is to configure DNS so that when a user types learn.techlearn.com in their browser, they are directed to the content hosted on techlearn.learnfast.com. You decide to use a CNAME record because it is simple and does not require knowing the IP address of the LearnFast servers. You add the following record in your DNS zone file:

learn.techlearn.com. CNAME techlearn.learnfast.com.

After saving the changes, you test the configuration. You open a command prompt and type nslookup learn.techlearn.com. The output shows:

Server: dns.techlearn.com Address: 203.0.113.10

learn.techlearn.com canonical name = techlearn.learnfast.com. techlearn.learnfast.com internet address = 198.51.100.20

This confirms that the CNAME record is working. The browser will now load the learning portal from the third-party platform. A few weeks later, the marketing department complains that the portal is sometimes unavailable. You investigate and discover that LearnFast has changed their IP addresses. Because you used a CNAME record, your DNS automatically resolves to the new IP without any action from you. If you had used an A record with the old IP, the portal would have been broken. This example shows the practical advantage of CNAME records: they decouple your domain from the underlying infrastructure. However, you also need to remember that you cannot add any other DNS records (like an A or MX) for learn.techlearn.com because the CNAME is the only record allowed at that node. This scenario is typical of Network+ PBQs where you have to choose the correct record type for a given situation.

Common Mistakes

Using a CNAME record at the zone apex (e.g., example.com instead of www.example.com).

The zone apex must have SOA, NS, and often MX or A records. A CNAME record cannot coexist with these records, and by definition, the zone apex already has required records. DNS resolvers will ignore or misbehave when a CNAME is present at the apex.

Use an A record with the IP address at the zone apex, or use an ALIAS/ANAME record if your provider supports it. For subdomains like www, CNAME is fine.

Creating a CNAME record that points to an IP address instead of a domain name.

A CNAME record is defined to point to a canonical domain name, not an IP address. The target field in a CNAME record must be a fully qualified domain name (FQDN). Pointing to an IP address is invalid and will cause resolution errors.

Always use a domain name as the target. If you need to point to an IP, use an A record (IPv4) or AAAA record (IPv6).

Using a CNAME record for a hostname that already has other DNS record types (e.g., an MX record).

RFC 1035 prohibits a CNAME record from coexisting with any other record type for the same owner name. If you have an MX record for mail.example.com, you cannot also have a CNAME for mail.example.com. This creates conflicting DNS data.

Assign different hostnames for different services. For example, use mail.example.com for MX records and webmail.example.com for a CNAME pointing to a webmail provider.

Confusing a CNAME record with an HTTP redirect (301/302).

A CNAME works at the DNS level, changing which server the browser connects to. An HTTP redirect works at the application layer, sending a new URL to the browser. They are not interchangeable. Using a CNAME does not change the URL in the address bar; it only changes the IP address to which the browser connects.

If you want the URL to change in the browser, use an HTTP redirect. If you just want the same URL to serve content from a different server, use a CNAME.

Exam Trap — Don't Get Fooled

{"trap":"The exam presents a scenario where a company wants to point example.com (the root domain) to a cloud load balancer using a CNAME record. The trap is that many candidates think it is acceptable because they have seen CNAME records used for other services."

,"why_learners_choose_it":"Learners often fail to remember the rule that CNAME records cannot exist at the zone apex. They may think that because CNAME is used for subdomains, it can also be used for the root domain. They might also confuse CNAME with an ALIAS record, which some providers offer for the apex."

,"how_to_avoid_it":"Memorize the rule: 'CNAME records cannot be used at the zone apex.' The zone apex (also called the root domain or 'naked domain') requires an SOA record and NS records at a minimum. A CNAME would conflict.

If you need to point the apex to a load balancer, use an A record or an ALIAS record if available. Always check if the hostname in the question is a subdomain or the root. Root = no CNAME."

Step-by-Step Breakdown

1

User requests an alias domain

A user types blog.example.com into their browser. The browser needs the IP address to connect, so it sends a DNS query to the configured DNS resolver for the A record of blog.example.com.

2

Resolver queries the authoritative DNS server

The resolver (e.g., 8.8.8.8) looks up the NS records for example.com, then queries the authoritative name server for an A record. Instead of finding an A record for blog.example.com, the server finds a CNAME record.

3

Server returns the CNAME record

The authoritative DNS server returns a response with the CNAME record, which contains the canonical name (target domain), such as blog.example.com is an alias for myblog.wordpress.com. The response includes the target but no IP address.

4

Resolver performs a second query for the canonical name

The resolver now knows it must find the IP address of myblog.wordpress.com. It performs a new DNS query for the A record of myblog.wordpress.com, starting the lookup process again for that domain.

5

Resolver receives the final IP address

The authoritative DNS server for wordpress.com returns the A record for myblog.wordpress.com with an IP address, say 192.0.2.100. The resolver caches both the CNAME and A records for their respective TTLs.

6

Browser connects to the IP address

The resolver returns the final IP address (192.0.2.100) to the user’s browser. The browser then opens a TCP connection to that IP and loads the website. The user sees the content from the WordPress platform, but the URL in the address bar remains blog.example.com.

Practical Mini-Lesson

CNAME records are one of the most commonly used DNS record types in enterprise and cloud environments. As a network professional, you will often need to configure them when setting up custom domains for third-party services. The process is straightforward but requires attention to detail.

First, identify the hostname you want to alias. It must be a subdomain, never the root domain. For example, use 'www' or 'app' or 'store' as the subdomain. The hostname you are aliasing must not have any other DNS records. If it currently has an A record, you must delete it before creating the CNAME. Most DNS management interfaces will warn you if you try to create a duplicate record.

Second, obtain the target domain from the external service. This is usually provided by the service provider, such as 'myapp.azurewebsites.net' or 'cdn.cloudfront.net'. The target must be a fully qualified domain name (FQDN). In many DNS providers, you need to include a trailing dot (for example, 'myapp.azurewebsites.net.') to indicate the root of the DNS tree, but this varies by provider. Always check the provider’s documentation.

Third, consider the TTL (time-to-live). For CNAME records, a lower TTL (like 300 seconds) is useful when you might change the target during troubleshooting. For stable configurations, a longer TTL (like 3600 seconds) reduces DNS query load.

Fourth, test your configuration. Use the nslookup command with the type set to cname: nslookup -type=cname app.example.com. You should see the canonical name in the output. Alternatively, use dig: dig app.example.com CNAME. If the CNAME is working, you will see the answer section with the target.

What can go wrong? The most common mistakes are using a CNAME at the zone apex, forgetting to remove conflicting records, or mistyping the target domain. Another issue is creating a CNAME chain (e.g., cname1 -> cname2 -> a record), which adds latency and is generally discouraged. Some providers also have limits on the depth of CNAME chasing.

In production, you should also consider that CNAME records affect mail delivery. If you set a CNAME for the same subdomain that is used for MX records, email will break. Always use separate subdomains for different services. For example, use 'mail.example.com' for email and 'webmail.example.com' for a CNAME to a webmail service.

Finally, keep in mind that CNAME records are part of the DNS resolution process and are not the same as URL redirects. If you need the URL to change in the browser, you need an HTTP redirect (301 or 302) at the web server level, not a CNAME. Understanding this distinction is critical for both real-world configuration and exam scenarios.

Memory Tip

Remember: 'CNAME Cannot At the Apex, No Other Records Allowed.' The 'C' stands for 'Canonical' and also reminds you it maps to a name, not an IP.

Covered in These Exams

Current Exam Context

Current exam versions that test this topic — use these objectives when studying.

Legacy Exam Context

Older materials may mention these exam versions, but learners should use the current objectives for their target exam.

N10-008N10-009(current version)

Related Glossary Terms

Frequently Asked Questions

Can I use a CNAME record for my root domain (example.com)?

No, you cannot. The root domain requires SOA and NS records, and a CNAME record cannot coexist with them. Use an A record for the root or an ALIAS record if your provider supports it.

What is the difference between a CNAME record and an A record?

An A record maps a domain directly to an IPv4 address. A CNAME record maps a domain to another domain name. The CNAME requires a second query to resolve the target domain to an IP address.

Can I have a CNAME record and an MX record for the same hostname?

No, that is not allowed. A CNAME record must be the only record type at that DNS node. If you need both, use different subdomains (e.g., mail.example.com for MX and webmail.example.com for CNAME).

Does a CNAME record change the URL in the browser?

No, it does not. A CNAME only affects where the browser connects, not the URL shown in the address bar. If you want the URL to change, you need an HTTP redirect.

How do I test if a CNAME record is working?

Use the nslookup command: nslookup -type=cname your-subdomain.example.com. Look for the 'canonical name' in the output. You can also use dig: dig your-subdomain.example.com CNAME.

Why does my CNAME record cause email delivery issues?

If you have a CNAME record for the same hostname as an MX record, the DNS is invalid. The email system cannot resolve the mail server correctly. Always use distinct hostnames for email and other services.

Summary

The CNAME (Canonical Name) record is a DNS resource record that creates an alias from one domain name to another. It is a standard tool used to point subdomains to external services such as content delivery networks, cloud platforms, and third-party applications. Unlike an A record, which directly returns an IP address, a CNAME returns a domain name that must be resolved further. This indirection provides flexibility because the target domain’s IP can change without requiring updates to the alias’s DNS records.

For IT professionals, understanding CNAME records is critical for DNS configuration, especially when integrating with SaaS providers, CDNs, and cloud hosting. The main limitations are that CNAME records cannot be placed at the zone apex, cannot coexist with any other record type for the same hostname, and must point to a domain name (not an IP). These rules are frequently tested on the CompTIA Network+ exam, both in multiple-choice questions and performance-based simulations.

When preparing for the exam, focus on the use cases for CNAME versus A records, the resolution process (two-step lookup), and the troubleshooting scenarios involving misconfigured CNAMEs. Remember the memory tip: 'CNAME Cannot At the Apex, No Other Records Allowed.' This will help you avoid the most common traps. In practice, use CNAME records to simplify management of external dependencies, but always plan your DNS namespace to avoid conflicts between record types. With a solid grasp of CNAME records, you will be well-prepared for both the exam and real-world network administration.