Domain IP Lookup

The records you will meet in nearly every zone

AHostname to an IPv4 address
AAAAHostname to an IPv6 address
CNAMEHostname to another hostname
MXDomain to its mail servers, by priority
TXTDomain to arbitrary text -- SPF, DKIM, verification
NSDomain to the nameservers that answer for it
DNS Fundamentals

Difference Between CNAME and A Record: When to Use Each

3 min read

Both records point a hostname somewhere. The difference between a CNAME and an A record is what they point at, and it determines who is responsible for keeping the configuration correct when an IP address changes.

A recordCNAME record
Points toAn IP addressAnother hostname
Example93.184.216.34myapp.herokudns.com
Extra lookup?No — final answerYes — resolve the target too
Allowed at root?YesNo (see below)
Other records alongside?YesNo — must be alone
Updates when IP changes?You must edit itAutomatic

The decision, in one question

Key takeaway

Do you control the IP address and know it will not change? Use an A record. Are you pointing at a service someone else operates? Use a CNAME, so their address changes do not break you.

That is genuinely the whole decision for most people. The rest of this article is the details that bite.

How a CNAME resolves

CNAME stands for Canonical Name. It says: this name is an alias — go look up that other name instead.

A CNAME and the record it eventually reaches
shop.example.com.    3600    IN    CNAME    stores.myshopify.com.
stores.myshopify.com. 300    IN    A        23.227.38.65

A resolver asking for shop.example.com gets the CNAME, then resolves stores.myshopify.com, then returns 23.227.38.65. Two lookups instead of one — a few milliseconds, almost always cached.

The benefit is that when Shopify moves to a new address, they change one A record on their side and your domain follows automatically. With an A record, you would be down until you noticed and edited it yourself.

The root-domain restriction

This is the single most common DNS frustration, and it is a protocol rule, not a limitation of your provider.

This is why hosts that only give you a hostname (myapp.herokuapp.com) create a problem at the root. There are three ways out:

  1. ALIAS / ANAME / CNAME flattening

    Many DNS providers offer a synthetic record type that behaves like a CNAME at the root. The provider resolves the target itself and serves the resulting IP as a normal A record, so the protocol rule is never broken. Cloudflare calls this CNAME flattening; Route 53 calls it an alias record.

  2. Redirect the root to www

    Point the root at a small redirect service and put the CNAME on www. Simple and universally supported, at the cost of one extra hop for visitors.

  3. Use an A record and accept the maintenance

    If your provider publishes stable IPs and documents them as static, an A record at the root is fine. Confirm they guarantee stability — many explicitly do not.

A CNAME must be alone

If a name has a CNAME, it may have nothing else — no A, no MX, no TXT.

Invalid — do not do this
mail.example.com.    IN    CNAME    ghs.googlehosted.com.
mail.example.com.    IN    TXT      "v=spf1 include:_spf.google.com ~all"

Some providers reject this outright; worse, some accept it and behave unpredictably. If you need a TXT record on a name, that name cannot be a CNAME.

When each is the right call

Use an A record for

  • Your root domain, in nearly every case.
  • A server you run on a static IP — a VPS, a dedicated box, a reserved cloud address.
  • Anywhere you need other records on the same name.
  • MX targets, which must resolve to addresses.

Use a CNAME for

  • Subdomains pointing at a managed platform (Shopify, Heroku, Netlify, Vercel).
  • www, pointed at your root or your host's hostname.
  • Domain-verification subdomains that providers ask you to create.
  • Anything whose underlying IP is not yours to control.

Checking what you have

See whether a name is a CNAME and where it leads
dig +short www.example.com CNAME
dig +short www.example.com A

The lookup tool shows A, AAAA, and CNAME records together for any domain, which makes it easy to spot a name that has both when it should not.

Need to check a domain's public DNS addresses? Use the Domain IP Lookup tool.

Free tools for this topic

cname vs a recordwhat is a cname recordcname recordalias record

Frequently asked questions