How to Troubleshoot DNS with dig and nslookup ?

Amongst other users, DNS helps web users connect to websites without memorizing IP addresses—unique numeric IDs assigned to computers to enable other computers to identify and communicate with them.

This article guides you on how to troubleshoot DNS with dig and nslookup.

But first, let’s clear a few things.

Why DNS Errors Occur ?

People often see the domain name system, DNS for short, as the internet’s phone book. It’s a network of servers that track domain names and matches them to the correct IP addresses.

When you visit a website with the domain name (like scalahosting.com), your browser asks the DNS server for the IP address, enabling you to connect to the website. 

DNS error occurs when the browser is unable to connect to the IP address. And one of the primary causes of this error is the DNS cache’s Time to Live (TTL). 

It’s the amount of time web admins set a packet (DNS information) to exist in a DNS cache before expiration—this is where device operating systems or browsers locally store DNS information to speed up future requests.

A DNS change doesn’t often propagate in real-time – the TTL determines when and how fast it does. 

When you make recent changes to your DNS records, move to a new host, or change the domain name, your website visitors will continue to see the old results or run into error until the TTL expires.

Basic Troubleshooting for DNS Issues

Some DNS issues require basic troubleshooting to resolve. 

Let’s quickly take a look at them :

  • Web browsers often report connectivity problems as DNS issues. So always check your routers and internet connection.
  • Switch off your router (or unplug your modem) and wait for a few minutes before switching it back or reconnecting the modem.
  • Run malware to find out if a virus is blocking internet access.
  • Ping the website with Down For Everyone Or Just Me. If the website is down just for you, then it’s a DNS problem – otherwise, it’s not necessarily a DNS problem, it might be from the host.
  • Flush your DNS cache to eliminate polluted DNS information.

Troubleshooting DNS With Command Line

If the DNS server fails to respond after basic troubleshooting, then you might want to use the command line to troubleshoot the IP address the domain currently points to.

The article makes it intuitive – let’s quickly examine how to go about it.

Troubleshooting With Dig on macOS and Linux

Dig is the primary command-line tool for troubleshooting DNS issues on macOS and Linux. 

It stands for Domain Internet Groper, and it enables users to dig into DNS issues from their computer rather than using web-based tools. You could learn more about Dig by typing [man dig] in the Linux command line. 

But follow these quick steps to troubleshoot DNS issues on your macOS and Linux computers :

  • Open the terminal window. Follow this navigation path to open the terminal app on macOS, Applications >> Utilities >> Terminal. If it’s a Linux device, use the terminal shortcut key CTRL + ALT + T to open the window.
  • Run this command at the command prompt to troubleshoot the DNS dig example.com

Replace example.com with the domain name you intend to test.

Dig presents DNS information as questions and answers. The ‘QUESTION SECTION’ shows the requests while the ‘ANSWER SECTION’ displays the response to the requests. 

Below is an example of Dig information for the domain, example.com.

How to Troubleshoot DNS with dig and nslookup ?, Troubleshooting With Dig on macOS and Linux

In the QUESTION SECTION, we could see the Dig command looks up for the A record of example.com, and the ANSWER SECTION shows the domain points to IP address 93.184.216.119.

If you wish to use a specific DNS server for the query, then you’d need to include the @ option in the dig command, and here’s an example, dig @208.67.222.222 example.com

The command performs a DNS lookup for the domain, www.example.com using an OpenDNS server with the IP address 208.67.222.222.

OpenDNS is an American company that provides DNS resolution services.  The company allows users to use its DNS servers for DNS lookup instead of relying on ISPs’ DNS servers or locally installed DNS servers.

Note: Dig command displays the A record of a domain by default. If you wish to look up a different DNS record, you could specify that at the end of the command-line thus, dig example.com MX

This command-line looks up the MX (mail exchanger) records of the domain, example.com.

Troubleshooting With nslookup

The nslookup program helps windows users to troubleshoot DNS issues using the command-line. 

Follow these steps to get started :

  • Press the Windows key and R on your keyboard to open the Run interface.
  • Type cmd on the search bar and press the Enter key to open the DOS command window.
  • Run this command at the command prompt to troubleshoot the DNS nslookup example.com

Replace example.com with the domain name you intend to test.

Check out how the nslookup program presents its outputs. Below is the nslookup information for google.com.

How to Troubleshoot DNS with dig and nslookup ?, Troubleshooting With nslookup

According to the nslookup information, google.com currently points to 216.58.223.206, and the DNS server used for the query is unknown, but the IP address is 10.109.7.113.

Note: you could also use the @ option in the nslookup command if you wish to use a specific DNS server for the query. nslookup also looks up the A records of a domain by default.

Use this command to look up a different DNS record:

  • set type=MX
  • example.com

Wrapping it Up

This article outlines easy steps to troubleshoot DNS issues on Windows, macOS, and Linux operating systems using the command line. 

However, you could use these web-based options if you’re not comfortable with the command line:

 

Was this helpful?

What’s your goal today?

1. Find the right Managed VPS solution

If you’re looking for industry-leading speed, ease of use and reliability Try ScalaHosting with an unconditional money-back guarantee.

2. Make your website lighting fast

We guarantee to make your WordPress site load in less than 2 seconds on a managed VPS with ScalaHosting or give your money back. Fill out the form, and we’ll be in touch.

Please enter a valid name
Please enter a valid website
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

3. Streamline your clients’ hosting experience

If you’re a web studio or development agency hosting more than 30 websites, schedule a call with Vlad, our co-founder and CTO, and see how we can deliver unmatched value to both your business and your clients.

Photo

Need a custom cluster or professional advice?

Book a meeting and get a free 30-minute consultation with Vlad, co-founder & CTO of Scala Hosting, who will help you select, design and build the right solution - from a single data center cluster to a multi-region & multi-datacenter high availability cluster with hundreds of servers.

Book a free consultation

4. Learn how to grow your website in 2024

An all-star team of SEO and web influencers are sharing their secret knowledge for the first time in years. Learn about the future of SEO, Web Design best practices and the secrets to getting the foundation for your website to thrive. Watch the exclusive webinar.

An Exclusive Insiders Look Behind The SEO and Web Development Curtain

Rado
Author

Working in the web hosting industry for over 13 years, Rado has inevitably got some insight into the industry. A digital marketer by education, Rado is always putting himself in the client's shoes, trying to see what's best for THEM first. A man of the fine detail, you can often find him spending 10+ minutes wondering over a missing comma or slightly skewed design.