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动态更 ...
随机推荐
- php实现矩形覆盖
php实现矩形覆盖 一.总结 很简单的斐波那契数列 二.php实现矩形覆盖 题目描述: 我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形.请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总 ...
- matplotlib学习之散点图与条形图
# coding:utf-8 from matplotlib import pyplot as plt import numpy as np plt.style.use('ggplot') x = n ...
- Chinese remainder theorem
https://en.wikipedia.org/wiki/Chinese_remainder_theorem http://planetmath.org/ChineseRemainderTheore ...
- spring-如何在项目启动的情况下获取Bean实例
十年阿里,就只剩下这套Java开发体系了 >>> 大家都知道,项目启动的时候,spring读取xml文件,将配置的bean 或者 注解下的controller service d ...
- HtmlParser基础教程 分类: C_OHTERS 2014-05-22 11:33 1649人阅读 评论(1) 收藏
1.相关资料 官方文档:http://htmlparser.sourceforge.net/samples.html API:http://htmlparser.sourceforge.net/jav ...
- php输出文件,数组
file_put_contents('C://zll.txt',var_export($data,true));//输出数组 file_put_contents('C://zll.txt','你好啊' ...
- 【u208】修复公路
Time Limit: 1 second Memory Limit: 128 MB [问题描述] A地区在地震过后,连接所有村庄的公路都造成了损坏而无法通车.政府派人修复这些公路. 给出A地区的村庄数 ...
- Tomcat启动失败问题解决
1. 系统框架加载正常,但是Tomcat启动失败,报错如下: 2013-7-26 17:18:33 org.apache.catalina.core.StandardContext startInte ...
- cocos2d-x 3.0学习游戏笔记的例子《卡塔防》第五步---开始建立游戏界面
/* 说明: **1.本次游戏实例是<cocos2d-x游戏开发之旅>上的最后一个游戏,这里用3.0重写并做下笔记 **2.我也问过木头本人啦,他说:随便写.第一别全然照搬代码.第二能够说 ...
- 【33.33%】【codeforces 608C】Chain Reaction
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...