Tutorial on NslookUp – Command-Line Tool to Query DNS Records [Examples]

Что значит authoritative и non-authoritative

В ответе на любую команду утилита показывает, с какого сервера была получена информация. Ответ приходит от серверов двух типов:

Authoritative answer (авторитетный ответ) – это ответ, который получен от основного (официального) сервера. Non-authoritative answer (неавторитетный ответ) – это ответ от промежуточного сервера. Например, на скриншотах из нашей статьи можно увидеть, что ответ приходил от non-authoritative сервера:

Обратите внимание! На промежуточном сервере может храниться кэшированная копия DNS. Если запись DNS была изменена недавно, кэшированная копия может содержать неактуальную информацию.

Что такое nslookup

DNS ― это центральный элемент интернет-системы. DNS соединяет IP-адрес с доменным именем, которое ему соответствует. Благодаря этой системе, нам не нужно запоминать набор цифр (например 123.123.123.123), чтобы перейти на сайт. Достаточно ввести домен в поисковую строку и браузер автоматически преобразует его в IP-адрес.

Однако посмотреть DNS может не только браузер. Любой пользователь может получить информацию о записях через сервис Whois или через NSLOOKUP. NSLOOKUP — это утилита, которая позволяет через командную строку узнать содержимое DNS. Утилита поможет:

. Enabling debug mode using -debug

You can turn on/off the debugging using -debug option in the command line

Change timeout interval to wait for a reply

You can change the default timeout to wait for a reply using -timeout option.

Common error messages

Connection Refused or Network is Unreachable – The connection to the DNS name server or finger server could not be made. This error commonly occurs with ls and finger requests.

Format Error – The DNS name server found that the request packet was not in the proper format. It may indicate an error in nslookup.

No Records – The DNS name server does not have resource records of the current query type for the computer, although the computer name is valid. The query type is specified with the set querytype command.

No Response From Server – No DNS name server is running on the server computer.

Non-Existent Domain – The computer or domain name does not exist. Check to make sure your spelling is correct.

:/>  Как почистить диск С от неустановленных обновлений

Refused – The DNS name server refused to service the request.

Server Failure – The DNS name server found an internal inconsistency in its database and could not return a valid answer.

Timed Out – The server did not respond to a request after a certain amount of time and a certain number of retries. You can set the time-out period with the set timeout subcommand. You can set the number of retries with the set retry subcommand.

 Back to Top

How to find an authoritative response

Typically, most of the responses to your nslookup queries are going to be non-authoritative. Meaning the response is from a cached copy from a third-party and not from the primary DNS server holding the master copy. For troubleshooting purposes, it’s important to realize that a cached copy may not contain the most up-to-date information.

How to open command prompt

To use this utility, you will need to launch the Command Prompt window. The three common ways to launch the Command Prompt window are:

  1. Search for cmd using the built-in Windows search tool.
  2. Right-click on the Start icon and select Command Prompt.

    Tutorial on NslookUp - Command-Line Tool to Query DNS Records [Examples]

  3. Press the keyboard combination WinKey R, then type cmd at the Run window that appears.

    Run cmd

 Back to Top

Installing nslookup

nslookup comes preinstalled on all major operating systems. If you need to install it again on Ubuntu or another Linux distro featuring the APT package manager, install the dnsutils package:

sudo apt install dnsutils

On CentOS, Fedora, and Red Hat, nslookup is part of the bind-utils package. Install it by running:

sudo dnf install bind-utils

Mx lookup

In case you don’t know about MX record, here is a simple explanation.

MX record is an entry defined in the DNS zone configuration to determine what mail server is responsible for handling domain’s email. For that, you should configure at least one MX record in order to receive email for your domain.

:/>  Non unicode windows 10 - Вэб-шпаргалка для интернет предпринимателей!

Furthermore, you can add many MX records, where each record should point to a different mail server. It is to handle load-balancing on your email infrastructure. However, it is still fine to have only one mail server.

Nslookup options

Find all the important nslookup options in the following table.

nslookup OptionDescription
-domain=[domain-name]Change the default DNS name.
-debugShow debugging information.
-port=[port-number]Specify the port for queries. The default port number is 53.
-timeout=[seconds]Specify the time allowed for the server to respond.
-type=aView information about the DNS A address records.
-type=anyView all available records.
-type=hinfoView hardware-related information about the host.
-type=mxView Mail Exchange server information.
-type=nsView Name Server records.
-type=ptrView Pointer records. Used in reverse DNS lookups.
-type=soaView Start of Authority records.

Perform a reverse dns lookup

While nslookup provides information about a domain name, it can also be used to look for the domain name associated with an IP address.

Perform a reverse DNS lookup using the following syntax:

nslookup [ip-address]

The command outputs the domain name.

Query a non-default port

DNS servers use port 53 to communicate. If you want to check a different port, specify it with the port option:

nslookup -port=[port-number] [domain-name]

Redirect output to text file

 Back to Top

Summary

MX lookup is an easy task and should be well-handled if you’re in charge of mail server configuration or DevOps.

So far, nslookup is more commonly used than host and dig utility, because it’s available by default on many systems.

If you know any other methods for MX lookup, please share with me in comments. I’d love to know !

Using dig utility

Another utility that is very useful for MX lookup is dig. Just make sure it is available on your system.

:/>  Скачать бесплатно стандартную игру Косынка на компьютер для Windows 10

The way to use dig is no difference from host and nslookup at all. However, dig provides a pretty much verbose output for nameserver record query.

Using host utility

Beside nslookup, there is another utility you can use for MX lookup is host utility.

Typing the command into terminal, if it’s available you can use it. Otherwise, if you’re on Linux/Unix/BSD, you can install by your install command based on distribution.

Specifically, for Debian-based Linux, ex. Ubuntu, you can use following command:

$ apt-get install host

The syntax of host utility is as simple as nslookup.

$ host -t MX DOMAIN_NAME

For example, trying to lookup MX records for gmail domain again using `host`.

View all records

View all available DNS records of a domain using the any option.

nslookup -type=any [domain-name]

The output shows NS, SOA, MX, and TXT information:

View domains mx records

MX records store all relevant Mail Exchange server data. This information is used to route all email requests for the domain to the appropriate mail server.

Check a domain’s MX data by typing:

nslookup -type=mx [domain-name]

The output shows the names of mail servers.

View domain’s ns records

Name Server (NS) records store names of the domain’s name servers. To see a domain’s NS records, type:

nslookup -type=ns [domain-name]

The output lists all available name servers:

View information about a specific name server

See the name, IPv4 and IPv6 information of a specific name server on a domain by using the following syntax:

nslookup [domain-name] [name-server]

The output is now limited to the nameserver you specified:

Как изменить интервал ожидания

Когда интернет слабый, для ответа сервера нужно больше времени, чем обычно. Если ответ не приходит в течение 5 секунд, запрос либо повторяется, либо появляется ошибка. Чтобы ответ от сервера успел дойти, нужно увеличить время ожидания. Для этого введите команду:

Где:

Как использовать утилиту nslookup

В Windows и macOS утилита встроена, поэтому можно сразу переходить в терминал и начинать с ней работать. Для Linux-систем иногда нужна её установка.

Для установки утилиты в CentOS и Ubuntu в терминале введите:

Для установки утилиты в Debian введите:

Теперь можно переходить к работе с утилитой. Если вы хотите сделать несколько запросов NSLOOKUP, можно включить утилиту в интерактивном режиме. Тогда вам не придется каждый раз писать nslookup в командах.

Чтобы выйти из интерактивного режима, введите exit.

Оставьте комментарий

Adblock
detector