Exercise: Finding Name Servers

In this lesson, we will look at a few command-line tools to lookup domain name servers.

Finding The Authoritative Name Server Using host

Press + to interact
host -t ns google.com

host is a DNS lookup utility. It is normally used to map hostnames to IP addresses. However, with a combination of flags, it can be programmed to perform a myriad of DNS-related tasks.

The syntax of the command above, for instance, is

Press + to interact
host -t ns hostname.com
  • host invokes the host command
  • -t is the type flag. It is used to specify the type of the command. Check out host’s manpage for a list of all the types available.
  • ns specifies the type. It stands for the name server in this case.
  • hostname.com can be any website of your choice.

We encourage you to experiment, explore, and get creative with the tool!

Checking What Your Local DNS Server Is

To check the IP address of your local DNS server, run the following command on UNIX based machines. If you’re on a mobile machine, try www.whatsmydnsserver.com. There are a lot of instructions available for Windows machines online.

Press + to interact
cat /etc/resolv.conf

Output

Here is what the output may look like

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 169.254.169.254
search c.educative-exec-env.internal google.internal

You can safely ignore the first two lines since they are comments. On the third line, nameserver shows the IP address of the local DNS server. On the last line, search represents the default search domain that is used to resolve a query for a domain with no suffix (for example, www.facebook).

Note: Educative’s code widgets run on a remote server. The code runs there, the output is then sent back to your machine and displayed. So, the DNS server shown here is local to the server that runs Educative’s code.


Now that we have a good idea of how DNS works, let’s study DNS records and messages in the next lesson.

Get hands-on with 1400+ tech skills courses.