免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1605 | 回复: 0
打印 上一主题 下一主题

dig 命令的基本用法 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-02 11:20 |只看该作者 |倒序浏览
本文来自:
IT运维专家网(LinuxTone.Org)
作者:
NetSeek
原文链接:
http://bbs.linuxtone.org/thread-956-1-1.html
IT运维专家网--"自由平等,互助分享!"
在 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
来源:
http://www.chinaunix.net
作者:阿骁
dig最基本的用法
>dig sina.com.cn                    //查询A记录
;; QUESTION SECTION:
;sina.com.cn.                   IN      A
;; ANSWER SECTION:
sina.com.cn.            37      IN      A       202.108.33.32
>dig sina.com.cn ns                //查询NS记录
;; QUESTION SECTION:
;sina.com.cn.                   IN      NS
;; ANSWER SECTION:
sina.com.cn.            21478   IN      NS      ns2.sina.com.cn.
sina.com.cn.            21478   IN      NS      ns3.sina.com.cn.
sina.com.cn.            21478   IN      NS      ns1.sina.com.cn.
>dig sina.com.cn soa             //查询SOA记录
;; QUESTION SECTION:
;sina.com.cn.                   IN      SOA
;; ANSWER SECTION:
sina.com.cn.            600     IN      SOA     ns1.sina.com.cn. senjin.staff.sina.com.cn. 5 1800 600 604801 600
另外,还可以
dig @Server sina.com.cn.   //在Server服务器上查询
sina.com.cn
的记录,比如
>dig @210.51.191.22 sina.com.cn
;; QUESTION SECTION:
;sina.com.cn.                   IN      A
;; AUTHORITY SECTION:
sina.com.cn.            21600   IN      NS      ns1.sina.com.cn.
sina.com.cn.            21600   IN      NS      ns2.sina.com.cn.
sina.com.cn.            21600   IN      NS      ns3.sina.com.cn.
;; ADDITIONAL SECTION:
ns1.sina.com.cn.        21600   IN      A       202.106.184.166
ns2.sina.com.cn.        21600   IN      A       61.172.201.254
ns3.sina.com.cn.        21600   IN      A       202.108.44.55
# 查找一个域的授权 dns 服务器
dig sina.com.cn. +nssearch
SOA ns1.sina.com.cn. senjin.staff.sina.com.cn. 5 1800 600 604801 600 from server  ns1.sina.com.cn in 31 ms.
SOA ns1.sina.com.cn. senjin.staff.sina.com.cn. 5 1800 600 604801 600 from server  ns3.sina.com.cn in 31 ms.
SOA ns1.sina.com.cn. senjin.staff.sina.com.cn. 5 1800 600 604801 600 from server  ns2.sina.com.cn in 46 ms.
# 从根服务器开始追踪一个域名的解析过程
>dig news.sina.com.cn +trace
;; global options:  printcmd
.                       518138  IN      NS      A.ROOT-SERVERS.NET.
.                       518138  IN      NS      B.ROOT-SERVERS.NET.
.                       518138  IN      NS      C.ROOT-SERVERS.NET.
.                       518138  IN      NS      D.ROOT-SERVERS.NET.
.                       518138  IN      NS      E.ROOT-SERVERS.NET.
.                       518138  IN      NS      F.ROOT-SERVERS.NET.
.                       518138  IN      NS      G.ROOT-SERVERS.NET.
.                       518138  IN      NS      H.ROOT-SERVERS.NET.
.                       518138  IN      NS      I.ROOT-SERVERS.NET.
.                       518138  IN      NS      J.ROOT-SERVERS.NET.
.                       518138  IN      NS      K.ROOT-SERVERS.NET.
.                       518138  IN      NS      L.ROOT-SERVERS.NET.
.                       518138  IN      NS      M.ROOT-SERVERS.NET.
;; Received 228 bytes from 192.168.1.1#53(192.168.1.1) in 15 ms
cn.                     172800  IN      NS      C.DNS.cn.
cn.                     172800  IN      NS      D.DNS.cn.
cn.                     172800  IN      NS      E.DNS.cn.
cn.                     172800  IN      NS      NS.CERNET.NET.
cn.                     172800  IN      NS      A.DNS.cn.
cn.                     172800  IN      NS      B.DNS.cn.
;; Received 297 bytes from 198.41.0.4#53(A.ROOT-SERVERS.NET) in 281 ms
sina.com.cn.            21600   IN      NS      ns3.sina.com.cn.
sina.com.cn.            21600   IN      NS      ns1.sina.com.cn.
sina.com.cn.            21600   IN      NS      ns2.sina.com.cn.
;; Received 136 bytes from 203.119.29.1#53(E.DNS.cn) in 171 ms
news.sina.com.cn.       60      IN      CNAME   jupiter.sina.com.cn.
jupiter.sina.com.cn.    60      IN      CNAME   hydra.sina.com.cn.
hydra.sina.com.cn.      60      IN      A       218.30.108.61
hydra.sina.com.cn.      60      IN      A       218.30.108.62
hydra.sina.com.cn.      60      IN      A       218.30.108.63
hydra.sina.com.cn.      60      IN      A       218.30.108.64
hydra.sina.com.cn.      60      IN      A       218.30.108.65
hydra.sina.com.cn.      60      IN      A       218.30.108.66
hydra.sina.com.cn.      60      IN      A       218.30.108.67
hydra.sina.com.cn.      60      IN      A       218.30.108.68
hydra.sina.com.cn.      60      IN      A       218.30.108.69
hydra.sina.com.cn.      60      IN      A       218.30.108.72
hydra.sina.com.cn.      60      IN      A       218.30.108.73
hydra.sina.com.cn.      60      IN      A       218.30.108.74
hydra.sina.com.cn.      60      IN      A       218.30.108.55
hydra.sina.com.cn.      60      IN      A       218.30.108.56
hydra.sina.com.cn.      60      IN      A       218.30.108.57
hydra.sina.com.cn.      60      IN      A       218.30.108.58
sina.com.cn.            86400   IN      NS      ns1.sina.com.cn.
sina.com.cn.            86400   IN      NS      ns2.sina.com.cn.
sina.com.cn.            86400   IN      NS      ns3.sina.com.cn.
;; Received 434 bytes from 202.106.184.166#53(ns1.sina.com.cn) in 31 ms
从上面的记录,我们可以看到整个的流程,从根服务器查询到cn的根服务器,然后查询到sina.com.cn的名字服务器,
news.sina.com.cn -> jupiter.sina.com.cn -->hydra.sina.com.cn  最后得到hydra的服务器IP。

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/38871/showart_2084437.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP