Network Services and Security · Topic 4 of 7

DNS Records

Diagnose DNS record problems (A, AAAA, CNAME, MX, NS, PTR) with nslookup and dig, and find why a host, web application or mail server cannot be reached by name.

  • 5 min
In a nutshell
  • A is IPv4, AAAA is IPv6, CNAME is an alias, MX is mail, NS is name servers, PTR is reverse.
  • DNS uses port 53, UDP for normal queries.
  • NXDOMAIN means the name does not exist.

What it is

DNS records are the entries in a DNS zone that map names to addresses and tell the world where to find a domain's servers and mail.

People use names and devices need addresses. When a record is missing or wrong, the network can be perfectly healthy and users still cannot reach a web site or send mail.

DNS uses port 53. Ordinary queries use UDP, and TCP is used for large replies and zone transfers.

How it works

A host checks its own cache, then asks its configured resolver, which finds the answer from the authoritative server.

Hostneeds a namequeryResolverDNS serverasksAuthoritative serverholds the recordsanswer and TTLHost

The six record types

RecordMapsTypical use
AName to IPv4 addressHost or web server
AAAAName to IPv6 addressHost or web server on IPv6
CNAMEAlias name to another namewww pointing at the real host name
MXDomain to a mail server name, with a preferenceDelivering mail
NSDomain to its name serversDelegation
PTRAddress back to a nameReverse lookup

Every answer carries a TTL, the number of seconds a resolver may cache it. After you fix a record, old answers can live on until the TTL runs out.

An MX record holds a preference number and a name. The lowest number is tried first. The MX target must be a name that has an A or AAAA record, not an IP address and not a CNAME.

PTR records live in a reverse zone. For IPv4 the address is written backwards under in-addr.arpa, so 203.0.113.80 becomes 80.113.0.203.in-addr.arpa. IPv6 uses ip6.arpa.

Querying from a client

On Windows, macOS and Linux, nslookup works the same way. Linux and macOS also have dig.

C:\> nslookup www.example.com
Server:   dns1.example.com
Address:  10.1.1.53

Non-authoritative answer:
Name:     www.example.com
Address:  203.0.113.80

The first two lines are the resolver that answered. "Non-authoritative" means the answer came from the resolver's cache or from another server, not from the zone's own server.

Ask for a record type with -type, or name a different server at the end:

nslookup -type=MX example.com
nslookup -type=AAAA www.example.com 10.1.1.53
nslookup 203.0.113.80

dig shows more detail:

$ dig example.com MX
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41972
;; ANSWER SECTION:
example.com.     3600  IN  MX  10 mail.example.com.
example.com.     3600  IN  MX  20 mail2.example.com.

3600 is the TTL, IN is the class, and MX is the type. dig -x 203.0.113.80 does a reverse lookup, and dig +short prints only the answers.

Reading the status

ResultMeaning
NOERROR with an answerThe record exists
NOERROR with no answerThe name exists but not that record type, for example no AAAA
NXDOMAINThe name does not exist
SERVFAIL or timeoutThe server could not answer, or cannot be reached

Diagnosing by symptom

Name failsping to IP worksquerynslookupwhich recordMissing or wrongfix the zoneWait for TTLflush the cache
SymptomLikely record problem
Web site opens by IP but not by nameA or AAAA missing, or the resolver is wrong
www.example.com fails but the host worksCNAME points to a name that does not exist
IPv6 users fail, IPv4 users workAAAA points to an address that is not reachable
Mail to the domain bouncesMX missing, or MX target has no A record
Mail server rejects your mailPTR missing or does not match the sending host
A whole domain does not resolveNS records wrong, so the delegation points to a dead server
Exam tip

If ping 203.0.113.80 works and ping www.example.com fails, the network path is fine. Stop checking routes and check DNS.

Clearing the cache

A client may keep a bad answer, so clear the cache after the zone is fixed. On macOS, run sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder.

C:\> ipconfig /displaydns
C:\> ipconfig /flushdns
$ resolvectl flush-caches

DNS on a Cisco router

ip domain lookup
ip name-server 10.1.1.53
ip domain name example.com
ip host LAB1 10.1.1.1

ip name-server points the router at a resolver, and ip host creates a local name entry.

Common mistakes

Blaming routing for a name failure. If the IP address works, look at DNS.

Pointing MX at an IP address or a CNAME. MX must name a host that has an A or AAAA record.

Forgetting AAAA. Adding a wrong AAAA record breaks IPv6 clients while IPv4 still works.

Confusing A and PTR. A goes from name to address. PTR goes from address to name.

Ignoring the TTL. A fixed record may not take effect everywhere until the old TTL expires.

Querying the wrong server. Ask the authoritative server directly to test the zone, not only the resolver.

What to remember for the exam

  • A is IPv4, AAAA is IPv6, CNAME is an alias, MX is mail, NS is name servers, PTR is reverse.
  • DNS uses port 53, UDP for normal queries.
  • NXDOMAIN means the name does not exist.
  • MX uses a preference number. Lower is tried first.
  • PTR zones are in-addr.arpa for IPv4 and ip6.arpa for IPv6.
  • nslookup works on Windows, macOS and Linux. dig is on Linux and macOS.
  • IP works but the name does not: suspect DNS, not routing.
  • The TTL controls how long a cached answer stays.

Check yourself

  • Users can reach a server by IP address but not by name. Which tool and record type do you check first?

    Use nslookup or dig to query the A record, or AAAA for IPv6, and check the resolver that answered.

  • What does NXDOMAIN mean, and how is it different from a reply with no answer?

    NXDOMAIN means the name does not exist. A NOERROR reply with no answer means the name exists but has no record of the type you asked for.

  • Which record do you check when mail to a domain bounces, and what must its target be?

    Check the MX record. Its target must be a host name that has an A or AAAA record, not an IP address or a CNAME.

Topic 4 of 7 in Network Services and Security

Test yourself on Network Services and Security

The full Cisco CCNA 200-301 v2.0 question bank has 1,242 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.