使用 NSlookup.exe

轉貼http://support.microsoft.com/default.aspx/kb/200525/zh-cn

 

概要

Nslookup.exe 是命令行管理工具,用於測試或解決 DNS 服務器問題。此工具是通過“控制面板”與 TCP/IP 協議一起安裝的。本文包含使用 Nslo...

<script type="text/javascript"></script>

Nslookup.exe 是命令行管理工具,用於測試或解決 DNS 服務器問題。此工具是通過“控制面板”與 TCP/IP 協議一起安裝的。本文包含使用 Nslookup.exe 的若干提示。

更多信息

要使用 Nslookup.exe,請注意以下方面: TCP/IP 協議必須安裝在運行 Nslookup.exe 的計算機上。 在 Microsoft TCP/I...

<script type="text/javascript"></script>

要使用 Nslookup.exe,請注意以下方面:
  • TCP/IP 協議必須安裝在運行 Nslookup.exe 的計算機上。
  • Microsoft TCP/IP 屬性頁的 DNS 選項卡的“DNS 服務搜索順序”字段中必須至少指定一個 DNS 服務器。
  • Nslookup 一直從當前上下文中的名稱中抽去後綴。如果無法進行完全合格的名稱查詢(即,使用尾隨點),那麼查詢將被附加到當前上下文中。例如,當前 DNS 設置是 att.com,並且在 www.microsoft.com 中執行查詢,那麼第一個查詢將作爲 www.microsoft.com.att.com 而失敗,因爲查詢是不合格的。這種方式與其他供應商的 Nslookup 方式可能不一致,本文的目的在於闡明 Microsoft Windows NT Nslookup.exe 的處理方式。
  • 如果已經使用 Microsoft TCP/IP 屬性DNS 選項卡上定義的“域後綴搜索順序”(Domain Suffix Search Order )中的搜索列表,將不會發生抽取操作。查詢將被附加到列表中指定的域後綴中。要避免使用搜索列表,請始終使用“完全合格的域名稱”(即,在名稱中添加尾隨點)。

Nslookup.exe 可以在兩種模式下運行:交互式和非交互式。當需要返回單塊數據時,請使用非交互式模式。非交互模式的語法如下:

   nslookup [-option] [hostname] [server]

要在交互模式下啓動 Nslookup.exe,只需在命令提示符下輸入 nslookup:

   C:/> nslookup
   Default Server:  nameserver1.domain.com
   Address:  10.0.0.1
   >

在命令提示符下輸入 help 或 ? 將生成可用的命令列表。在命令提示符下輸入的任何內容,如果它不是有效命令,則假設它是主機名,嘗試使用默認服務器來解析它。要中斷交互命令,請按 CTRL+C。要退出交互模式並返回到命令提示符下,並在命令提示符下輸入 exit

以下是幫助輸出,其中包含選項的完整列表:

Commands:   (identifiers are shown in uppercase, [] means optional)

 NAME            - print info about the host/domain NAME using default 
                   server
 NAME1 NAME2     - as above, but use NAME2 as server
 help or ?       - print info on common commands
 set OPTION      - set an option

    all                 - print options, current server and host
    [no]debug           - print debugging information
    [no]d2              - print exhaustive debugging information
    [no]defname         - append domain name to each query
    [no]recurse         - ask for recursive answer to query
    [no]search          - use domain search list
    [no]vc              - always use a virtual circuit
    domain=NAME         - set default domain name to NAME
    srchlist=N1[/N2/.../N6] - set domain to N1 and search list to N1, N2, 
                          and so on
    root=NAME           - set root server to NAME
    retry=X             - set number of retries to X
    timeout=X           - set initial time-out interval to X seconds
    type=X              - set query type (for example, A, ANY, CNAME, MX, 
                          NS, PTR, SOA, SRV)
    querytype=X         - same as type
    class=X             - set query class (for example, IN (Internet), ANY)
    [no]msxfr           - use MS fast zone transfer
    ixfrver=X           - current version to use in IXFR transfer request

 server NAME     - set default server to NAME, using current default server
 lserver NAME    - set default server to NAME, using initial server
 finger [USER]   - finger the optional NAME at the current default host
 root            - set current default server to the root
 ls [opt] DOMAIN [> FILE] - list addresses in DOMAIN (optional: output to 
                  FILE)

    -a          -  list canonical names and aliases
    -d          -  list all records
    -t TYPE     -  list records of the given type (for example, A, CNAME, 
                   MX, NS, PTR, and so on)

 view FILE       - sort an 'ls' output file and view it with pg
 exit            - exit the program

通過在命令提示符下運行 set 命令,可以在 Nslookup.exe 中設置許多不同的選項。要得到這些選項的完整列表,只需輸入 set all。請參見以上內容,在 set 命令下,得到可用選項的打印輸出。


查找不同的數據類型

<script type="text/javascript"></script>

要在域名空間中查找不同的數據類型,請在命令提示符下使用 set typeset q[uerytype] 命令。例如,要查詢郵件交換器數據,請輸入:
   C:/> nslookup
   Default Server:  ns1.domain.com
   Address:  10.0.0.1

   > set q=mx
   > mailhost
   Server:  ns1.domain.com
   Address:  10.0.0.1

   mailhost.domain.com     MX preference = 0, mail exchanger =
                           mailhost.domain.com
   mailhost.domain.com     internet address = 10.0.0.5
   >

第一次查詢是查找遠程名稱,答案是權威的,但隨後的查詢是非權威的。第一次查詢遠程主機時,本地 DNS 服務器與作爲該域權威的 DNS 服務器取得聯繫。然後,本地 DNS 服務器緩存該信息,以便從本地服務器緩存中非權威地回答隨後的查詢。


直接從另一個名稱服務器中進行查詢

<script type="text/javascript"></script>

要直接查詢另一個名稱服務器,請使用 serverlserver 命令切換到該名稱服務器。lserver 命令使用本地服務器得到要切換的服務器地址,而 server 命令使用當前默認服務器得到該地址。

例如:
   C:/> nslookup

   Default Server:  nameserver1.domain.com
   Address:  10.0.0.1

   > server 10.0.0.2

   Default Server:  nameserver2.domain.com
   Address:  10.0.0.2
   >

使用 Nslookup.exe 轉移整個區域

<script type="text/javascript"></script>

使用 ls 命令,Nslookup 可以用於轉移整個區域。查看遠程域中的所有主機,這是有用的。ls 命令的語法如下:

   ls [- a | d | t type] domain [> filename]

不帶參數使用 ls 命令將返回所有地址和名稱服務器數據的列表。-a 參數將返回別名和正式名稱,-d 將返回所有數據,而 -t 將按類型進行篩選。

例如:

   >ls domain.com
   [nameserver1.domain.com]
    nameserver1.domain.com.    NS     server = ns1.domain.com
    nameserver2.domain.com                 NS     server = ns2.domain.com
    nameserver1                            A      10.0.0.1
    nameserver2                            A      10.0.0.2

   >

在 DNS 服務器中可以按塊轉移區域,以便只有授權的地址和網絡纔可以執行此操作。如果設置了區域安全,將返回以下錯誤消息:
*** Can't list domain example.com .: Query refused

有關其它信息,請參見以下 Microsoft Knowledge Base 文章:
193837  (http://support.microsoft.com/kb/193837/EN-US/ ) Windows NT 4.0 DNS 服務器默認區域安全設置

Nslookup.exe 的疑難解答

<script type="text/javascript"></script>

默認服務器超時

<script type="text/javascript"></script>

當啓動 Nslookup.exe 工具時,以下錯誤可能出現:
*** Can't find server name for address w.x.y.z : Timed out

備註w.x.y.z 是在“DNS 服務搜索順序”列表中列出的第一個 DNS 服務器。

*** Can't find server name for address 127.0.0.1: Timed out

第一個錯誤指出不能連接 DNS 服務器,或者該計算機上的服務沒有運行。要解決此問題,啓動該服務器上的 DNS 服務,或檢查可能存在的連接問題。

第二個錯誤指出在“DNS 服務搜索順序”列表中還沒有定義服務器。要解決此問題,請將有效 DNS 服務器的 IP 地址添加到此列表中。

有關其它信息,請參見以下 Microsoft Knowledge Base 文章:
172060  (http://support.microsoft.com/kb/172060/EN-US/ ) NSLOOKUP:找不到地址 127.0.0.1 的服務器名

啓動 Nslookup.exe 時找不到服務器名

<script type="text/javascript"></script>

啓動 Nslookup.exe 工具時,可能出現以下錯誤:

*** Can't find server name for address w.x.y.z: Non-existent domain


當沒有名稱服務器 IP 地址的 PTR 記錄時,會出現此錯誤。當 Nslookup.exe 啓動時,它執行反向搜索,以得到默認服務器的名稱。如果沒有 PTR 數據,則返回此錯誤消息。要解決此問題,請確保反向搜索區域存在,幷包含名稱服務器的 PTR 記錄。

有關其它信息,請參見以下 Microsoft Knowledge Base 文章:
172953  (http://support.microsoft.com/kb/172953/EN-US/ ) 如何安裝和配置 Microsoft DNS Server

Nslookup 在子域上無法執行

<script type="text/javascript"></script>

當在子域上執行查詢或進行區域轉移時,Nslookup 可能返回以下錯誤:

*** ns.domain.com can't find child.domain.com.: Non-existent domain
*** Can't list domain child.domain.com.: Non-existent domain


在 DNS Manager 中,可以在主區域下添加一個新域,這樣就創建了一個子域。用這種方法創建子域並不爲該域創建一個單獨的 db 文件,這樣在該域進行查詢或在該域進行區域轉移時將會產生以上錯誤。在父域上進行區域轉移時將同時列出父域數據和子域數據。要解決此問題,請在 DNS 服務器上爲該子域創建一個新主域。

這篇文章中的信息適用於:
  • Microsoft Windows NT Server 4.0 Standard Edition
  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章