Find a Domain's IP Address (A Record) with dig and nslookup
In this step, you will perform a standard forward DNS lookup, which is the process of resolving a domain name to an IP address. This is one of the most common functions of DNS. The specific type of record that maps a domain name to an IPv4 address is called an A record. We will use two popular command-line tools for this task: nslookup and dig.
First, you need to ensure these tools are installed. They are part of the dnsutils package on Debian-based systems like Ubuntu. Let's update your package list and install it.
sudo apt-get update
sudo apt-get install -y dnsutils
Now that the tools are ready, let's use nslookup (which stands for "name server lookup") to find the IP address for www.google.com.
nslookup www.google.com
The output shows you the server that answered the query (your default from Step 1) and the "Non-authoritative answer," which contains the IP address(es) associated with www.google.com.
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: www.google.com
Address: 142.250.189.196
Name: www.google.com
Address: 2607:f8b0:4005:80d::2004
Next, let's perform the same query using dig (Domain Information Groper). dig is often preferred by system administrators because it provides more detailed, structured output.
dig www.google.com
Examine the output from dig. It is divided into sections. The QUESTION SECTION shows what you asked for (an A record for www.google.com). The ANSWER SECTION provides the result, including the IP address and the TTL (Time To Live) value, which indicates how long a resolver can cache this information.
; <<>> DiG 9.18.1-1ubuntu1.3-Ubuntu <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5247
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;www.google.com. IN A
;; ANSWER SECTION:
www.google.com. 7 IN A 142.251.46.196
;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Mon Jul 14 14:55:18 CST 2025
;; MSG SIZE rcvd: 59
By comparing the two outputs, you can see that while both tools achieve the same goal, dig offers a much more comprehensive view of the DNS response.