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动态更 ...
随机推荐
- Android Widget和悬浮窗 原理
1.简单介绍 Android widget是桌面插件,在android系统应用开发层面有特殊用途. AppWidget是把一个进程的控件嵌入到别外一个进程的窗口里的一种方法.悬浮窗的效果与Widget ...
- ExtJS中store.findExact
var ds = myGrid.apf_ds; var store = myGrid.getStore(); forEach(data, function (item) { if (store.fin ...
- [转载]Ocelot简易教程(二)之快速开始2
为什么这篇的标题叫“Ocelot简易教程(二)之快速开始2”呢,因为很多朋友跟我说上一篇“ Ocelot简易教程(二)之快速开始1”内容太少了,只是简单介绍Ocelot的一些简单配置,让Ocelot能 ...
- USB 3.0规范中译本 第10章 集线器,主机下行口以及设备上行口规范
本文为CoryXie原创译文,转载及有任何问题请联系cory.xie#gmail.com. 本章描述USB 3.0 集线器的体系结构要求.本章还描述主机下行口和集线器下行口之间功能性的不同之处,以及设 ...
- linux下Oracle11g RAC搭建(一)
linux下Oracle11g RAC搭建(一) 文档说明 作者 深蓝 项目 Visualbox下模拟RAC搭建(双节点)(Redhat5+Oracle11G) 环境 RedHat Enterp ...
- ios开发级联菜单(利用父子控制器--两个菜单封装为两个子控制器来实现)
一:1:级联菜单可以使用两个tableView来实现,也可以利用父子控制器,两个控制器来实现,根视图控制器作为两个控制器的父控制器,来管理两个子控制器.2:将左右菜单分别交给两个控制器去管理,对于一些 ...
- ChangeWindowMessageFilterEx 概述(用于取消低权限程序向高权限程序发送消息不成功的限制,分6个等级)
ChangeWindowMessageFilterEx 函数,为指定窗口修改用户界面特权隔离 (UIPI) 消息过滤器. 函数原型: BOOL WINAPI ChangeWindowMessageFi ...
- 【u206】最大赢家
Time Limit: 1 second Memory Limit: 128 MB [问题描述] Nic和Susan在玩一个有趣的游戏:在游戏开始前,他们先约定一个正整数n,同时令m=1.游戏过程中, ...
- [React] Normalize Events with Reacts Synthetic Event System
Event handlers are passed an instance of SyntheticEvent in React. In this video we'll take a look at ...
- 安全配置基线Linux系统
Linux系统安全配置基线 一:共享账号检查 配置名称:用户账号分配检查,避免共享账号存在 配置要求:1.系统需按照实际用户分配账号: 2.避免不同用户间共享账号,避免用户账号和服务器间通信使用的账号 ...