DNS查询工具:host、nslookup、dig
作者:zhanhailiang 日期:2014-11-01
1. host
- host提供域名到IP地址的双向解析;
- host默认通过/etc/resolv.conf读取Name Server来解析,除非提供可选參数server。
- -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
- 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="">
- dig是一个询问DNS域名服务的灵活工具,提供了来自被要求的,返回名称服务DNS的查询和显示的答案。大多数DNS管理员使用dig来排除DNS故障和问题;
- 其基本用法: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的更多相关文章
- 域名DNS解析工具ping/nslookup/dig/host
常见 DNS 记录的类型 类型 目的 A 地址记录,用来指定域名的 IPv4 地址,如果需要将域名指向一个 IP 地址,就需要添加 A 记录. AAAA 用来指定主机名(或域名)对应的 IPv6 地址 ...
- DNS正、反解析查询指令host、dig、nslookup
一.host指令格式:host [-a] FQDN [server] host -l domain [server]选项:-a :代表列出该主机所有的相关信息,包括 IP.TTL 与除错讯息等等-l ...
- 基于nodejs的DNS查询工具
开始这个实例之前,我们简单谈一下Node.js吧,Node.js是一个由JavaScript书写而成的强大Web开发框架,它让开发强壮的.伸缩性良好的服务器端Web应用变得更加简单.容易.这种技术诞生 ...
- host, nslookup, dig、whois
一.host命令:DNS 查找使用程序 选项与参数: -a :代表列出该主机所有的相关信息,包括 IP.TTL 与除错讯息等等 -l :若后面接的那个 domain 设定允许 allow-transf ...
- host,nslookup,dig 工具安装
DNS-测试工具 在centos7.9 中 安装bind后发现缺少,检测工具 工具包安装: 1 [root@server]# yum install -y bind-utils 安装后再次查询,发现已 ...
- DNS查询指令host
描述: Host指令提供一个简单的DNS解析的功能.正常地使用名称到IP的解析,当指令没有任何参数和选项的时候,它将输出简单的带命令行参数和选项的概要. 名称是可以被解析的域名,也可以是点分十进制的I ...
- DNS查询相关
本文同时发表在https://github.com/zhangyachen/zhangyachen.github.io/issues/45 一种简单的设计方式是在因特网上使用一个DNS服务器,该服务器 ...
- Linux基础命令---host域名查询工具
host host是一个常用的DNS查询工具,经常用来查询域名.检查域名解析是否正确. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.Fedora. 1.语法 ...
- centos DNS服务搭建 DNS原理 使用bind搭建DNS服务器 配置DNS转发 配置主从 安装dig工具 DHCP dhclient 各种域名解析记录 mydns DNS动态更新 第三十节课
centos DNS服务搭建 DNS原理 使用bind搭建DNS服务器 配置DNS转发 配置主从 安装dig工具 DHCP dhclient 各种域名解析记录 mydns DNS动态更 ...
随机推荐
- [Javascript Natural] Break up language strings into parts using Natural
A part of Natural Language Processing (NLP) is processing text by “tokenizing” language strings. Thi ...
- 亿格瑞A5-hdmi故障了
http://cn.egreatworld.com/store/product/egreat-a5-4k-uhd-hdr-blu-ray-navigation-hdd-media-player/ a5 ...
- 2020发布 .NET 5 下一代全平台 .Net 框架
[翻译] 正式宣布 .NET 5 2019-05-07 01:18 by Rwing, 16515 阅读, 79 评论, 收藏, 编辑 原文: Introducing .NET 5 今天,我们宣布 . ...
- POJ2112 Optimal Milking 【最大流+二分】
Optimal Milking Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 12482 Accepted: 4508 ...
- Android自定义控件View(一)
虽然Android API给我们提供了众多控件View来使用,但是鉴于Android的开发性,自然少不了根据需求自定义控件View了.比如说QQ头像是圆形的,但是纵观整个Android控件也找不到一个 ...
- tomcat 去除端口和项目名/使用域名访问/修改超链接为IP地址
1.打开tomcat/conf/server.xml 在host标签中加入 <Context docBase="项目名" path="" reloada ...
- ACCESS通过一个连接写入的数据,还有一个连接却读取不出来
近期在用c#实现一个数据导入的功能,将一个ACCESS数据库中的数据导入到还有一个ACCESS的数据库中,然后显示出来,可是导入成功了.却显示不出来. 经过研究认为应该是缓存的原因,因为我写入数据和读 ...
- NOIP模拟 table - 矩阵链表
题目大意: 给一个n*m的矩阵,每次交换两个大小相同的不重叠的子矩阵,输出最后的矩阵 题目分析: 这题向我们展示了出神入化的链表是如何炼成的.思想都懂,实现是真的需要技术,%%% 用一副链表来表示该矩 ...
- WPF入门(三)->几何图形之线条(LineGeometry)
原文:WPF入门(三)->几何图形之线条(LineGeometry) 前一章我们对wpf的xaml语言有了一定的了解,那么我们现在开始来学习如何使用wpf来画出几何图形. LineGeometr ...
- Eclipse Che开发Spring Web应用(入门) (二)
在上篇博客中我们介绍了如何安装Eclipse Che这种浏览器SDK之后,收到了许多开发者的提问,为了方便初学者开发Java web应用,笔者又一步步实践了spring web开发(demo)过程,欢 ...