Sub topic 8
DNS and Name Resolution
This chapter assumes you know how IPv4 addresses, subnet masks and default gateways work, and that you can use the Windows command prompt. It also assumes you know what DHCP does. DNS is the service that turns names people can remember into addresses that computers use. On A+ Core 1 you need to know what DNS does, which record types exist, how a lookup proceeds, and how to diagnose a failure with nslookup, ping and ipconfig.
Why DNS Exists
Computers route traffic by IP address. People prefer names such as example.com. The Domain Name System (DNS) is a distributed, hierarchical database that maps names to IP addresses and holds other data about those names.
Without DNS, every device would need a local list of every name it wanted to reach. Early networks did this with a single HOSTS file. That file still exists today and is still checked first by Windows.
DNS listens on port 53. It uses UDP for most queries because they are small and fast. It uses TCP for zone transfers between servers and for responses too large for one UDP packet.
The DNS Hierarchy
A fully qualified domain name (FQDN) is the complete name of a host, read right to left from the most general part to the most specific. Take www.example.com. as an example.
- The final dot stands for the root of the DNS tree. It is usually left off when typing.
comis the top-level domain (TLD). Other TLDs includeorg,net,eduand country codes such asuk.exampleis the second-level domain, the part an organization registers.wwwis a host name, or subdomain, that the organization creates itself.
Different servers are responsible for different levels. Root servers know where the TLD servers are. TLD servers know which servers are authoritative for each registered domain. An authoritative server holds the actual records for a zone, which is the portion of the namespace it manages.
How a Lookup Works
Your computer does not usually contact all these servers itself. It asks a recursive resolver, normally the DNS server handed out by DHCP. In a small office this is often the router, which forwards requests to the ISP's resolver or to a public one.
Windows tries several sources in order before sending anything over the network:
- The local DNS resolver cache, which holds answers from recent lookups.
- The
HOSTSfile atC:\Windows\System32\drivers\etc\hosts. - The configured DNS server.
The resolver stores the answer for a length of time called the TTL (time to live), set by the domain's owner. Until the TTL expires, repeat requests are answered from cache. Caching makes DNS fast. It also explains why a changed record can appear to work on one computer and fail on another for a while.
Common Record Types
A DNS server stores data as resource records. The A+ exam expects you to recognize these.
| Record | Name | Purpose | Example value |
|---|---|---|---|
| A | Address | Maps a name to an IPv4 address | 93.184.216.34 |
| AAAA | Quad-A | Maps a name to an IPv6 address | 2606:2800:220:1::1 |
| CNAME | Canonical name | Makes one name an alias of another name | www points to example.com |
| MX | Mail exchanger | Names the mail server for a domain, with a priority | mail.example.com |
| TXT | Text | Holds free text, often used for email security settings | v=spf1 ... |
| PTR | Pointer | Maps an IP address back to a name (reverse lookup) | host.example.com |
| NS | Name server | Lists the authoritative servers for a zone | ns1.example.com |
Three of the TXT uses are worth knowing by name, because the exam mentions them:
- SPF lists which servers may send mail for a domain.
- DKIM publishes a key used to verify signed messages.
- DMARC tells receivers what to do with mail that fails those checks.
A lower MX priority number is tried first. A CNAME cannot point to an IP address, only to another name.
Where Clients Get Their DNS Servers
A client learns its DNS servers in one of two ways:
- Automatically from DHCP, together with its IP address, mask and gateway. This is the normal case.
- Manually, by entering a primary and alternate (secondary) DNS server in the adapter's IPv4 properties.
Typing public DNS server addresses manually is a common fix when the ISP's resolver is slow or down. On the exam, remember that an internal DNS server is needed on a domain network so clients can find domain controllers by name.
Checking DNS in Practice
The ipconfig /all output lists the DNS servers each adapter uses. The nslookup tool then queries DNS directly, which separates a name resolution problem from a general network problem.
nslookup example.com
nslookup example.com 8.8.8.8
nslookup -type=MX example.comThe first command uses the DNS server configured on the adapter. The second sends the same question to a specific server, here 8.8.8.8. This tells you whether the configured server is the problem. The third asks for MX records instead of the default address record.
When the configured server answers with a "Non-authoritative answer", it is replying from its cache instead of from the zone itself. That is normal.
ipconfig /displaydns
ipconfig /flushdns/displaydns shows the local resolver cache. /flushdns clears it so the next lookup goes to the server. Run it after a DNS record has changed and your computer still returns the old address.
Isolating a DNS Fault
The most useful habit is to ping by address and then by name. The two tests use different parts of the system.
ping 8.8.8.8
ping example.comRead the results this way:
| `ping 8.8.8.8` | `ping example.com` | Likely cause |
|---|---|---|
| Succeeds | Succeeds | Network and DNS both work |
| Succeeds | Fails with "could not find host" | DNS problem: wrong server, server down, or blocked port 53 |
| Fails | Fails | Connectivity problem: cable, Wi-Fi, gateway or ISP |
If the name fails but the address works, check the DNS servers in ipconfig /all. Then try nslookup against a public server. If that works, the configured DNS server is at fault. Replace it, or fix the DHCP scope or router setting that hands it out.
Common Errors and Edge Cases
- A wrong or unreachable DNS server. Pages fail to load, yet chat apps or services that connect by IP address still work. This can look like a dead internet connection when it is only DNS.
- A stale cache. A site moved to a new address, but your computer still uses the old one. Flush the cache.
- A tampered HOSTS file. Malware may add entries that send a legitimate name to a malicious address. If one site misbehaves on one computer only, inspect the file.
- Browser redirects to unexpected sites. Unexpected DNS servers on the adapter or router can redirect traffic. Check the configured addresses against what you expect.
- APIPA address. A
169.254.x.xaddress means DHCP failed, so no DNS server was provided either. Fix DHCP first. - Split results by network. A name may resolve on an internal network and fail outside it, because an internal DNS zone holds private records.
- Port 53 blocked. A firewall that blocks UDP or TCP 53 breaks name resolution while leaving pings by address working.
Summary Table for Review
| Item | What to remember |
|---|---|
| Port | 53, UDP for queries, TCP for zone transfers and large replies |
| Lookup order on Windows | Cache, HOSTS file, DNS server |
| Name to IPv4 | A record |
| Name to IPv6 | AAAA record |
| Alias | CNAME |
| Mail routing | MX |
| Reverse lookup | PTR |
| Clear cache | `ipconfig /flushdns` |
| Query a server | `nslookup` |
Exercise
A user can open https://8.8.8.8-style address links and ping 8.8.8.8 succeeds, but ping example.com returns "Ping request could not find host example.com". ipconfig /all shows a valid IP address, mask and gateway. What is the most likely problem, and what two steps would you take next?
Show answer
The most likely problem is DNS name resolution, because connectivity by IP address works. First, check the DNS servers listed in ipconfig /all. Second, run nslookup example.com 8.8.8.8 to test a different server. If that works, the configured server is at fault, so change it on the adapter or fix the setting that DHCP hands out. Running ipconfig /flushdns is a reasonable extra step if a stale cache is suspected.
Exercise
Which DNS record type would you create to (a) point www.example.com at an IPv6 address, (b) make shop.example.com an alias of store.example.net, and (c) tell other mail servers where to deliver email for example.com?
Show answer
(a) An AAAA record. (b) A CNAME record. (c) An MX record.
Exercise
You changed a website's address on the DNS server, but your workstation still reaches the old address. Name two things that could cause this and the command that addresses one of them.
Show answer
The local resolver cache may still hold the old answer until its TTL expires, and a HOSTS file entry may be overriding DNS. Run ipconfig /flushdns to clear the cache. For the second cause, open C:\Windows\System32\drivers\etc\hosts and remove the entry.