Sub topic 9
DNS: turning names into addresses
This chapter assumes you know what an IPv4 address is, what a default gateway does, and how DHCP hands out settings. It covers how the Domain Name System (DNS) resolves names, which records the A+ Core 1 exam expects, and how to separate DNS faults from other connectivity faults.
What DNS does
Computers route traffic by IP address, but people remember names. DNS is a distributed, hierarchical database that maps names such as example.com to addresses such as 93.184.216.34. It also maps in reverse and stores other data, such as mail routing.
A device does not run the whole lookup itself. It asks a DNS resolver, which is a server that does the work and returns the answer. On a SOHO network, the resolver the client uses is usually the router. The router either forwards requests to the ISP's DNS servers or to a public resolver you configured.
DNS normally uses port 53. Ordinary lookups use UDP. TCP is used for large responses and zone transfers between servers.
How a lookup works
The name is read right to left. In www.example.com, the root is implied, com is the top-level domain (TLD), example is the second-level domain, and www is a host name.
Most lookups skip steps because of caching. Each answer carries a TTL (time to live), the number of seconds it may be stored. The resolver and the client both cache results. This speeds up browsing. It also means a changed record can appear to "not work" until the old cached copy expires.
Common record types
| Record | Maps | Example use |
|---|---|---|
| A | Name to IPv4 address | `www.example.com` to `93.184.216.34` |
| AAAA | Name to IPv6 address | The same site over IPv6 |
| CNAME | Alias name to another name | `shop.example.com` to `store.provider.net` |
| MX | Domain to its mail server | Where email for `example.com` is delivered |
| TXT | Free text | Email anti-spoofing policies such as SPF, DKIM, and DMARC, and domain ownership checks |
| PTR | IP address to name | Reverse lookup |
| NS | Domain to its authoritative name servers | Delegation |
The exam expects you to recognize A, AAAA, MX, and TXT, and to know that a CNAME is an alias. Spam-related TXT records (SPF, DKIM, DMARC) are a frequent exam topic.
Where the client gets its DNS servers
A client learns its DNS servers in one of two ways:
- Automatically. DHCP supplies the DNS server addresses along with the IP address, mask, and gateway. This is the default on SOHO networks.
- Manually. An administrator types a primary and secondary DNS server into the adapter settings. Public resolvers such as
1.1.1.1and8.8.8.8are common choices.
A client with a static IP configuration needs its DNS entry typed too. Forgetting it is a classic fault. The device can ping IP addresses but cannot load any site by name.
Testing DNS with nslookup
nslookup queries a DNS server directly and shows which server answered.
nslookup example.comThe output starts with the server that was asked, then lists the address records for the name. Two results are worth recognizing:
- A normal answer means DNS works for that name.
- "DNS request timed out" or "Server failed" means the configured server is unreachable or not answering.
You can ask a different server by naming it second, for example nslookup example.com 8.8.8.8. If the public server answers and your configured server does not, the fault is the configured server, not the internet connection.
Related commands:
ipconfig /all
ipconfig /displaydns
ipconfig /flushdnsipconfig /all lists the DNS servers each adapter is using. /displaydns shows the local cache. /flushdns clears it, which fixes stale entries after a record changes.
Isolating DNS from other faults
The key skill is telling a name problem from a connectivity problem. Test by address first, then by name:
ping 127.0.0.1checks the local TCP/IP stack.pingthe default gateway checks the local network.pinga known public address, such as8.8.8.8, checks internet routing.ping example.comchecks name resolution on top of that.
If step 3 succeeds and step 4 fails, DNS is the problem. If step 3 fails, look at the gateway, the modem, or the ISP instead.
| Symptom | Likely cause | Fix |
|---|---|---|
| Ping by IP works, by name fails | No DNS server, or an unreachable one | Check `ipconfig /all`, fix DHCP or static DNS entries, or try a public resolver |
| One site fails, others load | Stale cache or a bad record | `ipconfig /flushdns`, then retry |
| Site name opens the wrong page | Old cache, or a hosts file entry | Flush the cache and check the hosts file |
| Nothing works by IP or name | Not a DNS fault | Check the cable, Wi-Fi, gateway, and DHCP |
The hosts file is a local text file that maps names to addresses and is checked before DNS. Malware sometimes edits it to redirect real sites to fake ones.
Edge cases
- APIPA addresses. A client with a
169.254.x.xaddress has no DHCP server and therefore no DNS servers. Name lookups fail along with everything else. Fix DHCP first. - Split results. A client may use the router as its only DNS server. If the router's own upstream setting is wrong, every device fails by name while the router still answers pings.
- Redirected searches. Unexpected pages or ads can mean the router's DNS settings were changed by an attacker. Check the router's DNS fields and reset them.
- Local names. Home devices often resolve names through the router rather than through public DNS. Public resolvers cannot look up those private names.
Exercise
A laptop on a SOHO network loads no websites. ping 8.8.8.8 succeeds, but ping example.com fails with "could not find host." Which service is the likely cause, and what are two things you would do next?
Show answer
DNS name resolution is failing, because the network path to the internet works. Run ipconfig /all to check which DNS servers the laptop is using, and run nslookup example.com to see whether that server answers. Then correct the DNS settings (renew the DHCP lease or enter a working server such as 8.8.8.8) and run ipconfig /flushdns.
Exercise
Which DNS record type would you check to find where email for a domain is delivered, and which would you use to point shop.example.com at another name?
Show answer
Use the MX record for mail delivery. Use a CNAME record to make shop.example.com an alias for another host name.