先前曾经简单介绍过在CentOS5.2下搭建实现DNS服务器,可查看这里
现在就再简单大致记录介绍三款常用于检查测试调试DNS服务器搭建是否成功的工具吧~即Dig、Host、Nslookup,介绍:
Shell方式可以使用3种工具来查询DNS数据库:nslookup、dig和host,在BIND的软件发布中包括nslookup和dig。
Nslookup是这三个工具中最老的,而且总是随同BIND一起发布;dig是域信息的探索程序,最初由SteveHotz编写,后来
MichaelSawy针对BIND 9将它重新编写,它也和BIND一起发布;host由Eric
Wassenaar编写,是另一个开放源代码的工具,其特点是输出对用户很友好,功能是可检查区文件的语法。另外三者使用的解析器库不同:dig和
host使用BIND的解析器,而nslookup有其自身的解析器。
(1)、Dig命令
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} [...]]
以上是关于dig用法参数列表,可以通过man dig 或者 dig –h | more 查看其命令相应的帮助信息~ 参数可接IP
address或domain name来获得name server所提供的相关讯息,提供不同资料记录型态,例如A、MX…等等
(2)、Host命令
[root@yanqx ~]$ host -h
host: illegal option — h
Usage: host [-aCdlriTwv] [-c class] [-N ndots] [-t type] [-W time]
[-R number] hostname [server]
-a is equivalent to -v -t *
-c specifies query class for non-IN data
-C compares SOA records on authoritative nameservers
-d is equivalent to -v
-l lists all hosts in a domain, using AXFR
-i IP6.INT reverse lookups
-N changes the number of dots allowed before root lookup is done
-r disables recursive processing
-R specifies number of retries for UDP packets
-t specifies the query type
-T enables TCP/IP mode
-v enables verbose output
-w specifies to wait forever for a reply
-W specifies how long to wait for a reply
-4 use IPv4 query transport only
-6 use IPv6 query transport only
默认情况下,只是简单使用host+欲查询域名得到只是简单一些A记录或MX记录等,想了解全部信息需加上 –a 参数查看 如:
[root@yanqx ~]$ host qingxianyan.cn
qingxianyan.cn has address 74.220.219.76
qingxianyan.cn mail is handled by 0 qingxianyan.cn.
(3)、Nslookup命令
在linux或win下输
入nslookup命令后,会看到 > 提示符号,之后就可输入查询指令。一般会输入IP address或是domain
name来做反向及正向的解析。而nslookup不仅提供上述2种解析,亦像dig提供DNS中其它的资料记录型态,例如A、MX、NS…等等,可在提
示符号直接输入”?”来获得所有可以使用的参数或资料型态。
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, etc.
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 (ex. A,ANY,CNAME,MX,NS,PTR,SOA,SRV)
querytype=X – same as type
class=X – set query class (ex. 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 (e.g. A,CNAME,MX,NS,PTR etc.)
view FILE – sort an ‘ls’ output file and view it with pg
exit – exit the program
参考资料:http://docsrv.sco.com/NET_tcpip/dnsC.nslook.html
