www.example.com)nslookup and digDNS stands for Domain Name System. It is the phonebook of the internet.
It turns a domain name (like example.com) into an IP address (like 203.0.113.10).
People remember names. Computers need numbers. DNS connects the two.
Simple meaning:
You type : www.example.com
DNS finds : 203.0.113.10
Your browser connects to 203.0.113.10
The IP addresses in this tutorial are example addresses. Real websites have different ones.
๐ New to IP addresses? Read What Is an IP Address? IPv4 vs IPv6 Explained first.
๐ DNS works at the Application layer and uses port 53: UDP for most questions, TCP for bigger jobs. See What Are Network Ports? for ports.
Imagine you want to call a friend, but you only remember the name.
You open your contacts app, search the name, and it gives you the number.
Friend's name = Domain name
Phone number = IP address
Your contacts app = DNS
That is DNS. You use the name. DNS finds the number.
A domain name is read from right to left.
www . example . com .
| | | |
| | | +-- root (the dot at the very end, usually hidden)
| | +-------- TLD (top-level domain)
| +-------------------- domain
+---------------------------- subdomain
.com, .org or .in (India)examplewwwA record is one entry in a domain's DNS data. Each record tells the world one fact about the domain.
| Record | What it stores | Example |
|---|---|---|
| A | The IPv4 address of a name | example.com โ 203.0.113.10 |
| AAAA | The IPv6 address of a name | example.com โ 2001:db8::10 |
| CNAME | An alias that points to another name, not to an IP | www.example.com โ example.com |
| MX | The mail server of the domain. A lower number is tried first | 10 mail.example.com |
| NS | The nameserver that holds the domain's records | ns1.example.com |
| TXT | Text notes, often used for email security | v=spf1 -all |
You set these records at your domain provider (Cloudflare, GoDaddy, Namecheap and others).
nslookup is built into Windows and works on Linux too.
Windows and Linux:
nslookup example.com
If nslookup is missing on Linux, install it:
sudo apt install dnsutils
Sample output on Linux (yours will differ):
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: example.com
Address: 203.0.113.10
Name: example.com
Address: 2001:db8::10
Sample output on Windows (yours will differ):
Server: dns.google
Address: 8.8.8.8
Non-authoritative answer:
Name: example.com
Addresses: 2001:db8::10
203.0.113.10
dig shows more details.
dig example.com
Sample output on Linux (shortened, yours will differ):
; <<>> DiG 9.18.39 <<>> example.com
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18441
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 3600 IN A 203.0.113.10
;; Query time: 23 msec
;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP)
How to read it:
status: NOERROR means the lookup worked. NXDOMAIN means the name does not exist.3600), the class IN (Internet), the record type A, and the address.The TTL says how long the answer may be saved. The next tutorial explains it.
Linux:
dig +short example.com AAAA
dig +short example.com MX
dig +short example.com NS
dig +short example.com TXT
+short prints only the answer. Sample output (yours will differ):
2001:db8::10
10 mail.example.com.
ns1.example.com.
"v=spf1 -all"
Windows:
nslookup -type=MX example.com
Sample output on Windows (yours will differ):
Non-authoritative answer:
example.com MX preference = 10, mail exchanger = mail.example.com
Replace MX with NS, TXT or AAAA to see other records.
example.com is a special name reserved for examples, so its real records may look different. Try a domain you know.
| Error / Symptom | Cause | Fix |
|---|---|---|
NXDOMAIN or Non-existent domain |
The name does not exist | Check the spelling. The domain may not be registered |
no servers could be reached or timed out |
Your computer cannot reach the DNS server | Check your internet connection and firewall, then try another resolver |
| A site opens by IP address but not by name | DNS is the problem | Switch your DNS to a public resolver such as 8.8.8.8 or 1.1.1.1 |
dig: command not found (Linux) |
dig is not installed | Run sudo apt install dnsutils |
| You see a different IP than your friend | Large websites give different addresses in different places | Normal. Nothing is wrong |
When a website will not load, check if DNS is the problem.
Ping an IP address, then ping a name:
ping 8.8.8.8
ping google.com
If the IP works and the name fails, DNS is broken.
- DNS turns domain names into IP addresses (the phonebook of the internet)
- Domain names are read right to left: root, TLD, domain, subdomain
- Records: A (IPv4), AAAA (IPv6), CNAME (alias), MX (mail), NS (nameserver), TXT (text)
- DNS uses port 53: UDP for most questions, TCP for bigger jobs
- nslookup works on Windows and Linux
- dig (Linux) shows more detail: dig example.com
- NXDOMAIN = the name does not exist
- If ping by IP works but ping by name fails, DNS is the problem
How DNS Works : what happens behind the scenes when you press Enter. Resolvers, root servers, caching and TTL.
TechWithJuned ยท Learn โ Execute โ Build
๐ฌ Questions & Discussion
Have a doubt? Ask below โ no login needed.
Loading comments...