作者:zhanhailiang 日期:2014-11-01

1. host

  1. host提供域名到IP地址的双向解析;
  2. host默认通过/etc/resolv.conf读取Name Server来解析,除非提供可选參数server。
  3. -a參数相当于进行ANY查询。
[root@~]# host pic1.vip.com
pic1.vip.com is an alias for pic1.vip.com.wscdns.com.
pic1.vip.com.wscdns.com is an alias for vipshop.xdwscache.glb0.lxdns.com.
vipshop.xdwscache.glb0.lxdns.com has address 111.206.217.105
vipshop.xdwscache.glb0.lxdns.com has address 125.39.1.138
vipshop.xdwscache.glb0.lxdns.com has address 218.59.186.76
vipshop.xdwscache.glb0.lxdns.com has address 111.206.169.23
[root@~]# host pic1.vip.com 8.8.8.8
Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:
 
pic1.vip.com is an alias for pic1.vip.com.wscdns.com.
pic1.vip.com.wscdns.com is an alias for vipshop.xdwscache.glb0.lxdns.com.
vipshop.xdwscache.glb0.lxdns.com has address 125.39.1.138
vipshop.xdwscache.glb0.lxdns.com has address 111.206.169.23
vipshop.xdwscache.glb0.lxdns.com has address 111.206.217.105
vipshop.xdwscache.glb0.lxdns.com has address 218.59.186.76
[root@~]# host -a pic1.vip.com 8.8.8.8
Trying "pic1.vip.com"
Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:
 
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39471
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
 
;; QUESTION SECTION:
;pic1.vip.com. IN ANY
 
;; ANSWER SECTION:
pic1.vip.com. 3975 IN CNAME pic1.vip.com.wscdns.com.
 
Received 64 bytes from 8.8.8.8#53 in 412 ms

2. nslookup

  1. nslookup提供交互式和非交互式两种查询方式;
[root@~]# nslookup
> pic1.vip.com
Server: 10.202.72.116
Address: 10.202.72.116#53
 
Non-authoritative answer:
pic1.vip.com canonical name = pic1.vip.com.wscdns.com.
pic1.vip.com.wscdns.com canonical name = vipshop.xdwscache.glb0.lxdns.com.
Name: vipshop.xdwscache.glb0.lxdns.com
Address: 125.39.1.138
Name: vipshop.xdwscache.glb0.lxdns.com
Address: 218.59.186.76
Name: vipshop.xdwscache.glb0.lxdns.com
Address: 111.206.169.23
Name: vipshop.xdwscache.glb0.lxdns.com
Address: 111.206.217.105
> exit
 
[root@~]# nslookup pic1.vip.com
Server: 10.202.72.116
Address: 10.202.72.116#53
 
Non-authoritative answer:
pic1.vip.com canonical name = pic1.vip.com.wscdns.com.
pic1.vip.com.wscdns.com canonical name = vipshop.xdwscache.glb0.lxdns.com.
Name: vipshop.xdwscache.glb0.lxdns.com
Address: 111.206.217.105
Name: vipshop.xdwscache.glb0.lxdns.com
Address: 125.39.1.138
Name: vipshop.xdwscache.glb0.lxdns.com
Address: 218.59.186.76
Name: vipshop.xdwscache.glb0.lxdns.com
Address: 111.206.169.23

3. dig

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYmlsbGZlbGxlcg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

  1. dig是一个询问DNS域名服务的灵活工具,提供了来自被要求的,返回名称服务DNS的查询和显示的答案。大多数DNS管理员使用dig来排除DNS故障和问题;
  2. 其基本用法:dig [@server] name [type]。

1. 普通使用方法:dig pic1.vip.com

[root@~]# dig pic1.vip.com
 
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> pic1.vip.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 65138
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 5, ADDITIONAL: 5
 
;; QUESTION SECTION:
;pic1.vip.com. IN A
 
;; ANSWER SECTION:
pic1.vip.com. 4518 IN CNAME pic1.vip.com.wscdns.com.
pic1.vip.com.wscdns.com. 28 IN CNAME vipshop.xdwscache.glb0.lxdns.com.
vipshop.xdwscache.glb0.lxdns.com. 120 IN A 218.59.186.76
vipshop.xdwscache.glb0.lxdns.com. 120 IN A 111.206.169.23
vipshop.xdwscache.glb0.lxdns.com. 120 IN A 111.206.217.105
vipshop.xdwscache.glb0.lxdns.com. 120 IN A 125.39.1.138
 
;; AUTHORITY SECTION:
xdwscache.glb0.lxdns.com. 162890 IN NS ns1.glb0.lxdns.com.
xdwscache.glb0.lxdns.com. 162890 IN NS ns4.glb0.lxdns.com.
xdwscache.glb0.lxdns.com. 162890 IN NS ns3.glb0.lxdns.com.
xdwscache.glb0.lxdns.com. 162890 IN NS ns5.glb0.lxdns.com.
xdwscache.glb0.lxdns.com. 162890 IN NS ns2.glb0.lxdns.com.
 
;; ADDITIONAL SECTION:
ns1.glb0.lxdns.com. 400 IN A 218.60.106.128
ns2.glb0.lxdns.com. 400 IN A 111.206.217.82
ns3.glb0.lxdns.com. 400 IN A 101.227.66.164
ns4.glb0.lxdns.com. 400 IN A 111.206.217.82
ns5.glb0.lxdns.com. 400 IN A 222.132.5.102
 
;; Query time: 21 msec
;; SERVER: 10.202.72.116#53(10.202.72.116)
;; WHEN: Sat Nov 1 00:42:27 2014
;; MSG SIZE rcvd: 341

2. 进行ANY查询:

[root@~]# dig vip.com ANY
 
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> vip.com ANY
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59219
;; flags: qr rd ra; QUERY: 1, ANSWER: 7, AUTHORITY: 2, ADDITIONAL: 2
 
;; QUESTION SECTION:
;vip.com. IN ANY
 
;; ANSWER SECTION:
vip.com. 171039 IN NS ns7.vipshop.com.
vip.com. 171039 IN NS ns8.vipshop.com.
vip.com. 4451 IN A 183.61.89.84
vip.com. 4451 IN A 183.61.89.20
vip.com. 4451 IN TXT "v=spf1 ip4:122.11.55.162 ip4:180.186.22.7 ip4:122.11.55.163 ip4:210.21.83.149 ip4:210.21.83.150 ip4:183.61.189.204 ip4:121.11.65.219 ip4:61.155.128.141 include:easeye-edm.com a mx ~all"
vip.com. 4451 IN MX 1 mail.vip.com.
vip.com. 4451 IN SOA ns7.vip.com. it.vip.com. 2014103116 1800 600 604800 1200
 
;; AUTHORITY SECTION:
vip.com. 171039 IN NS ns8.vipshop.com.
vip.com. 171039 IN NS ns7.vipshop.com.
 
;; ADDITIONAL SECTION:
ns7.vipshop.com. 13022 IN A 14.17.85.62
ns8.vipshop.com. 13022 IN A 183.61.89.62
 
;; Query time: 0 msec
;; SERVER: 10.202.72.116#53(10.202.72.116)
;; WHEN: Sat Nov 1 00:42:41 2014
;; MSG SIZE rcvd: 425

3. 使用+trace參数,追踪查询过程:

[root@~]# dig pic1.vip.com +trace
 
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> pic1.vip.com +trace
;; global options: +cmd
. 483723 IN NS e.root-servers.net.
. 483723 IN NS g.root-servers.net.
. 483723 IN NS m.root-servers.net.
. 483723 IN NS a.root-servers.net.
. 483723 IN NS b.root-servers.net.
. 483723 IN NS c.root-servers.net.
. 483723 IN NS i.root-servers.net.
. 483723 IN NS f.root-servers.net.
. 483723 IN NS j.root-servers.net.
. 483723 IN NS k.root-servers.net.
. 483723 IN NS l.root-servers.net.
. 483723 IN NS h.root-servers.net.
. 483723 IN NS d.root-servers.net.
;; Received 496 bytes from 10.202.72.116#53(10.202.72.116) in 1 ms
 
com. 172800 IN NS a.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.
com. 172800 IN NS c.gtld-servers.net.
com. 172800 IN NS d.gtld-servers.net.
com. 172800 IN NS e.gtld-servers.net.
com. 172800 IN NS f.gtld-servers.net.
com. 172800 IN NS g.gtld-servers.net.
com. 172800 IN NS h.gtld-servers.net.
com. 172800 IN NS i.gtld-servers.net.
com. 172800 IN NS j.gtld-servers.net.
com. 172800 IN NS k.gtld-servers.net.
com. 172800 IN NS l.gtld-servers.net.
com. 172800 IN NS m.gtld-servers.net.
;; Received 490 bytes from 199.7.83.42#53(199.7.83.42) in 27 ms
 
vip.com. 172800 IN NS ns7.vipshop.com.
vip.com. 172800 IN NS ns8.vipshop.com.
;; Received 106 bytes from 192.43.172.30#53(192.43.172.30) in 291 ms
 
pic1.vip.com. 7200 IN CNAME pic1.vip.com.wscdns.com.
;; Received 64 bytes from 183.61.89.62#53(183.61.89.62) in 37 ms

4. 指定name server,使用+trace參数,能够看到第一步是通过指定的@server查询根服务器:

[root@~]# dig @8.8.8.8 pic1.vip.com +trace
 
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> @8.8.8.8 pic1.vip.com +trace
; (1 server found)
;; global options: +cmd
. 18601 IN NS a.root-servers.net.
. 18601 IN NS b.root-servers.net.
. 18601 IN NS c.root-servers.net.
. 18601 IN NS d.root-servers.net.
. 18601 IN NS e.root-servers.net.
. 18601 IN NS f.root-servers.net.
. 18601 IN NS g.root-servers.net.
. 18601 IN NS h.root-servers.net.
. 18601 IN NS i.root-servers.net.
. 18601 IN NS j.root-servers.net.
. 18601 IN NS k.root-servers.net.
. 18601 IN NS l.root-servers.net.
. 18601 IN NS m.root-servers.net.
;; Received 228 bytes from 8.8.8.8#53(8.8.8.8) in 301 ms
 
com. 172800 IN NS m.gtld-servers.net.
com. 172800 IN NS l.gtld-servers.net.
com. 172800 IN NS k.gtld-servers.net.
com. 172800 IN NS j.gtld-servers.net.
com. 172800 IN NS i.gtld-servers.net.
com. 172800 IN NS h.gtld-servers.net.
com. 172800 IN NS g.gtld-servers.net.
com. 172800 IN NS f.gtld-servers.net.
com. 172800 IN NS e.gtld-servers.net.
com. 172800 IN NS d.gtld-servers.net.
com. 172800 IN NS c.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.
com. 172800 IN NS a.gtld-servers.net.
;; Received 490 bytes from 198.41.0.4#53(198.41.0.4) in 130 ms
 
vip.com. 172800 IN NS ns7.vipshop.com.
vip.com. 172800 IN NS ns8.vipshop.com.
;; Received 106 bytes from 192.55.83.30#53(192.55.83.30) in 90 ms
 
pic1.vip.com. 7200 IN CNAME pic1.vip.com.wscdns.com.
;; Received 64 bytes from 14.17.85.62#53(14.17.85.62) in 30 ms

因为篇幅有限。想知道很多其它的关于host, nslookup。dig参数和应用场景的命令,请问man手册及相关文章。

版权声明:本文博客原创文章。博客,未经同意,不得转载。

DNS查询工具:host、nslookup、dig的更多相关文章

  1. 域名DNS解析工具ping/nslookup/dig/host

    常见 DNS 记录的类型 类型 目的 A 地址记录,用来指定域名的 IPv4 地址,如果需要将域名指向一个 IP 地址,就需要添加 A 记录. AAAA 用来指定主机名(或域名)对应的 IPv6 地址 ...

  2. DNS正、反解析查询指令host、dig、nslookup

    一.host指令格式:host [-a] FQDN [server] host -l domain [server]选项:-a :代表列出该主机所有的相关信息,包括 IP.TTL 与除错讯息等等-l ...

  3. 基于nodejs的DNS查询工具

    开始这个实例之前,我们简单谈一下Node.js吧,Node.js是一个由JavaScript书写而成的强大Web开发框架,它让开发强壮的.伸缩性良好的服务器端Web应用变得更加简单.容易.这种技术诞生 ...

  4. host, nslookup, dig、whois

    一.host命令:DNS 查找使用程序 选项与参数: -a :代表列出该主机所有的相关信息,包括 IP.TTL 与除错讯息等等 -l :若后面接的那个 domain 设定允许 allow-transf ...

  5. host,nslookup,dig 工具安装

    DNS-测试工具 在centos7.9 中 安装bind后发现缺少,检测工具 工具包安装: 1 [root@server]# yum install -y bind-utils 安装后再次查询,发现已 ...

  6. DNS查询指令host

    描述: Host指令提供一个简单的DNS解析的功能.正常地使用名称到IP的解析,当指令没有任何参数和选项的时候,它将输出简单的带命令行参数和选项的概要. 名称是可以被解析的域名,也可以是点分十进制的I ...

  7. DNS查询相关

    本文同时发表在https://github.com/zhangyachen/zhangyachen.github.io/issues/45 一种简单的设计方式是在因特网上使用一个DNS服务器,该服务器 ...

  8. Linux基础命令---host域名查询工具

    host host是一个常用的DNS查询工具,经常用来查询域名.检查域名解析是否正确. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.Fedora.   1.语法       ...

  9. centos DNS服务搭建 DNS原理 使用bind搭建DNS服务器 配置DNS转发 配置主从 安装dig工具 DHCP dhclient 各种域名解析记录 mydns DNS动态更新 第三十节课

    centos  DNS服务搭建  DNS原理  使用bind搭建DNS服务器 配置DNS转发 配置主从  安装dig工具  DHCP  dhclient  各种域名解析记录  mydns DNS动态更 ...

随机推荐

  1. C++项目參考解答:累加求圆周率

    [项目-累加求圆周率] 用例如以下公式求π的近似值(计算直到最后一项的绝对值小于10−5) π4=1−13+15−17+... [參考解答] #include <iostream> usi ...

  2. jboss-as-7.1.1.Final与jdk1.8不兼容解决方案

    今天在安装1.8电脑上装了jboss7.1.1,配置好了运行的时候就是无法启动,最后得出答案是:jboss-as-7.1.1.Final与jdk1.8不兼容 1.如果你的电脑安装了jdk1.8,那么在 ...

  3. 安装使用jupyter(原来的notebook)

    1.安装pyzmq 使用pip install pyzmq,安装不成功. 使用easy_install.exe pyzmq.成功安装. 2.安装tornado pip tornado 安装完尚不成功. ...

  4. iOS开发runtime学习:一:runtime简介与runtime的消息机制

    一:runtime简介:也是面试必须会回答的部分 二:runtime的消息机制 #import "ViewController.h" #import <objc/messag ...

  5. C++实践參考——二进制文件浏览器

    [项目-二进制文件浏览器] (1)做一个相似BinaryViewer的查看二进制文件的程序.输入文件名称后,能够以16进制和ASCII对比的方式列出该文件的内容.能够參考下图: 提示:循环中,一次读入 ...

  6. 使用Opencv中matchTemplate模板匹配方法跟踪移动目标

    模板匹配是一种在图像中定位目标的方法,通过把输入图像在实际图像上逐像素点滑动,计算特征相似性,以此来判断当前滑块图像所在位置是目标图像的概率. 在Opencv中,模板匹配定义了6种相似性对比方式: C ...

  7. Android多线程研究(5)——线程之间共享数据

    一.如果是每个线程都执行相同的代码,则可以使用同一个Runnable来实现共享 public class MultiThreadShareData { public static void main( ...

  8. php解析xml字符串

    <?php $content = <<<XML <?xml version="1.0" encoding="UTF-8"?> ...

  9. 无线物联网中CoAP协议的研究与实现【转】

    无线物联网中CoAP协议的研究与实现 时间:2013-04-09 来源:电子科技 作者:汤春明,张 荧,吴宇平 关键字:CoAP   无线   物联网   协议 摘要:由于物联网中的很多设备都是资源受 ...

  10. (三)Unity5.0新特性------动画的StateMachineBehaviours

    出处:http://blog.csdn.net/u010019717 author:孙广东      时间:2015.3.31 (State machine behaviours)状态机的行为在Ani ...