分享
 
 
 

dig 命令的基本用法

王朝厨房·作者佚名  2007-01-02
窄屏简体版  字體: |||超大  

:em17:

在 unix 和 linux 下,建议大家使用 dig 命令来代替 nslookup。 dig 命令的功能比 nslookup 强大很多,不像 nslookkup 还得 set 来 set 去的,怪麻烦的。下面是 dig 的一些比较常用的命令:

# dig 最基本的用法

dig @server sina.com.cn.

# 用 dig 查看 zone 数据传输

dig @server zx.xmgd.com. AXFR

# 用 dig 查看 zone 数据的增量传输

dig @server zx.xmgd.com. IXFR=N

# 用 dig 查看反向解析

dig -x 210.52.83.228 @server

# 查找一个域的授权 dns 服务器

dig xmgd.com. +nssearch

# 从根服务器开始追踪一个域名的解析过程

dig xmgd.com +trace

# 查看你使用的是哪个 F root dns server

dig +norec @F.ROOT-SERVERS.NET HOSTNAME.BIND CHAOS TXT

yfhe 回复于:2003-12-24 09:32:09

很好,有没有更详细一点的(偶有点贪心啊,呵呵 :D ) :shock:

cuiy 回复于:2003-12-24 09:48:28

不错

阿骁 回复于:2003-12-24 09:52:59

[quote:a33b405944="yfhe"]很好,有没有更详细一点的(偶有点贪心啊,呵呵 :D ) :shock:[/quote:a33b405944]

:em04:

这些都是平常会经常用到的,再详细的查查 man 手册吧! 呵呵。。。。

supereyes 回复于:2003-12-24 22:46:26

希望大家能将dig的常用用法和解决、分析dns状况的好参数写在这个帖子。我也会的~

chenbohero 回复于:2004-10-25 22:48:02

可惜啊!!我不是用的unix啊

阿骁 回复于:2004-10-26 08:37:02

[quote:8a7c5e0a94="chenbohero"]可惜啊!!我不是用的unix啊[/quote:8a7c5e0a94]

你可以到 www.isc.org 去下载一个 bind for windows 的版本安装,安装后就可以在 windows 上使用 dig 命令了。^O^

idcpanda 回复于:2004-10-27 12:12:31

[quote:e6c50b5fb4="阿骁"]

你可以到 www.isc.org 去下载一个 bind for windows 的版本安装,安装后就可以在 windows 上使用 dig 命令了。^O^[/quote:e6c50b5fb4]

在上面没有找到:)请帮助一下

阿骁 回复于:2004-10-27 12:13:32

ftp://ftp.isc.org/isc/bind/contrib/ntbind-9.3.0/BIND9.3.0.zip

可观 回复于:2004-11-03 12:26:23

3Q

wingger 回复于:2004-11-03 14:49:04

^-^在win下可以用dig了

rkit 回复于:2004-11-06 19:09:33

[quote:7cdba99212="wingger"]^-^在win下可以用dig了[/quote:7cdba99212]

用呢?

wingger 回复于:2004-11-06 20:29:08

[quote:37032802ea="rkit"]

用呢?[/quote:37032802ea]

什么意思???

idcpanda 回复于:2004-11-10 12:23:14

xths

mantou 回复于:2004-11-30 09:37:52

很大的疑问,加入用了这些命令, 出现什么样的信息才是正确的,

比如dig -x 210.52.83.228 @server

该出现什么信息??

仅仅说命令,我们还是一知半解

bst 回复于:2004-12-28 12:39:55

为方便查找我就把man dig 放在这了..

The dig Manual Page

This page contains the manual page for the UNIX shell comand "dig" for your reference. Note that this is taken straight from the man page on my system, your system might be running a different version or not have this command enabled at all.

DIG(1) DIG(1)

NAME

dig - send domain name query packets to name servers

SYNOPSIS

dig [@server] domain [] []

[+] [-] [%comment]

DESCRIPTION

Dig (domain information groper) is a flexible command line

tool which can be used to gather information from the

Domain Name System servers. Dig has two modes: simple

interactive mode which makes a single query, and batch

which executes a query for each in a list of several query

lines. All query options are accessible from the command

line.

The usual simple use of dig will take the form:

dig @server domain query-type query-class

where:

server may be either a domain name or a dot-notation

Internet address. If this optional field is omit-

ted, dig will attempt to use the default name

server for your machine.

Note: If a domain name is specified, this will be

resolved using the domain name system resolver

(i.e., BIND). If your system does not support DNS,

you may have to specify a dot-notation address.

Alternatively, if there is a server at your dis-

posal somewhere, all that is required is that

/etc/resolv.conf be present and indicate where the

default name servers reside, so that server

itself can be resolved. See resolver(5) for infor-

mation on /etc/resolv.conf. (WARNING: Changing

/etc/resolv.conf will affect the standard resolver

library and potentially several programs which use

it.) As an option, the user may set the environment

variable LOCALRES to name a file which is to be

used instead of /etc/resolv.conf (LOCALRES is spe-

cific to the dig resolver and not referenced by

the standard resolver). If the LOCALRES variable is

not set or the file is not readable then

/etc/resolv.conf will be used.

domain is the domain name for which you are requesting

information. See OPTIONS [-x] for convenient way

to specify inverse address query.

query-type

is the type of information (DNS query type) that

you are requesting. If omitted, the default is "a"

(T_A = address). The following types are recog-

nized:

a T_A network address

any T_ANY all/any information about specified domain

mx T_MX mail exchanger for the domain

ns T_NS name servers

soa T_SOA zone of authority record

hinfo T_HINFO host information

axfr T_AXFR zone transfer

(must ask an authoritative server)

txt T_TXT arbitrary number of strings

(See RFC 1035 for the complete list.)

query-class

is the network class requested in the query. If

omitted, the default is "in" (C_IN = Internet).

The following classes are recognized:

in C_IN Internet class domain

any C_ANY all/any class information

(See RFC 1035 for the complete list.)

Note: "Any" can be used to specify a class and/or a

type of query. Dig will parse the first occurrence

of "any" to mean query-type = T_ANY. To specify

query-class = C_ANY you must either specify "any"

twice, or set query-class using "-c" option (see

below).

OTHER OPTIONS

%ignored-comment

"%" is used to included an argument that is simply

not parsed. This may be useful if running dig in

batch mode. Instead of resolving every @server-

domain-name in a list of queries, you can avoid the

overhead of doing so, and still have the domain

name on the command line as a reference. Example:

dig @128.9.0.32 %venera.isi.edu mx

isi.edu

-<DIG option>

"-" is used to specify an option which effects the

operation of dig. The following options are cur-

rently available (although not guaranteed to be

useful):

-x dot-notation-address

Convenient form to specify inverse address

mapping. Instead of "dig 32.0.9.128.in-

addr.arpa" one can simply "dig -x

128.9.0.32".

-f file

File for dig batch mode. The file contains a

list of query specifications (dig command

lines) which are to be executed succes-

sively. Lines beginning with ';', '#', or

'\n' are ignored. Other options may still

appear on command line, and will be in

effect for each batch query.

-T time

Time in seconds between start of successive

queries when running in batch mode. Can be

used to keep two or more batch dig commands

running roughly in sync. Default is zero.

-p port

Port number. Query a name server listening

to a non-standard port number. Default is

53.

-P[ping-string]

After query returns, execute a ping(8) com-

mand for response time comparison. This

rather unelegantly makes a call to the

shell. The last three lines of statistics is

printed for the command:

ping -s server_name 56 3

If the optional "ping string" is present, it

replaces "ping -s" in the shell command.

-t query-type

Specify type of query. May specify either an

integer value to be included in the type

field or use the abbreviated mnemonic as

discussed above (i.e., mx = T_MX).

-c query-class

Specify class of query. May specify either

an integer value to be included in the class

field or use the abbreviated mnemonic as

discussed above (i.e., in = C_IN).

-envsav

This flag specifies that the dig environment

(defaults, print options, etc.), after all

of the arguments are parsed, should be saved

to a file to become the default environment.

Useful if you do not like the standard set

of defaults and do not desire to include a

large number of options each time dig is

used. The environment consists of resolver

state variable flags, timeout, and retries

as well as the flags detailing dig output

(see below). If the shell environment vari-

able LOCALDEF is set to the name of a file,

this is where the default dig environment is

saved. If not, the file "DiG.env" is created

in the current working directory.

Note: LOCALDEF is specific to the dig

resolver, and will not affect operation of

the standard resolver library.

Each time dig is executed, it looks for

"./DiG.env" or the file specified by the

shell environment variable LOCALDEF. If such

file exists and is readable, then the envi-

ronment is restored from this file before

any arguments are parsed.

-envset

This flag only affects batch query runs.

When "-envset" is specified on a line in a

dig batch file, the dig environment after

the arguments are parsed, becomes the

default environment for the duration of the

batch file, or until the next line which

specifies "-envset".

-[no]stick

This flag only affects batch query runs. It

specifies that the dig environment (as read

initially or set by "-envset" switch) is to

be restored before each query (line) in a

dig batch file. The default "-nostick"

means that the dig environment does not

stick, hence options specified on a single

line in a dig batch file will remain in

effect for subsequent lines (i.e. they are

not restored to the "sticky" default).

+<QUERY option>

"+" is used to specify an option to be changed in

the query packet or to change dig output specifics.

Many of these are the same parameters accepted by

nslookup(8). If an option requires a parameter,

the form is as follows:

+keyword[=value]

Most keywords can be abbreviated. Parsing of the

"+" options is very simplistic -- a value must

not be separated from its keyword by white space.

The following keywords are currently available:

Keyword Abbrev. Meaning [default]

[no]debug (deb) turn on/off debugging mode [deb]

[no]d2 turn on/off extra debugging mode [nod2]

[no]recurse (rec) use/don't use recursive lookup [rec]

retry=# (ret) set number of retries to # [4]

time=# (ti) set timeout length to # seconds [4]

[no]ko keep open option (implies vc) [noko]

[no]vc use/don't use virtual circuit [novc]

[no]defname (def) use/don't use default domain name [def]

[no]search (sea) use/don't use domain search list [sea]

domain=NAME (do) set default domain name to NAME

[no]ignore (i) ignore/don't ignore trunc. errors [noi]

[no]primary (pr) use/don't use primary server [nopr]

[no]aaonly (aa) authoritative query only flag [noaa]

[no]sort (sor) sort resource records [nosor]

[no]cmd echo parsed arguments [cmd]

[no]stats (st) print query statistics [st]

[no]Header (H) print basic header [H]

[no]header (he) print header flags [he]

[no]ttlid (tt) print TTLs [tt]

[no]cl print class info [nocl]

[no]qr print outgoing query [noqr]

[no]reply (rep) print reply [rep]

[no]ques (qu) print question section [qu]

[no]answer (an) print answer section [an]

[no]author (au) print authoritative section [au]

[no]addit (ad) print additional section [ad]

pfdef set to default print flags

pfmin set to minimal default print flags

pfset=# set print flags to #

(# can be hex/octal/decimal)

pfand=# bitwise and print flags with #

pfor=# bitwise or print flags with #

The retry and time options affect the retransmis-

sion strategy used by resolver library when sending

datagram queries. The algorithm is as follows:

for i = 0 to retry - 1

for j = 1 to num_servers

send_query

wait((time * (2**i)) / num_servers)

end

end

(Note: dig always uses a value of 1 for

num_servers.)

DETAILS

Dig once required a slightly modified version of the BIND

resolver(3) library. BIND's resolver has (as of BIND 4.9)

been augmented to work properly with Dig. Essentially,

Dig is a straight-forward (albeit not pretty) effort of

parsing arguments and setting appropriate parameters. Dig

uses resolver routines res_init(), res_mkquery(),

res_send() as well as accessing _res structure.

FILES

/etc/resolv.conf initial domain name and name server

addresses

ENVIRONMENT

LOCALRES file to use in place of /etc/resolv.conf

LOCALDEF default environment file

AUTHOR

Steve Hotz hotz@isi.edu

ACKNOWLEDGMENTS

Dig uses functions from nslookup(8) authored by Andrew

Cherenson.

BUGS

Dig has a serious case of "creeping featurism" -- the

result of considering several potential uses during it's

development. It would probably benefit from a rigorous

diet. Similarly, the print flags and granularity of the

items they specify make evident their rather ad hoc gene-

sis.

Dig does not consistently exit nicely (with appropriate

status) when a problem occurs somewhere in the resolver

(NOTE: most of the common exit cases are handled). This

is particularly annoying when running in batch mode. If

it exits abnormally (and is not caught), the entire batch

aborts; when such an event is trapped, dig simply contin-

ues with the next query.

SEE ALSO

named(|8), resolver(3), resolver(5), nslookup(8)

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有