How to Use Nslookup Windows Command (11 Examples)

Утилита и одноименная команда nslookup позволяет обращаться к серверу имен (NS) из командной строки. С ее помощью можно выполнить проверку работы DNS-сервера и созданных в нем записей. В данной инструкции подробно разберем работу с данной утилитой.

nslookup и синтаксис
Описание опций
Примеры
Аналоги

In this tutorial, you will learn how to use nslookup to check DNS records.

I’ll show you how to check several DNS record types (A, PTR, CNAME, MX, etc) by using the windows nslookup command.

And in this post, I’ll show you how to use nslookup against your local DNS server and an external DNS server (great tip for troubleshooting).

Let’s get started!

Table of Contents:

Hi! Your public IP addresses are:

Your DNS resolvers are:

Your DNS security:

Load dnscheck.tools in any web browser to identify your current DNS
resolvers and check DNSSEC validation.

DNS Test Server

dnscheck.tools is also a custom DNS test server!

Options affect the dns responses to queries for domain names formed from those options.

Answers are provided for A, AAAA, and TXT queries. Responses are signed with DNSSEC algorithms 13, 14, and 15
by default.

A hyphen-separated list optionally containing:

  • any of:
    • <random> — any six-character alphanumeric string; useful for cache busting
    • watch — mirror corresponding requests to the /watch/<random>
      page; requires <random>
    • truncate — set the message truncation flag in responses over UDP
    • compress — force the use of DNS message compression in the response
  • one of:
    • padding<n> — add <n> bytes of EDNS0 padding, up to 4000, to A, AAAA,
      and TXT responses
    • txtfill<n> — add <n> bytes of padding as TXT data, up to 4000, to TXT
      responses
  • one of:
    • formerr — respond with «format error»
    • servfail — respond with «server failure»
    • notimpl — respond with «not implemented»
    • refused — respond with «query refused»
    • noreply — do not respond
  • one of:
    • nosig — do not provide any DNSSEC signature in the response
    • badsig — provide an invalid DNSSEC signature in the response
    • expiredsig[<t>] — provide an expired DNSSEC signature in the response,
      <t> seconds in the past (default 1 day)
  • one of:
    • alg13 — use only ECDSA P-256 with SHA-256 when signing the response
    • alg14 — use only ECDSA P-384 with SHA-384 when signing the response
    • alg15 — use only Ed25519 when signing the response
  • one of:
    • ipv4 — respond only over IPv4
    • ipv6 — respond only over IPv6
  • one of:
    • tcp — respond only over TCP (including DNS over TLS)
    • udp — respond only over UDP; disables automatic message compression and truncation
  • # dig watch-abc123.go.dnscheck.tools txt
  • # dig badsig-watch-abc123.go.dnscheck.tools txt
  • # dig noreply-watch-abc123.go.dnscheck.tools txt
  • addr.tools — our collection of DNS related tools
  • r/dns,
    r/HomeNetworking
    — relevant subreddits

We don’t track or care who you are. We aren’t affiliated with any VPN provider. This site doesn’t use cookies.
Cheers!

This article describes how to use the dig and nslookup tools to test DNS settings. (Microsoft Windows uses nslookup, while Mac OS X and Linux use dig.) You can use these tools to determine the IP address associated with a domain name, obtain the mail server settings for a domain, and much more.

You can use web-based tools or command-line tools to run these types of tests.

For a general introduction to network troubleshooting, please read this article first.

Table of Contents
  • Troubleshooting DNS with web-based tools
  • Troubleshooting DNS with command-line tools
Содержание
  1. Troubleshooting DNS with web-based tools
  2. Troubleshooting DNS with command-line tools
  3. About DNS Lookup
  4. List of DNS record types
  5. Check TCP/IP Settings
  6. Flush the DNS Cache
  7. Release and Renew DHCP Server IP
  8. Change to Public DNS Servers
  9. Use dig
  10. Use nslookup
  11. Use host
  12. Use traceroute or tracert
  13. Contact Your ISP
  14. С чего начать?
  15. Ошибка “Connection timed out”
  16. Решение основных проблем с DNS
  17. Пустой ответ на команду dig
  18. Ошибка “Permission denied”
  19. Ошибка “No address records (A or AAAA)”
  20. Ошибка “CNAME and other data”
  21. Ошибка “Query denied”
  22. Ошибка “Transfer failed”
  23. Ошибка в синтаксисе
  24. Аналоги nslookup
  25. Ввод команды и синтаксис
  26. Why you must learn the Nslookup command line tool
  27. Примеры использования
  28. How DNS works
  29. Опции nslookup
  30. Использование опций
  31. NSLookup Syntax
  32. How to Use Nslookup to Check DNS Records
  33. Nslookup IP Address (IP to Domain Name)
  34. Nslookup domain name (Domain to IP Address)
  35. Nslookup MX record
  36. Nslookup SOA Record
  37. Nslookup CNAME
  38. Nameserver lookup
  39. Nslookup TXT record
  40. Nslookup all DNS records
  41. Nslookup domain controller
  42. Nslookup Verbose
  43. Nslookup use External DNS server
  44. Summary
  45. Tips for troubleshooting DNS Problems
  46. Step#1 Make sure you have connectivity to the DNS server?
  47. Step #2 Are other users or devices having name resolution issues?
  48. Step #3 Use NSLookup to test local server
  49. Step #5 Use NSlookup server to test forwarding DNS Server (UPstream)
  50. Step #6 Scan for viruses and spyware
  51. Step #7 Check the client’s host file
  52. Step #8 Flush DNS Cache

Troubleshooting DNS with web-based tools

If you have never worked at the command line before, web-based networking tools provide an easy way to start troubleshooting DNS. There are many web sites that provide these services for free.

For example, to test if DNS propagation is complete, you can visit http://www.whatsmydns.net and specify a domain name. The site displays a global map showing the IP address associated with the domain name for a variety of DNS servers around the world.

  1. Use your web browser to visit http://www.digwebinterface.com.
  2. In the Hostnames or IP addresses text box, type the domain that you want to test.
  3. In the list box, select .
  4. Under , select the check box.
  5. Under , select the server that you want to use for the DNS query. You can use the default name server, or select a specific DNS server, like OpenDNS or Google.
  6. Click . The page displays the results from dig, as well as the actual dig command used. If the domain has an A record configured, dig displays the domain name and its associated IP address.

Troubleshooting DNS with command-line tools

Dig (on Mac OS X and Linux) and nslookup (on Microsoft Windows) are the primary command-line tools for troubleshooting DNS issues.

Using nslookup on Microsoft Windows
  1. Open a DOS command window. To do this, click , click , type , and then press Enter.
  2. At the command prompt, type the following command. Replace example.com with the domain that you want to test:
    nslookup example.com
    • To use a specific DNS server for the query, add the server name or IP address to the end of the command. For example, the following command performs a DNS lookup on the example.com domain using an OpenDNS server (which has IP address 208.67.222.222):
      nslookup example.com 208.67.222.222
    • set type=MX
      example.com
  3. Server:  resolver1.opendns.com
    Address:  208.67.222.222
    
    Name:    example.com
    Address:  93.184.216.119
    

    From this, we can see that example.com is currently pointing to IP address 93.184.216.119. We can also see that DNS server resolver1.opendns.com was used for the query.

Using dig on Apple Mac OS X and Linux
  1. Open a terminal window. The procedure to do this depends on the operating system and desktop environment:
    • On Mac OS X, click , click , and then click .
    • On Linux, open a terminal window.
  2. dig example.com
    
    • To use a specific DNS server for the query, use the @ option. For example, the following dig command performs a DNS lookup on the example.com domain using an OpenDNS server (which has IP address 208.67.222.222):
      dig @208.67.222.222 example.com
    • dig example.com MX
  3. [email protected]:~$ dig example.com
    ; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> example.com
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46803
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;example.com.   IN A
    
    ;; ANSWER SECTION:
    example.com.  2424 IN A 93.184.216.119
    
    ;; Query time: 12 msec
    ;; SERVER: 192.168.0.1#53(192.168.0.1)
    ;; WHEN: Thu Jan  9 16:07:09 2014
    ;; MSG SIZE  rcvd: 45
    

    Dig displays a QUESTION SECTION (the request) and an ANSWER SECTION (what the DNS server sends in response to the request). In this case, we used the default options for dig, which simply looks up the A record for a domain. From this, we can see that example.com currently points to IP address 93.184.216.119.

Читайте также:  Начните работу с электронной почтой Yandex Connect для вашего домена уже сегодня

About DNS Lookup

DNS Lookup is a browser based network tool that displays DNS records showing publicly for the domain name being queried.

Enable Advanced Mode displays the authority, additional, DNS message header, and DNS server response information for the DNS query. This can help to understand more comprehensive DNS Lookup information.

Enable DNSSEC (Domain Name System Security Extensions), DNSSEC creates a secure domain name system by adding cryptographic signatures to existing DNS records. By checking its associated signature, you can verify that a requested DNS record comes from its authoritative name server and wasn’t altered en-route, opposed to a fake record injected in a man-in-the-middle attack.


List of DNS record types

DNS (domain name system) stores information related to domain names as a distributed database. The client-server service translates domain names to IP addresses and vice versa.

Troubleshooting DNS Issues
  • A stable internet connection.
  • Access to the command line/terminal.
  • A user account with administrator/sudo privileges.
  • Check cables

If using a wired connection, make sure everything is connected properly. On wireless networks, check if WiFi is turned on and connected. Check the router if all cables are functional. Try to switch ports for ethernet cables and test out the connection.

  • Restart router

Turn the router off and wait for at least two minutes before turning it on again. Wait until the router fully boots up before rechecking the connection.

  • Scan for malware
  • Check the website

If the problems arise when connecting to a particular website or a part of the website, check if the connection problem is with the website itself. One way to do this is using the ping command.

ping response and no response terminal output

The command output helps identify the reason for the connection problem:

1. If ping does not show a response, the issue is most likely on the server’s end.

2. A common cause of an error in the response is a poorly configured DNS server or firewall restrictions. Learn how to resolve the «Temporary failure in name resolution» error.

3. If the output shows a response, the problem is most likely with the DNS.

The comprehensive list below provides valuable tips for troubleshooting DNS issues.

Check TCP/IP Settings

Misconfigured DNS server addresses are a common issue. Reset the settings and check if communication is back to normal. Depending on which OS you’re using, the steps are different.

1. Search for Network Status in the Start menu and open the tool.

network status windows start

2. Select Properties under the network connection details.

ethernet properties button

3. Click the Edit button to change the IP settings.

ip settings edit button

4. If the IP assignment is Manual, double-check the IP, Preferred, and Alternate DNS addresses. Change IP assignment by selecting Automatic (DHCP) from the dropdown menu to reset back to normal.

ip settings automatic

5. Save the settings when finished.

1. Click the connection icon in the top-right corner.

connection ubuntu

2. Open the menu and select Wired Settings.

wired settings ubuntu

3. Click the gear icon in the connection pane to open the settings.

network settings ubuntu

4. Navigate to the IPv4 tab in the settings menu.

5. If manually assigned, double-check the Address and DNS IP address list. Select the Automatic (DHCP) option and change the DNS switch to Automatic to reset back to normal.

network settings automatic ubuntu

Apply the settings when finished and close the window. Lastly, check the connection to ensure everything functions correctly.

Note: Learn how to install and use PowerDNS on Ubuntu, an open-source DNS server solution that helps resolve namespaces.

Flush the DNS Cache

IP mapping to popular websites is often the target of malicious attacks. DNS caches information to improve loading speed, and it might have cached a wrong address. Clearing the DNS cache deletes all the lookup information and updates with subsequent requests.

Release and Renew DHCP Server IP

Releasing and renewing the IP address helps resolve an IP conflict and old DNS information by refreshing the cached information. The easiest way to accomplish a release and renewal is through the command prompt/terminal.

Warning: Resetting the IP disconnects the computer from the internet.

To renew the IP on Windows using the command prompt:

IPCONFIG /RELEASE
IPCONFIG /RENEW

2. Check the new information with:

IPCONFIG /ALL

To force IP renewal on Linux via the terminal:

sudo dhclient -r

The terminal outputs a confirmation message, and the connection is closed.

2. Run dhclient without any options to renew the IP:

sudo dhclient
sudo dhclient terminal output

Change to Public DNS Servers

Change the DNS servers to public domain addresses. Some standard options are:

  • Google’s 8.8.8.8 address as primary and 8.8.4.4 as secondary.
  • Cloudflare’s 1.1.1.1 address as primary and 1.0.0.1 as secondary.

Public domain addresses are generally reliable and are available for free. However, use this only as a temporary resolution.

Use dig

The dig command (domain information groper) provides DNS information and helps in diagnosing issues. The utility’s raw output makes it the preferred method for troubleshooting DNS issues.

The program is available on macOS and Linux by default and is free to install on Windows.

dig <domain name or IP>

For example, to show the information for phoenixnap.com, run:

dig phoenixnap.com
dig phoenixnap.com query terminal output
  • The status shows whether a query was successful.
  • The ANSWER SECTION shows a response to a request sent in the QUESTION SECTION.
  • The SERVER displays the address for the public DNS server.

By default, dig looks up the A record for a domain and shows which IP address the domain points to when resolving the name.

The dig tool offers many advanced options for comprehensive searches. For example, add the +trace tag to see the full path to the destination:

dig phoenixnap.com +trace
dig phoenixnap.com +trace query terminal output

The +trace option helps pinpoint traffic drops in the route to the destination.

To check the delegated name servers, use the ns option:

dig phoenixnap.com ns
dig phoenixnap.com ns query terminal output

Use the ns option to help identify and troubleshoot delegation problems.

Use nslookup

The nslookup command provides functions for checking different DNS records and servers. The tool is available on macOS, Linux, and Windows operating systems by default, and it was the first tool for querying DNS.

nslookup <domain name or IP>

For example, run nslookup for phoenixnap.com:

nslookup phoenixnap.com
nslookup phoenixnap.com terminal output

The output prints the DNS server’s address and the A record response. The nslookup command is preferable for Windows because of its availability.

Use host

The host utility is a straightforward program for performing a DNS lookup. The command is available for macOS and Linux systems.

The basic syntax for host is:

host <domain name or IP>
host phoenixnap.com
host phoenixnap.com terminal output

The host command is excellent for quickly checking if a domain name exists and resolves to an address. A typical use case for host is in bash scripts.

Use additional options to display more information. For example, add the -a tag to see a similar output to the dig command:

host -a phoenixnap.com
host -a phoenixnap.com terminal output

The output shows additional information in the answer section, such as the NS, SOA, MX, and other available records.

Use traceroute or tracert

The traceroute and tracert tools help trace a route from source to destination. When troubleshooting DNS issues, the commands help identify where packets stopped on the network. The traceroute command is available on macOS and Linux, while the Windows equivalent is tracert.

Note: Install the traceroute tool using the apt package manager:

sudo apt install traceroute

As a readily available and simpler alternative, use tracepath.

traceroute <domain name or IP>

If using a Windows machine, run:

tracert <domain name or IP>
traceroute phoenixnap.com terminal output

Contact Your ISP

If the computer uses the ISP’s DNS, you cannot resolve the issues on your end. Contacting the ISP helps determine the problem and pinpoint the difficulties on their end.

Читайте также:  Межсетевой экран микротик

DNS-сервер фактически является приложением, которое работает на отдельном физическом сервере или совместно с другими серверами и обрабатывает все запросы, содержащие доменные имена.

Как только вы зарегистрировали доменное имя, оно начинает обслуживаться DNS-сервером, и любое обращение к домену по имени проходит через него. С момента привязки доменного имени к DNS-серверу может пройти до 72 часов, чтобы домен начал работать. Если по истечении этого срока домен не заработал или возникла ситуация, когда работающий домен перестал отвечать на запросы, проведите быструю диагностику DNS.

С чего начать?

Используйте утилиту whois для первичной диагностики DNS. Актуально для Linux-систем.

whois ispserver.ru

How to Use Nslookup Windows Command (11 Examples)

В примере показан корректный вывод ответа на whois, который в большинстве случаев должен быть именно таким.

Строка с меткой “state:” обозначает статус, в котором находится домен. REGISTERED и DELEGATED в этой строке указывают на то, что домен зарегистрирован и делегирован.

Для получения краткой информации о домене используйте команду whois с параметрами:

whois ispserver.ru | grep -Ei 'name server|nserver|state'

How to Use Nslookup Windows Command (11 Examples)

Если домен не зарегистрирован (такого домена не существует), то ответ на whois будет следующим:

How to Use Nslookup Windows Command (11 Examples)

Используйте утилиту dig для обращения из командной строки к серверу DNS. Выполните трассировку маршрута пакетов к DNS-серверу командой:

dig ispserver.ru +trace

How to Use Nslookup Windows Command (11 Examples)

How to Use Nslookup Windows Command (11 Examples)

Если при трассировке на каком-то шаге передача запроса происходит не на нужный DNS-сервер (например, серверы зоны .ru не перенаправляют пакет на серверы ns1.ispvds.com, ns2.ispvds.com), это означает, что информация о домене либо еще не обновилась, либо появились какие-то проблемы при работе DNS-сервера.

Опросите конкретный DNS-сервер, обслуживающий ваш домен, командой

dig ispserver.ru ns1.ispvds.ru

How to Use Nslookup Windows Command (11 Examples)

Ошибка “Connection timed out”

How to Use Nslookup Windows Command (11 Examples)

Проверьте, доступен ли DNS-сервер и открыт ли на нем 53 порт.

Опросите первичный сервер имен командой

dig ispserver.ru <IP-адрес>

где IP-адрес - IP сервера, на котором расположен домен.

How to Use Nslookup Windows Command (11 Examples)

Решение основных проблем с DNS

Описание всех возникших проблем DNS-сервера читайте в лог-файле DNS, который по умолчанию находится по следующему пути: /var/log/messages. Расположение может быть изменено в зависимости от настроек вашего сервера. Через ISPmanager лог-файл можно просмотреть через “Менеджер файлов”.

How to Use Nslookup Windows Command (11 Examples)

Далее описаны наиболее часто возникающие проблемы DNS, которые можно обнаружить командой dig или в лог-файле.

Пустой ответ на команду dig

Под пустым ответом на команду dig понимается отсутствие секции ANSWER в выводе.

How to Use Nslookup Windows Command (11 Examples)

Как правило, причинами такого ответа могут быть:

  • не существует такого доменного имени;
  • домен не зарегистрирован на VPS;
  • не создана А-запись для домена.

Проверьте, зарегистрирован ли домен на сервере. Зайдите в ISPmanager в раздел “Сайты” и убедитесь, что в списке существует запись вашего доменного имени. В данном примере это isptest.com, которого в списке нет. Нажмите на кнопку “Создать сайт” и создайте новый сайт.

How to Use Nslookup Windows Command (11 Examples)

Если у вас нет панели управления ISPmanager, проверьте, есть ли файл зоны домена, вручную.

Удостоверьтесь, что на сервере для вашего домена корректно созданы А-записи. Зайдите в ISPmanager в раздел “Управление DNS”. Выделите домен и нажмите кнопку “Управлять DNS записями”.

How to Use Nslookup Windows Command (11 Examples)

How to Use Nslookup Windows Command (11 Examples)

Если вы не используете панель управления ISPmanager, выполните проверки вручную на сервере. Пример А-записи в конфигурационном файле named.conf:

ispserver.com.   IN      A       10.10.10.10

Ошибка “Permission denied”

Следующая запись лог-файле DNS означает, что были неправильно назначены права на файл зоны или владелец файла /etc/bind/ispsrv.com

Oct 12 15:23:50 ispsrv named[18761]: zone ispsrv.ru/IN: loading from master file /etc/bind/ispsrv.com failed: permission denied

Oct 12 15:23:50 ispsrv named[18761]: zone ispsrv.ru/IN: not loaded due to errors.

Удостоверьтесь, что служба bind запущена от имени того же пользователя, что и владелец файла ispsrv.com. Выполните команду

[root@dns ~]# ls -l /etc/bind/ispsrv.com -rw -r

Следующий результат этой команды говорит о том, что владельцем /etc/bind/ispsrv.com является суперпользователь root:

1 root root 444 Oct 12 16:00 /etc/bind/fvdstest.com

Также проверьте права на саму папку /etc/bind/ командой:

[root@dns ~]# ls -ld /etc/bind/ drwxr-sr-x

Следующий результат указывает на то, что директория доступна пользователям root и bind:

2 root bind 4096 Oct 12 16:07 /etc/bind

Ошибка “No address records (A or AAAA)”

Следующие строки в лог-файле DNS означают, что ресурсная А-запись отсутствует для дочернего NS:

Oct 12 15:23:50 ispsrv ds named[19931]: zone ispsrv.ru/IN: NS 'ns1.ispsrv.com' has no address records (A or AAAA)

Oct 12 15:23:50 ispsrv named[19931]: zone ispsrv.ru/IN: NS 'ns2.ispsrv.com' has no address records (A or AAAA)

Oct 12 15:23:50 ispsrv named[19931]: zone ispsrv.ru/IN: not loaded due to errors.

В данном случае для DNS-серверов ns1.ispsrv.com и ns2.ispsrv.com отсутствуют А-записи. Сделайте следующие записи в фале named.conf:

ns1     IN      A       10.10.10.10

ns2     IN      A       11.11.11.11

Ошибка “CNAME and other data”

Следующие строки в лог-файле DNS означают, что для одного домена прописаны одновременно А и CNAME ресурсные  записи:

Oct 12 16:13:30 ispsrv named[20701]: zone ispsrv.ru/IN: loading from master file /etc/bind/fvdstest.com failed: CNAME and other data

Oct 12 16:13:30 ispsrv named[20701]: zone ispsrv.ru/IN: not loaded due to errors.

Конфликт вызывает запись вида:

ispsrv.com.   IN      A       10.10.10.10

ispsrv.com.   IN      CNAME   isptest.com

Оставьте только одну необходимую запись.

Ошибка “Query denied”

Следующие строки в лог-файле DNS означают, что ваш запрос к DNS-серверу запрещен:

Oct 12 16:53:03 ispsrv named[03771]: client 188.120.234.14#49834: query ‘ispsrv.com/A/IN’ denied

А таком случае DNS-сервер возможно настроен так, что запросы к нему разрешены только от дочернего DNS (slave).

Ошибка “Transfer failed”

Oct 12 17:13:13 ispsrv named[83374]: client 188.126.231.143#50652: zone transfer ispsrv.com/AXFR/IN' denied

Команда dig указывает на эту ошибку следующим ответом:

; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> ispsrv.com @10.10.10.10 AXFR

;; global options: +cmd

; Transfer failed.

Ошибка в синтаксисе

Если вы случайно допустили синтаксическую ошибку в конфигурации файла доменной зоны, то в ответе на команду dig появятся не ожидаемые вами обозначения. Например,

;; QUESTION SECTION:

;<domain>.        IN    A

;; ANSWER SECTION:

<domain>.    3600    IN    A    123.123.123.123

;; AUTHORITY SECTION:

<domain>.    3600    IN    NS    ns2.ispsrv.ru.<domain>.

<domain>.    3600    IN    NS    ns1.ispsrv.ru.<domain>.

<domain> означает, что после ns1.ispsrv.ru не поставлена точка. Исправьте ошибку, поставив закрывающую точку: ns1.ispsrv.ru.

Аналоги nslookup

1) В качестве альтернативы командной строке, можно воспользоваться различными онлайн сервисами для выполнения запросов к DNS. Например, на 2whois.ru.

2) Для Linux можно воспользоваться утилитой dig, которая также предназначена для выполнения запросов к DNS.

3) На мобильных устройствах, например, под управлением Android есть свои утилиты для опроса DNS. Например, Ping & Net.

Дмитрий Моск — частный мастер

Была ли полезна вам эта инструкция?

Ввод команды и синтаксис

Для работы с утилитой необходимо открыть командную строку (cmd или powershell в Windows и unix-shell в UNIX). В системах на базе Windows утилита встроена, и мы можем работать с ней в любой момент. Для некоторых дистрибутивов Linux потребуется установка утилиты одной из команд:

yum install nslookup

apt-get install nslookup

* первая команда для систем на базе Red Hat, вторая — Debian.

Для выполнения запросов используем команду:

Самый простой пример использования команды:

Утилита также поддерживает работу в интерактивном режиме — вводим команду:

После можно делать запросы.

Why you must learn the Nslookup command line tool

When DNS is not working devices cannot communicate. You will be unable to browse websites, send an email, chat online, stream videos, and so on.

If you have a local DNS server issue then your employees can’t work and business is impacted.

You need a way to quickly troubleshoot and resolve these issues.

That is why it’s important to know how to use the Nslookup command.

This command is built into all Windows operating systems, it’s free and easy to use.

Примеры использования

1. Запрос записи ipv6 для домена mail.ru.

nslookup -type=AAAA mail.ru

б) интерактивный режим:

> set type=AAAA

2. Узнать NS серверы для домена google.com.

nslookup -type=NS google.com

б) интерактивный режим:

> set type=NS

3. Определить mx-записи для yandex.ru через DNS-сервер 8.8.8.8

Читайте также:  Vmware личный кабинет

nslookup -type=MX yandex.ru 8.8.8.8

б) интерактивный режим:

> set type=MX

б) интерактивный режим:

> set type=ptr

How DNS works

Understanding how DNS works will help you troubleshoot DNS issues faster. It will help you identify if it’s a client, a local DNS issue, or another DNS server (forwarding server or ISP).

Computer and other network devices communicate by IP address. It would be hard to remember the IP address of every website or resource you access, domain names are easier to remember. DNS will take the easy to remember name and map it to the IP address so devices can communicate.

Below I walk through how a computer uses DNS to resolve names.

  1. User types in google.com into their browser. This will send a query to the DNS server to go fetch the IP address for google.com
  2. The DNS server that the client uses may not know the IP address. This can be your local Active Directory DNS server or your ISP DNS server. If it doesn’t know the IP address of the domain it will forward it on to the next DNS server.
  3. The next DNS server says it knows the IP address and sends the request back to the computer.
  4. The computer is then able to communicate to google.com.
How to Use Nslookup Windows Command (11 Examples)

DNS uses resource records to provide details about systems on a network. The above example used an A resource record which maps a domain name to an IP address.

In the examples below I will show you how to query different resource records.

Опции nslookup

При выполнении запросов мы можем использовать следующие опции:

Также мы можем вызвать описание для nslookup.

а) в системах на базе Windows:

б) в Linux:

Использование опций

При вводе команды nslookup к опциям добавляем дефис, например:

nslookup -timeout=1 -type=MX dmosk.ru

Если мы работаем с nslookup в интерактивном режиме, то опции задаются с помощью команды set:

* первая команда задает опцию для выполнения подробных запросов. Вторая — делает запрос для домена dmosk.ru.

NSLookup Syntax

To view the syntax just type nslookup hit enter then type?

Here is a screenshot

How to Use Nslookup Windows Command (11 Examples)

There are a lot of options but in most cases, you will only need a few of them to verify DNS records. The most useful command switches are set type, server, and debug. I’ll show you the most commonly used commands below.

How to Use Nslookup to Check DNS Records

Below are several examples of how to use nslookup to check various DNS record types. By default, nslookup will use the local DNS server configured by your computer. See the last example to change Nslookup to use an external server.

Nslookup IP Address (IP to Domain Name)

nslookup 8.8.8.8

Use this command if you know the IP address and want to find the domain name. In the screenshot below the IP 8.8.8.8 resolves to the domain name dns.google.com

How to Use Nslookup Windows Command (11 Examples)

Nslookup domain name (Domain to IP Address)

nslookup domainname

If you want to find the IP address of a domain name then use this command. In this example, the domain name ad.activedirectorypro.com resolves to several IP addresses.

How to Use Nslookup Windows Command (11 Examples)

Nslookup MX record

nslookup -type=mx domainname
How to Use Nslookup Windows Command (11 Examples)

Nslookup SOA Record

nslookup -type=soa ad.activedirectorypro.com

The Start of Authority record indicates which DNS server is the best source of information for the domain. This will return the primary name server, responsible mail addresses, default ttl, and more.

How to Use Nslookup Windows Command (11 Examples)

Nslookup CNAME

nslookup -type=cname www.activedirectorypro.com

The CNAME record is used to alias or redirects one DNS name to another DNS name.

How to Use Nslookup Windows Command (11 Examples)

Nameserver lookup

nslookup -type=na ad.activedirectorypro.com

Use the above command to view the name servers for a domain. You can see below the name servers for my domain are dc1, dc2 and dc3.

How to Use Nslookup Windows Command (11 Examples)

Nslookup TXT record

nslookup -type=na domainname

Use this command to view text DNS records for a domain.

How to Use Nslookup Windows Command (11 Examples)

Nslookup all DNS records

nslookup -type=any ad.activedirectorypro.com

This command will display all available records.

How to Use Nslookup Windows Command (11 Examples)

Nslookup domain controller

Use these steps to list all domain controllers for a specific domain.

  1. From the command prompt type nslookup and press enter
  2. Then type set type=SRV and press enter
  3. Next, type _ldap._tcp.ad.activedirectorypro.com and press enter. (replace ad.activedirectorypro.com with your domain name).
How to Use Nslookup Windows Command (11 Examples)

This will display all domain controllers for the ad.activedirectorypro.com domain.

How to Use Nslookup Windows Command (11 Examples)

Nslookup Verbose

Turning on debug will display a lot more details about the resource record such as primary name server, mail address, default TTL, and much more. To turn on debug use the command below

nslookup 
set debug
How to Use Nslookup Windows Command (11 Examples)

Nslookup use External DNS server

This is very useful in troubleshooting. Maybe a website isn’t loading on your internal network but does when you are off the network. You can use this to see if your internal DNS is returning different results than an external DNS server. You can use your ISP DNS server or google.

To change the DNS server type nslookup and press “enter”.

Then type server IPADDRESS. For example “server 8.8.8.8” and press enter. This will instruct the nslookup command to use the 8.8.8.8 server to run DNS record lookups.

How to Use Nslookup Windows Command (11 Examples)

Summary

In this guide, I walked through several examples of how to use the nslookup windows command. The nslookup command is a great tool to troubleshoot and check DNS records. A lot of times network issues are related to DNS and knowing how to quickly verify DNS is working correctly can be a huge time saver.

Tips for troubleshooting DNS Problems

Here are my tips for troubleshooting DNS issues.

Step#1 Make sure you have connectivity to the DNS server?

If your client has communication issues with the DNS server then name resolution is not going to work.

To check what DNS is set on a Windows system use this command:

Now take the IP listed for the DNS server and see if the client can ping it or communicate with it.

Step #2 Are other users or devices having name resolution issues?

You need to determine how big of a problem you have. Is it just one, two, or many devices that have name resolution issues?

If it’s just one then you may just have a client issue. If it’s all or many then you may have an issue with the local or upstream DNS server.

Step #3 Use NSLookup to test local server

Use NSLookup to verify the local DNS server is working correctly. Use the command to verify DNS records on local servers. If you need examples see the previous section.

If you are having issues internally you will want to check the health of your Active Directory environment. Since DNS and AD are very tightly integrated a faulty domain controller could be causing your DNS issues. 
See my tutorial on how to check domain controller health.

Step #5 Use NSlookup server to test forwarding DNS Server (UPstream)

Step #6 Scan for viruses and spyware

Viruses and spyware can install all kinds of nasty things on computers to redirect traffic to malicious sites. Browser hijacking is very common

Step #7 Check the client’s host file

I don’t recommend adding entries to the host file but if it contains incorrect or outdated data, you won’t be able to connect. Viruses can also modify the host file which would redirect you to malicious websites.

Step #8 Flush DNS Cache

The client’s cache could be the problem to flush the cache run this command

I hope this article helped you understand the NSLookup and how it can be used to verify and troubleshoot DNS. If you liked this video or have questions leave a quick comment below.

Оцените статью
Хостинги