You can troubleshoot different DNS problems using the built-in commands that you already have on your computer. No matter if you are a Windows, Linux, or macOS user, you have various commands included in your OS. Here are the 5 most popular DNS troubleshooting commands that you should know and how to use them.
Ping commands (Linux, macOS, and Windows)
Ping is a very simple tool that sends packets (ICMP) from your computer to the destination that you have set. The target could be a hostname or an IP address of a particular device.
You can use it through the Terminal (Linux and macOS) or through the Command Prompt (Windows).
The basic ping command looks like this:
ping google.com, or ping 18.104.22.168
You will get statistics about the time it took for the packages to arrive, the percentage of packet loss, and additional parameters, depending on the options you have added.
To get the list of options, use “ping-?” (Windows) or “ping-h” (Linux and macOS), depending on your OS.
You can use the ping command to see if a server is responsive, or as a monitor, you can set the ping command to send constantly pings using a particular interval for the checking.
Nslookup command (Windows, Linux, macOS)
The nslookup command is a DNS diagnostic command that has the advantage of being present on all popular OSes. Using different nslookup commands, you can see all types of DNS records.
Use the nslookup command like this:
nslookup -type=any google.com
The above command will show all available DNS records for the domain google.com. You can change the type to ns, mx, a, aaaa, soa for a particular DNS record type. You can put another domain name or an IP after the DNS type.
Traceroute (Linux and macOS) / Tracert command (Windows)
Traceroute command on Linux and macOS or Tracert on Windows is another built-in software that you can use for DNS troubleshooting. With this one, you can understand better the route of the DNS queries. You will see each individual hop with their response time, hostname, and IP address, and you will see a complete picture of the route to the target.
The traceroute and its Windows version tracert both have additional options that can further help you do more precise DNS troubleshooting.
This is how traceroute command, and tracert command looks like:
Dig command (Linux and *macOS)
Dig is a very handy DNS diagnostic tool that you have built-in on most Linux distros. You can get it on *macOS with Homebrew, but sadly there is no Windows version. You can use the dig command to probe your nameservers, see all kinds of DNS records, perform a reverse DNS lookup, check a specific port, and even traceroute both with IPv4 and IPv6. It is good all-around software. The basic dig command looks like this:
Where you can change the domain name with another or an IP address. The great part about dig is that the result of your query is full of information. There are also many options that can make your probe more specific and get you better results.
Host command (Linux)
The host command is very similar to the dig command in functionality. You can use it for various DNS troubleshooting, including seeing DNS records, checking a domain name or IP address, seeing the nameservers of a domain, doing a reverse lookup, and modifying the DNS queries with various options. In most cases, it overlaps with the dig command, and since both are built-in on Linux, you can decide which one to use.
You already have many DNS troubleshooting tools inside your computer. Use them whenever you need them. They are small and easy to use, and in most cases, they will provide you enough information for your needs. The DNS troubleshooting commands might look outdated, but they work!