windows及linux底下好用的查詢dns指令

使用google dns來查詢dns

C:\Users\tonyhack>nslookup
預設伺服器:  dns.hinet.net
Address:  168.95.1.1

> server 8.8.8.8
預設伺服器:  google-public-dns-a.google.com
Address:  8.8.8.8

>

查詢A指向

C:\Users\tonyhack>nslookup www.mobile01.com
伺服器:  dns.hinet.net
Address:  168.95.1.1

未經授權的回答:
名稱:    www.mobile01.com
Address:  202.39.235.195

或是設定type=a來查詢

> www.seednet.com.tw
伺服器:  dns.hinet.net
Address:  168.95.1.1

DNS request timed out.
    timeout was 2 seconds.
未經授權的回答:
名稱:    www.seednet.com.tw
Addresses:  199.59.243.105
          199.59.243.106
          199.59.243.107
          199.59.243.108
          199.59.243.109

查詢IPv6 A指向

> set type=aaaa
> www.google.com.tw
Server:		8.8.8.8
Address:	8.8.8.8#53

Non-authoritative answer:
www.google.com.tw	has AAAA address 2404:6800:4008:c00::5e

查詢CNAME

> set type=cname
> www.youtube.com.tw
伺服器:  dns.hinet.net
Address:  168.95.1.1

未經授權的回答:
www.youtube.com.tw      canonical name = youtube-ui.l.google.com
>

查詢MX指向

> set type=mx
> hinet.net
伺服器: dns.hinet.net
Address: 168.95.1.1

未經授權的回答:
hinet.net MX preference = 10, mail exchanger = netnews.hinet.net

查詢NS指向

> set type=ns
> yahoo.com
伺服器:  dns.hinet.net
Address:  168.95.1.1

未經授權的回答:
yahoo.com       nameserver = ns5.yahoo.com
yahoo.com       nameserver = ns3.yahoo.com
yahoo.com       nameserver = ns2.yahoo.com
yahoo.com       nameserver = ns4.yahoo.com
yahoo.com       nameserver = ns8.yahoo.com
yahoo.com       nameserver = ns6.yahoo.com
yahoo.com       nameserver = ns1.yahoo.com
>

如果要查詢該域名底下全部的話,有些如果有特別設定的域名會查不出來

> set type=any
> google.com
伺服器: dns.hinet.net
Address: 168.95.1.1

未經授權的回答:
google.com MX preference = 40, mail exchanger = alt3.aspmx.l.google.com
google.com MX preference = 50, mail exchanger = alt4.aspmx.l.google.com
google.com MX preference = 10, mail exchanger = aspmx.l.google.com
google.com MX preference = 20, mail exchanger = alt1.aspmx.l.google.com
google.com MX preference = 30, mail exchanger = alt2.aspmx.l.google.com
google.com AAAA IPv6 address = 2404:6800:4008:c02::66
google.com internet address = 74.125.23.102
google.com internet address = 74.125.23.113
google.com internet address = 74.125.23.138
google.com internet address = 74.125.23.139
google.com internet address = 74.125.23.100
google.com internet address = 74.125.23.101
google.com nameserver = ns1.google.com
google.com nameserver = ns3.google.com
google.com nameserver = ns4.google.com
google.com nameserver = ns2.google.com

更進階的指令可以在nslookup底下按?即會列出可使用的指令

> ?
命令:   (識別元會以大寫字元顯示,[] 表示選用)
NAME            - 列印使用預設伺服器之主機/網域 NAME 的資訊
NAME1 NAME2     - 與上述相同,但使用 NAME2 做為伺服器
help 或 ?       - 列印常用命令的資訊
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         - 與 type 相同
    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            - 結束程式

清除本機dns快取

C:\Users\tony\ipconfig /flushdns

Windows IP 設定

成功清除 DNS 解讀器快取。

By tony

自由軟體愛好者~喜歡不斷的思考各種問題,有新的事物都會想去學習嘗試 做實驗並熱衷研究 沒有所謂頂天的技術 只有謙虛及不斷的學習 精進專業,本站主要以分享系統及網路相關知識、資源而建立。 Github http://stnet253.github.io

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料