Test DNS resolution with nslookup
In the previous step, we looked at the /etc/resolv.conf
file, which tells your system where to find DNS servers. Now, let's actively test if your system can resolve a domain name using the nslookup
command.
nslookup
is a command-line utility for querying the Domain Name System (DNS) to obtain domain name or IP address mapping or for any other specific DNS record. It's a fundamental tool for network troubleshooting.
Let's use nslookup
to find the IP address for example.com
. Type the following command in your terminal and press Enter:
nslookup example.com
You should see output similar to this:
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: example.com
Address: 93.184.216.34
Let's break down this output:
Server: 127.0.0.53
: This shows the IP address of the DNS server that nslookup
used for the query. As we saw in the previous step, this is the local resolver specified in /etc/resolv.conf
.
Address: 127.0.0.53#53
: This is the IP address and port number of the DNS server. DNS typically uses port 53.
Non-authoritative answer:
: This indicates that the answer came from a caching DNS server, not the authoritative server for example.com
.
Name: example.com
: This is the domain name you queried.
Address: 93.184.216.34
: This is the IP address that the DNS server returned for example.com
. This is the address your computer would connect to when you try to visit example.com
.
If nslookup
returns an IP address, it means your system successfully resolved the domain name. If it fails, you might see an error message indicating a problem with DNS resolution.
You can try resolving other domain names as well, like google.com
or labex.io
.
nslookup google.com
The output will show the IP addresses associated with google.com
. Note that a single domain name can have multiple IP addresses.
This command is invaluable for verifying that your DNS configuration is working correctly and for finding the IP addresses of specific domain names.
Click Continue to move on to the next step.