Interview Prep/Networking/DNS & Service Discovery

What is the difference between an A record and a CNAME, and when do you use each?

BeginnerScenarioDNS & Service Discovery
Answer

Situation read → An A record maps a name to an IP; a CNAME maps a name to another name.

What I'd do →

  1. Use A (or AAAA) when you control a fixed IP, for example app.example.com A 203.0.113.10
  2. Use CNAME when the target is a name owned by someone else, for example www CNAME myapp.herokuapp.com or an ALB DNS name
  3. Verify with dig app.example.com and dig +short CNAME www.example.com
  4. Never put other record types next to a CNAME on the same name

Why → A CNAME lets the provider change IPs without you touching DNS.

Interview tip → Mention that a CNAME adds a resolution hop, so it costs one extra lookup on cold cache.

All Networking questions Roadmap: Networking for DevOps

More on DNS & Service Discovery