nslookup 命令
nslookup这个名字的意思是:"name server lookup".
这个命令行工具是内置在的命令行工具, windows和unix上都有. 能允许用户查询网络中的域IP地址, 或主机的IP地址.
首先需要理解到NSLOOKUP会假设你正在查询在私有网络上的本地域. 你可以查询external 的domain, 但是NSLOOKUP会先在内部域查询.
nslookup 有下面的子命令:
- server NAME (这里的NAME是查询的DNS服务器的服务器名或者IP地址). 查询DNS服务器并不总是可以的, 因为经常对DNS的查询会为防止拒绝服务式攻击而被阻止掉.
- set type=NAME (这里的NAME是要查询的记录的类型). 比如说, set type mx会给出mail records.
使用方法:
C:\Users\yunzhang>nslookup ?
Usage:
nslookup [-opt ...] # interactive mode using default server
nslookup [-opt ...] - server # interactive mode using 'server'
nslookup [-opt ...] host # just look up 'host' using default server
nslookup [-opt ...] host server # just look up 'host' using 'server'
这个命令行工具在排查DNS协议的错误的时候非常有用, 一般你会先使用Ping命令, 看看网络是否通畅. 之后, nslookup就排的上用场了.
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
|
||||||||||||||||||||||||||||||||||
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)
|
||||||||||||||||||||||||||||||||||
view FILE | sort an 'ls' output file and view it with pg | ||||||||||||||||||||||||||||||||||
exit | exit the program |
输出结果解释
==============
命令运行结果如下
C:\Documents and Settings\Administrator.YUNZHANG>nslookup 190043m5
Server: engx86win2k8.contoso.local //使用的DNS Server的名字
Address: 192.168.1.1
Name: 190043m5.contoso.lab //解析server name的结果
Address: 192.168.1.5
摘自:
http://en.wikipedia.org/wiki/Nslookup
Microsoft DOS nslookup command
http://www.computerhope.com/nslookup.htm
Using NSLOOKUP for DNS Server diagnosis
http://www.windowsnetworking.com/articles_tutorials/Using-NSLOOKUP-DNS-Server-diagnosis.html#
view FILE - sort an 'ls' output file and view it with more
exit - exit the program, ^D also exits
>^D
Interactive/Noninteractive (交谈式/非交谈式)
执行 nslookup 时可以直接在后面跟着我们要查询的资料, 那幺 nslookup 会直接把结果传回来
如果只打入 nslookup [enter], 则进入交谈模式, 出现提示符号 >, 此时 nslookup 会等待 user input command.
tung@traveler:~> nslookup www.yohoo.com
Server: sun4.ee.ncku.edu.tw
Address: 140.116.72.14
Non-authoritative answer:
Name: yohoo.com
Address: 216.116.98.143
Aliases: www.yohoo.com
tung@traveler:~> nslookup
Default Server: sun4.ee.ncku.edu.tw
Address: 140.116.72.14
> www.yohoo.com 特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系
Server: sun4.ee.ncku.edu.tw
Address: 140.116.72.14
Non-authoritative answer:
Name: yohoo.com
Address: 216.116.98.143
Aliases: www.yohoo.com
Authoritative/Non-Authoritative
在查询时有时会出现 Non-authoritative answer, 代表这个答案是由 local DNS 的 cache 中直接读出来的, 而不是 local DNS 向真正负责这个 domain 的 name server 问来的.
常用的一些 option/command
1. set all
可以得知目前 nslookup 的一些 default 设定值
tung@traveler:~> nslookup
Default Server: sun4.ee.ncku.edu.tw
Address: 140.116.72.14
> set all
Default Server: sun4.ee.ncku.edu.tw
Address: 140.116.72.14
Set options:
nodebug defname search recurse
nod2 novc noignoretc port=53 ..
querytype=A class=IN timeout=5 retry=4
root=a.root-servers.net.
domain=ee.ncku.edu.tw
srchlist=ee.ncku.edu.tw
2. server dns_server_ip
表示将内定的 local DNS 换成另一部 server
Ex: server 140.116.2.6
3. set type=any
表示在查询某个 domain name 时, 将和这个 domain name 的一些相关资料一并显示出来
> set type=any
> www.yohoo.com
Server: sun4.ee.ncku.edu.tw
Address: 140.116.72.14
Non-authoritative answer:
www.yohoo.com canonical name = yohoo.com
Authoritative answers can be found from:
yohoo.com nameserver = ns1.netgateway.net
版权申明:本站文章均来自网络,如有侵权,请联系028-86262244-215 ,我们收到后立即删除,谢谢!