nslookup與dig


在進行DNS撥測時,我們常用的命令為nslookup和dig工具進行撥測

nslookup

是windows上默認自帶的DNS撥測工具

nslookup domain-name server-address

當沒有指定server-address時,nslookup工具會讀系統網絡配置的TCP/IP屬性中配置的DNS服務器的地址。 

具體的使用方法可在windows的cmd命令行中輸入nslookup回車,然后輸入help獲得幫助信息。

> help
命令:   (標識符以大寫表示,[] 表示可選)
NAME            - 打印有關使用默認服務器的主機/域 NAME 的信息
NAME1 NAME2     - 同上,但將 NAME2 用作服務器
help or ?       - 打印有關常用命令的信息
set OPTION      - 設置選項
    all                 - 打印選項、當前服務器和主機
    [no]debug           - 打印調試信息
    [no]d2              - 打印詳細的調試信息
    [no]defname         - 將域名附加到每個查詢
    [no]recurse         - 詢問查詢的遞歸應答
    [no]search          - 使用域搜索列表
    [no]vc              - 始終使用虛擬電路
    domain=NAME         - 將默認域名設置為 NAME
    srchlist=N1[/N2/.../N6] - 將域設置為 N1,並將搜索列表設置為 N1、N2 等
    root=NAME           - 將根服務器設置為 NAME
    retry=X             - 將重試次數設置為 X
    timeout=X           - 將初始超時間隔設置為 X 秒
    type=X              - 設置查詢類型(如 A、AAAA、A+AAAA、ANY、CNAME、MX、
                          NS、PTR、SOA 和 SRV)
    querytype=X         - 與類型相同
    class="X"             - 設置查詢類(如 IN (Internet)和 ANY)
    [no]msxfr           - 使用 MS 快速區域傳送
    ixfrver=X           - 用於 IXFR 傳送請求的當前版本
server NAME     - 將默認服務器設置為 NAME,使用當前默認服務器
lserver NAME    - 將默認服務器設置為 NAME,使用初始服務器
root            - 將當前默認服務器設置為根服務器
ls [opt] DOMAIN [> FILE] - 列出 DOMAIN 中的地址(可選: 輸出到文件 FILE)
    -a          -  列出規范名稱和別名
    -d          -  列出所有記錄
    -t TYPE     -  列出給定 RFC 記錄類型(例如 A、CNAME、MX、NS 和 PTR 等)
                   的記錄
view FILE           - 對 'ls' 輸出文件排序,並使用 pg 查看
exit            - 退出程序

 

dig

是Linux默認自帶的DNS撥測工具

dig @server-address domain-name

當沒有指定server-address時,dig工具會到系統的/etc/resolv.conf中讀取系統配置的DNS服務器地址。

具體的使用方法可在Linux的命令行輸入dig -h獲得幫助信息。

# dig -h
Usage:  dig [@global-server] [domain] [q-type] [q-class] {q-opt}
            {global-d-opt} host [@local-server] {local-d-opt}
            [ host [@local-server] {local-d-opt} [...]]
Where:  domain    is in the Domain Name System
        q-class  is one of (in,hs,ch,...) [default: in]
        q-type   is one of (a,any,mx,ns,soa,hinfo,axfr,txt,...) [default:a]
                 (Use ixfr=version for type ixfr)
        q-opt    is one of:
                 -x dot-notation     (shortcut for reverse lookups)
                 -i                  (use IP6.INT for IPv6 reverse lookups)
                 -f filename         (batch mode)
                 -b address[#port]   (bind to source address/port)
                 -p port             (specify port number)
                 -q name             (specify query name)
                 -t type             (specify query type)
                 -c class            (specify query class)
                 -k keyfile          (specify tsig key file)
                 -y [hmac:]name:key  (specify named base64 tsig key)
                 -4                  (use IPv4 query transport only)
                 -6                  (use IPv6 query transport only)
                 -m                  (enable memory usage debugging)
        d-opt    is of the form +keyword[=value], where keyword is:
                 +[no]vc             (TCP mode)
                 +[no]tcp            (TCP mode, alternate syntax)
                 +time=###           (Set query timeout) [5]
                 +tries=###          (Set number of UDP attempts) [3]
                 +retry=###          (Set number of UDP retries) [2]
                 +domain=###         (Set default domainname)
                 +bufsize=###        (Set EDNS0 Max UDP packet size)
                 +ndots=###          (Set NDOTS value)
                 +edns=###           (Set EDNS version)
                 +[no]search         (Set whether to use searchlist)
                 +[no]showsearch     (Search with intermediate results)
                 +[no]defname        (Ditto)
                 +[no]recurse        (Recursive mode)
                 +[no]ignore         (Don't revert to TCP for TC responses.)
                 +[no]fail           (Don't try next server on SERVFAIL)
                 +[no]besteffort     (Try to parse even illegal messages)
                 +[no]aaonly         (Set AA flag in query (+[no]aaflag))
                 +[no]adflag         (Set AD flag in query)
                 +[no]cdflag         (Set CD flag in query)
                 +[no]cl             (Control display of class in records)
                 +[no]cmd            (Control display of command line)
                 +[no]comments       (Control display of comment lines)
                 +[no]question       (Control display of question)
                 +[no]answer         (Control display of answer)
                 +[no]authority      (Control display of authority)
                 +[no]additional     (Control display of additional)
                 +[no]stats          (Control display of statistics)
                 +[no]short          (Disable everything except short
                                      form of answer)
                 +[no]ttlid          (Control display of ttls in records)
                 +[no]all            (Set or clear all display flags)
                 +[no]qr             (Print question before sending)
                 +[no]nssearch       (Search all authoritative nameservers)
                 +[no]identify       (ID responders in short answers)
                 +[no]trace          (Trace delegation down from root)
                 +[no]dnssec         (Request DNSSEC records)
                 +[no]nsid           (Request Name Server ID)
                 +[no]sigchase       (Chase DNSSEC signatures)
                 +trusted-key=####   (Trusted Key when chasing DNSSEC sigs)
                 +[no]topdown        (Do DNSSEC validation top down mode)
                 +[no]multiline      (Print records in an expanded format)
                 +[no]onesoa         (AXFR prints only one soa record)
        global d-opts and servers (before host name) affect all queries.
        local d-opts and servers (after host name) affect only that lookup.
        -h                           (print help and exit)
        -v                           (print version and exit)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM