Explore three different options for using a DNS lookup command, with a focus on some nslookup commands, the basics of DNS, and how you can troubleshoot DNS issues using these commands.
![[Featured Image] A businessperson learning how to use a DNS lookup command works on their laptop as they complete coursework for an online class.](https://d3njjcbhbojbot.cloudfront.net/api/utilities/v1/imageproxy/https://images.ctfassets.net/wp1lcwdav1p1/6qHzXZQ9TSNmWUhsuRjKaM/357be55a0b48216f66ea245f030d4517/GettyImages-2241261515.jpg?w=1500&h=680&q=60&fit=fill&f=faces&fm=jpg&fl=progressive&auto=format%2Ccompress&dpr=1&w=1000)
Domain Name System (DNS) lookup commands are a fast way to get information on DNS nameserver IP addresses, mail exchangers, and more.
Three DNS lookup commands include nslookup, dig, and host.
A DNS lookup command allows IT professionals to quickly diagnose issues with internal servers and external web domains.
You can use nslookup across Windows, Linux, and macOS machines if you are administering computers with multiple operating systems.
Learn more about DNS, how it works behind the scenes, what DNS lookup commands do, some basic commands, and the different utilities available to you. If you're ready to start building in-demand skills in IT, try the Google IT Support Professional Certificate to learn more about DNS, day-to-day IT troubleshooting, and how to use the command line interface (CLI).
A DNS lookup command, such as nslookup or dig, allows you to query name servers specifically when troubleshooting DNS connection issues. With a DNS lookup command, you can show:
A records (server names)
The associated IP addresses
MX records (mail exchange)
The canonical name (CNAME) records
Other resource records like start of authority (SOA), name server (NS), and pointer records (PTR).
DNS is the process of translating the human-readable domain name (www.coursera.org) to the machine-readable IP address of the server that sends the files to load the www.coursera.org homepage. DNS effectively maps domain names, automatically converting them into IP addresses. Computers understand IP addresses easily, while humans have a stronger grasp on domain names. With DNS, you only need to remember coursera.org, and the computer will convert it into the numbers necessary to obtain the information and display the proper web page quickly.
DNS resolution follows these steps:
1. You, the user, type in the domain of the website you want to visit, such as www.coursera.org, in your web browser, which sends a query to a server known as the DNS resolver.
2. The DNS resolver, which is typically owned by your internet service provider (ISP), sends a request to a DNS root nameserver.
3. The root nameservers, located across the world, respond to the DNS resolvers with the Top Level Domain (TLD) DNS server, which can be .com or .net, but in this example is .org.
4. The DNS resolver then sends a request to the .org TLD.
5. The .org TLD scans its records and responds to the DNS resolvers with the IP address of the servers associated with coursera.org.
6. The DNS resolver receives the IP address.
7. The DNS resolver then responds back to the web browser with the IP address.
8. The web browser can now query the actual IP address associated with coursera.org, where it can make an HTTP connection to the server, which sends the file necessary to load www.coursera.org.
You can use DNS lookup commands like nslookup by launching CMD or PowerShell when using Windows, or the terminal for macOS and Linux operating systems. To launch nslookup, simply open the terminal or PowerShell and type: nslookup and the IP address or domain name you'd like to troubleshoot.
If you are using PowerShell, nslookup is installed by default. If your Linux machine does not have nslookup installed, you can install it by running the command:
sudo dnf install bind-utils (RedHat Distros)
sudo apt install bind-utils (Ubuntu/Debian Linux Distros)
Once installed, the commands for nslookup are the same across Windows, macOS, and Linux, making it convenient for system administrators working across different operating systems.
The most basic way to use nslookup is to write a command that directly queries an IP or domain name, for example:
nslookup www.coursera.org
The output for this command should be the IP address of the web server. Say you wanted to confirm that the MX records are working for www.coursera.org. You could use the command:
nslookup -type=MX www.coursera.org
This will give you information about the MX provider for Coursera, which is through Amazon DNS services. Other tools in nslookup include:
nslookup -name mydomain.com gives you the CNAME and IP address of the domain.
nslookup -debug mydomain.com gives you detailed information about packets sent and received
nslookup -type=[record type: A, AAAA, MX, CNAME, etc.] mydomain.com can display a specified resource type
nslookup -recurse tells the DNS services to search other services if it does not have the requested information
So far, the examples of nslookup above have all been in noninteractive mode, so each command returns only one piece of data at a time, meaning you'd have to use the nslookup command for every piece of information you want. However, using nslookup in interactive mode allows you to search for various information at one time. You can enter interactive mode by simply typing and returning:
Nslookup
Once you are in interactive mode, you should just see the ">" symbol in the command line interface. From there, you can simply type commands in nslookup like before:
www.coursera.org
This will return the server and IP address. You can continue to type commands in interactive mode without needing to type nslookup each time. Exit interactive mode simply by entering the command:
exit
This will terminate the interactive mode of nslookup.
While nslookup is a popular DNS lookup tool, it is not the only one available. Other tools you might consider using include:
ping: a basic tool that helps you determine whether the network issue is with the DNS or the network itself.
dig: similar to nslookup in that it helps you troubleshoot DNS issues, but provides much more detail for advanced troubleshooting tasks
host: provides simple, straightforward outputs without the detail of dig, making it helpful in writing networking scripts
The DNS lookup command you use will likely vary depending on your OS environment. Compare the three command options to see how nslookup, dig, and host stack up against one another:
| nslookup | dig | host |
|---|---|---|
| Available on all OSes but native to Windows | Pre-installed on many Linux distros and macOS, but requires installation on Windows | Pre-installed on Linux and macOS, but requires installation on Windows |
| Simple answers | Most verbose answers | Simple answers |
| Commands written as: nslookup www.coursera.org | Commands written as: dig www.coursera.org | Commands written as: host www.coursera.org |
Each DNS lookup tool provides similar information, and the one you use will depend on what's available at the time and your personal preferences.
If you had just the IP address of a source, you could use nslookup to perform a reverse lookup to find the name of the server it came from. You can do this by typing the command:
nslookup <the IP address you want to look up>
dig -x <the IP address you want to look up>
host <the IP address you want to look up>
8.8.8.8 is the Google Public DNS IP Address. You can change your router settings to use the Google Public DNS instead of the DNS provided by your ISP. Changing the DNS your router communicates with may improve your browsing speed and add more security measures. Note that changing your DNS settings is only recommended if you are proficient in administering your own operating system and networking.
As a professional working in IT, cybersecurity, or networking, you’ll likely need to build DNS lookup skills because they allow you to troubleshoot DNS resolution issues effectively. You may run into issues with users, whether internal users connecting to a server or external users connecting to websites, or being unable to access server files, a printer, or a webpage. By using DNS lookup commands to access the administrative records of each server, you can better spot where the problem lies.
To start building skills in networking fundamentals, consider earning an entry-level networking certification, such as the Cisco Certified Network Associate (CCNA) or the CompTIA Network+ certification. Both credentials can help prepare you for an entry-level career in IT and allow employers to verify your skills in configuring, maintaining, and troubleshooting networks.
Subscribe to our newsletter, Career Chat, on LinkedIn to stay up to date on industry trends, career resources, and networking opportunities. Or, explore these free resources for networking professionals:
Watch on YouTube: CCNA vs. Network+: Decoding Your Networking Certification Path
Whether you want to develop a new skill, get comfortable with an in-demand technology, or advance your abilities, keep growing with a Coursera Plus subscription. You’ll get access to over 10,000 flexible courses.
Editorial Team
Coursera’s editorial team is comprised of highly experienced professional editors, writers, and fact...
This content has been made available for informational purposes only. Learners are advised to conduct additional research to ensure that courses and other credentials pursued meet their personal, professional, and financial goals.