Sub topic 8
DNS and Name Resolution
This chapter assumes you know what an IPv4 address, subnet mask and default gateway are, and that you can use the Windows command prompt. DNS is the Domain Name System. It translates names such as example.com into IP addresses, so people do not have to remember numbers.
How a Lookup Works
A client sends a query to the DNS server listed in its IP configuration. DHCP usually supplies that server address. The client checks its local resolver cache first. If the name is not cached, the server answers from its own cache or asks other DNS servers until it finds the answer.
DNS uses port 53. Ordinary queries use UDP. TCP is used for large responses and for zone transfers between servers.
Common Record Types
| Record | Purpose | Example |
|---|---|---|
| A | Name to IPv4 address | `example.com` to `93.184.216.34` |
| AAAA | Name to IPv6 address | `example.com` to an IPv6 address |
| CNAME | Alias that points to another name | `www` to `example.com` |
| MX | Mail server for a domain | Where email for `example.com` goes |
| TXT | Free text, often used for email security such as SPF | Domain ownership or sender policy |
| PTR | IP address to name (reverse lookup) | Used in reverse lookups |
Testing Name Resolution
Use nslookup to query DNS directly. Use ipconfig /flushdns to clear the local cache.
nslookup example.com
ipconfig /flushdnsIf nslookup returns an address, DNS is working. ping can then confirm that the host is reachable.
Common Errors
- Ping by IP works, ping by name fails. The network path is fine and DNS is the problem. Check the DNS server addresses with
ipconfig /all. - A site loads the wrong address after a change. The cache holds an old record. Run
ipconfig /flushdns. - Wrong DNS server. An incorrect static entry, or a DHCP scope that hands out the wrong address, breaks name lookups for every client.
- Internal names do not resolve. The client may be using a public DNS server that knows nothing about the local network.
Where DNS Fits
DNS depends on a valid IP configuration. A client with an APIPA address (169.254.x.x) has usually not reached a DHCP server, so it has no DNS server either. Fix addressing first, then test names.
Exercise
A user can ping 8.8.8.8 successfully but cannot open any website by name. Which service is the most likely cause, and which command would you use to test it?
Show answer
DNS is the most likely cause, because the network path works but names are not being resolved. Run nslookup example.com to test resolution, and check the configured DNS servers with ipconfig /all.
Exercise
Which record type maps a name to an IPv4 address, and which maps a name to an IPv6 address?
Show answer
An A record maps a name to an IPv4 address. An AAAA record maps a name to an IPv6 address.