nslookup命令用法

nslookup命令用法


nslookup命令

nslookup命令的功能是查詢一臺機器的IP地址和其對應的域名。它通常需要一臺域名服務器來提供域名服務,如果用戶已經設置好域名服務器,就可以用這個命令查看不同主機的IP地址對應的域名。

該命令的一般格式爲:

nslookup [IP地址/域名]

[]在本地機上使用nslookup命令。

$ nslookup

Default Server: name.tlc.com.cn

Address: 192.168.1.99

>

在符號“>”後面輸入要查詢的IP地址或域名並回車即可;如果要退出該命令,輸入exit並回車即可。




nslookup命令用於查詢DNS的記錄,查看域名解析是否正常,在網絡故障的時候用來診斷網絡問題。nslookup的用法相對來說還是蠻簡單的,主要是下面的幾個用法。

1、直接查詢 ¶

這個可能大家用到最多,查詢一個域名的A記錄。

nslookup domain [dns-server]

如果沒指定dns-server,用系統默認的dns服務器。下面是一個例子:

C:/Users/jackie>nslookup www.ezloo.com 8.8.8.8 
Server: google-public-dns-a.google.com 
Address: 8.8.8.8

Non-authoritative answer: 
Name: www.ezloo.com 
Address: 70.32.68.136

 

2、查詢其他記錄 ¶

直接查詢返回的是A記錄,我們可以指定參數,查詢其他記錄,比如AAAA、MX等。

nslookup -qt=type domain [dns-server]

其中,type可以是以下這些類型:

A 地址記錄 
AAAA 地址記錄 
AFSDB Andrew文件系統數據庫服務器記錄 
ATMA ATM地址記錄 
CNAME 別名記錄 
HINFO 硬件配置記錄,包括CPU、操作系統信息 
ISDN 域名對應的ISDN號碼 
MB 存放指定郵箱的服務器 
MG 郵件組記錄 
MINFO 郵件組和郵箱的信息記錄 
MR 改名的郵箱記錄 
MX 郵件服務器記錄 
NS 名字服務器記錄 
PTR 反向記錄 
RP 負責人記錄 
RT 路由穿透記錄 
SRV TCP服務器信息記錄 
TXT 域名對應的文本信息 
X25 域名對應的X.25地址記錄

例如:

C:/Users/jackie>nslookup -qt=mx ezloo.com 8.8.8.8 
Server: google-public-dns-a.google.com 
Address: 8.8.8.8

Non-authoritative answer: 
ezloo.com MX preference = 10, mail exchanger = aspmx.l.google.com 
ezloo.com MX preference = 20, mail exchanger = alt1.aspmx.l.google.com 
ezloo.com MX preference = 30, mail exchanger = alt2.aspmx.l.google.com 
ezloo.com MX preference = 40, mail exchanger = aspmx2.googlemail.com 
ezloo.com MX preference = 50, mail exchanger = aspmx3.googlemail.com

3、查詢更具體的信息 ¶

查詢語法:

nslookup –d [其他參數] domain [dns-server]

只要在查詢的時候,加上-d參數,即可查詢域名的緩存。

C:/Users/jackie>nslookup -d www.ezloo.com 
------------ 
Got answer: 
HEADER: 
opcode = QUERY, id = 1, rcode = NOERROR 
header flags: response, want recursion, recursion avail. 
questions = 1, answers = 1, authority records = 2, additional = 2

QUESTIONS: 
196.134.191.60.in-addr.arpa, type = PTR, class = IN 
ANSWERS: 
-> 196.134.191.60.in-addr.arpa 
name = tzdns1.tzptt.zj.cn 
ttl = 11568 (3 hours 12 mins 48 secs) 
AUTHORITY RECORDS: 
-> 191.60.in-addr.arpa 
nameserver = dns-noc.zjhzptt.net.cn 
ttl = 11537 (3 hours 12 mins 17 secs) 
-> 191.60.in-addr.arpa 
nameserver = ns.zjnbptt.net.cn 
ttl = 11537 (3 hours 12 mins 17 secs) 
ADDITIONAL RECORDS: 
-> dns-noc.zjhzptt.net.cn 
internet address = 202.96.103.36 
ttl = 11522 (3 hours 12 mins 2 secs) 
-> ns.zjnbptt.net.cn 
internet address = 202.96.104.18 
ttl = 11522 (3 hours 12 mins 2 secs)

------------ 
Server: tzdns1.tzptt.zj.cn 
Address: 60.191.134.196

------------ 
Got answer: 
HEADER: 
opcode = QUERY, id = 2, rcode = NOERROR 
header flags: response, want recursion, recursion avail. 
questions = 1, answers = 1, authority records = 2, additional = 0

QUESTIONS: 
www.ezloo.com, type = A, class = IN 
ANSWERS: 
-> www.ezloo.com 
internet address = 70.32.68.136 
ttl = 2732 (45 mins 32 secs) 
AUTHORITY RECORDS: 
-> ezloo.com 
nameserver = ns61.domaincontrol.com 
ttl = 2365 (39 mins 25 secs) 
-> ezloo.com 
nameserver = ns62.domaincontrol.com 
ttl = 2365 (39 mins 25 secs)

------------ 
Non-authoritative answer: 
------------ 
Got answer: 
HEADER: 
opcode = QUERY, id = 3, rcode = NOERROR 
header flags: response, want recursion, recursion avail. 
questions = 1, answers = 0, authority records = 1, additional = 0

QUESTIONS: 
www.ezloo.com, type = AAAA, class = IN 
AUTHORITY RECORDS: 
-> ezloo.com 
ttl = 10800 (3 hours) 
primary name server = ns61.domaincontrol.com 
responsible mail addr = dns.jomax.net 
serial = 2011032900 
refresh = 28800 (8 hours) 
retry = 7200 (2 hours) 
expire = 604800 (7 days) 
default TTL = 86400 (1 day)

------------ 
Name: www.ezloo.com 
Address: 70.32.68.136

發佈了132 篇原創文章 · 獲贊 17 · 訪問量 18萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章