Concept Flow - nslookup and dig for DNS
Start Command
Send DNS Query
Receive DNS Response
Parse Response
Display Results
End
The command sends a DNS query, waits for the response, parses it, and then shows the results.
nslookup example.com dig example.com
| Step | Command | Action | Output Example | Notes |
|---|---|---|---|---|
| 1 | nslookup example.com | Send DNS query for example.com | Server: 8.8.8.8 Address: 8.8.8.8 Non-authoritative answer: Name: example.com Address: 93.184.216.34 | nslookup sends query and shows IP address |
| 2 | dig example.com | Send DNS query for example.com | ; <<>> DiG 9.16.1-Ubuntu <<>> example.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12345 ;; ANSWER SECTION: example.com. 86400 IN A 93.184.216.34 ;; Query time: 30 msec ;; SERVER: 8.8.8.8#53(8.8.8.8) ;; WHEN: Thu Jun 01 12:00:00 UTC 2023 ;; MSG SIZE rcvd: 56 | dig shows detailed DNS response including header and answer |
| 3 | nslookup invalid.domain | Send DNS query for invalid.domain | Server: 8.8.8.8 Address: 8.8.8.8 ** server can't find invalid.domain: NXDOMAIN | Shows error when domain not found |
| 4 | dig invalid.domain | Send DNS query for invalid.domain | ; <<>> DiG 9.16.1-Ubuntu <<>> invalid.domain ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 54321 ;; Query time: 20 msec ;; SERVER: 8.8.8.8#53(8.8.8.8) ;; WHEN: Thu Jun 01 12:01:00 UTC 2023 ;; MSG SIZE rcvd: 45 | dig shows NXDOMAIN status for not found domain |
| 5 | End | No more queries | Command prompt returns | Execution ends |
| Variable | Start | After nslookup example.com | After dig example.com | After nslookup invalid.domain | After dig invalid.domain | Final |
|---|---|---|---|---|---|---|
| DNS Query | None | example.com | example.com | invalid.domain | invalid.domain | None |
| DNS Response Status | None | NOERROR | NOERROR | NXDOMAIN | NXDOMAIN | None |
| IP Address | None | 93.184.216.34 | 93.184.216.34 | None | None | None |
nslookup and dig send DNS queries to get domain info. nslookup shows simple answers; dig shows detailed info. Both report errors like NXDOMAIN if domain not found. Use these commands to check domain IPs and DNS records. nslookup is simpler; dig is more detailed and flexible.