Udemy logo

dns lookup commandDNS stands for Domain Name System and is sometimes also referred to as a Domain Name Server or a Domain Number System. DNS simplifies our web browsing experience. Every website we visit has a domain name and an associated IP address. Typically, we use the more practical domain name to visit websites instead of trying to remember the IP address like, 875.89.565.55. Think of DNS as a translator, it acts as a conduit between human language and machine language so we don’t have to memorize a series of numbers to browse the internet and the machine doesn’t have to try and read our non-numerical language.

DNS is sometimes known as the Internet’s Phone Book because it’s a huge database of IP addresses that are recalled when a domain name is typed in. Once the IP address is found for the appropriate domain name we can view the data in our browser. We would type in IP addresses in our browser to view sites but that would be impractical. If there is a DNS error the site may not load or may be delayed while the DNS server is trying to locate the correct IP address. To prevent having DNS issues take a minute to read DNS Issues You Didn’t See Coming. It may save you a lot of time and frustration in the future.

DNS Lookup Commands

The flow of information from the domain address to the DNS and back to the browser is called a forward lookup. This lookup is a function of the DNS database trying to access DNS information about a certain domain name. This happens every time we visit a website on the Internet by using a domain name. A reverse lookup is when an IP address is used in lieu of a domain name and the domain name is the information being sought. There are third party websites you can use like https://www.nslookup.io/ to access DNS information about a website. To avoid using third party sites when debugging or tracing information you can use the command line on your computer. If you’re unfamiliar with using the command line there is an online course to help guide you through it. Check out Master the Linux Command Line. Here are a few commands to know.

Name Server lookup

1. Access your command prompt. Use the command nslookup (this stands for Name Server Lookup) followed by the domain name or IP address you want to trace. Press enter. This command will simply query the Name Service for information about the specified IP address or domain name.

2. The first set of numbers you see is your IP address so don’t pay attention to that. Look at the second set of data to retrieve your answers. If you used an IP address for the nslookup you should see your answer next to the name section. If you used a domain name instead, you will see the IP address in the address section.

Reverse Lookup

There are a few ways to do this as discussed below, but here is a common used command.

1. Access your command prompt by going to Windows->Run.

2. Type Command into the blank field and hit enter. You should now see a black box which is your command line.

3. Type ping –a 12.343.132.12 (replace the numbers with the IP address you are trying to trace).

4. You should now see data pertaining to the IP address you wished to reverse lookup.

Host DNS Lookup

The host command is a simple tool for doing DNS lookups. It can translate domain names to IP addresses, IP addresses to domain names, identify name servers and even find out the domain mail server for an address.

1. Pull up your command line and type in host –t a domainname.com (replace domainname.com with the domain you are trying to resolve).

2. You should see the something that says domainname.com has address 78.264.564.256.

1. Type the command $ host –t mx domainname.com (again, replace domainname.com with the domain name you are tracing) into your command line. Press enter.

2. You will see an output similar to this:

domainname.com mail is handled by 3 domainname.com.S9A2.PSMTP.com.

domainname.com mail is handled by 2 domainname.com.S9A1.PSMTP.com.

1. Type in $ host –t ns domainname.com in the command line. Press enter.

2. You should see an output that looks like this:

domainname.com name server ns1.laughingsquid.net

domain name.com name server ns2.laughingsquid.net

1. Type the command $ host –a domainname.com or $ host –t any domainname.com

Dig DNS lookup

Dig is a great tool to perform DNS troubleshooting. It’s flexible and provides clear results that make this a go to for DNS administrators. The answers come from the name servers that are queried. Use this video tutorial to learn the ins and outs of network troubleshooting.

1. Type in command dig domainname.com mx

2. The output will look something like domainname.com mail is handled by 3 domainname.com.S9A2.PSMTP.com.

1. Type in the command $ dig +trace domainname.com

2. The output will be long and start off with global options.

3. To get a short answer use command $ dig +short domainname.com

4. The output will just be the IP address

1. Type in the command $ dig +noall +answer domainname.com

2. The output will be all of the records starting with A.

1. Type in the command $ dig –x +short {} (fill in the actual IP address) or  $ dig –x +short. Again, fill in the actual IP address.

2. The output will be the domain name of the IP entered.

The Internet is a complex entity and understanding how it works in the backend isn’t for everyone. However, if you are thinking about becoming a Network Engineer or System Administrator you could really benefit from this TCP/IP training video that will address how Transmission Control Protocol and Internet Protocols connect and communicate throughout the Internet.

Page Last Updated: April 2014

Featured course

Naming Systems using Blockchains: On-chain and Off-chain

Last Updated September 2022

Highest Rated
  • 1.5 total hours
  • 43 lectures
  • Beginner Level
4.9 (13)

Basics of DNS and Blockchain implementations - On-chain and Off-chain | By Sam Ghosh

Explore Course

DNS students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy Business.

Request a demo