使用dig/nslookup命令查看dns解析详情

Linux系统 专栏收录该内容
31 篇文章 0 订阅

dig - DNS lookup utility


当域名出现访问故障时,可以通过检查域名解析来判断是否是由错误的解析导致的问题。
1.域名解析无结果(不存在或被HOLD(未实名认证等))
2.域名解析到错误的IP(被阻断,被劫持响应错误结果,需要对解析流程做判断)
3.对应CNAME记录的值无法解析
4.部分解析异常(配置多个域名服务器时,多个服务器解析结果不一致,需要确认是否在DNS服务器上配置添加的解析记录一致)


简单使用解析一下www.baidu.com结果如下:
这里写图片描述
可以看到有请求段和应答段,最后解析出的A记录有两条。


dig命令做迭代查询


在命令后加上+trace可以跟踪整个解析流程:
1. 由根域名服务器查找到负责解析.com的顶级域名服务器
2. 由顶级域名服务器查找到baidu.com的二级域名服务器
3. 由二级域名服务器查找到www.baidu.com对应一条CNAME记录www.a.shifen.com
4. 再去查找www.a.shifen.com对应的A记录
5. 最后返回A记录对应的IP地址

[root@jia3 ~]# dig www.baidu.com +trace

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6 <<>> www.baidu.com +trace
;; global options: +cmd
.                       320307  IN      NS      a.root-servers.net.
.                       320307  IN      NS      k.root-servers.net.
.                       320307  IN      NS      i.root-servers.net.
.                       320307  IN      NS      l.root-servers.net.
.                       320307  IN      NS      b.root-servers.net.
.                       320307  IN      NS      e.root-servers.net.
.                       320307  IN      NS      h.root-servers.net.
.                       320307  IN      NS      d.root-servers.net.
.                       320307  IN      NS      g.root-servers.net.
.                       320307  IN      NS      j.root-servers.net.
.                       320307  IN      NS      f.root-servers.net.
.                       320307  IN      NS      m.root-servers.net.
.                       320307  IN      NS      c.root-servers.net.
;; Received 228 bytes from 202.106.0.20#53(202.106.0.20) in 98 ms

com.                    172800  IN      NS      c.gtld-servers.net.
com.                    172800  IN      NS      l.gtld-servers.net.
com.                    172800  IN      NS      d.gtld-servers.net.
com.                    172800  IN      NS      h.gtld-servers.net.
com.                    172800  IN      NS      m.gtld-servers.net.
com.                    172800  IN      NS      a.gtld-servers.net.
com.                    172800  IN      NS      k.gtld-servers.net.
com.                    172800  IN      NS      b.gtld-servers.net.
com.                    172800  IN      NS      e.gtld-servers.net.
com.                    172800  IN      NS      g.gtld-servers.net.
com.                    172800  IN      NS      j.gtld-servers.net.
com.                    172800  IN      NS      i.gtld-servers.net.
com.                    172800  IN      NS      f.gtld-servers.net.
;; Received 491 bytes from 192.5.5.241#53(192.5.5.241) in 93 ms

baidu.com.              172800  IN      NS      dns.baidu.com.
baidu.com.              172800  IN      NS      ns2.baidu.com.
baidu.com.              172800  IN      NS      ns3.baidu.com.
baidu.com.              172800  IN      NS      ns4.baidu.com.
baidu.com.              172800  IN      NS      ns7.baidu.com.
;; Received 201 bytes from 192.48.79.30#53(192.48.79.30) in 501 ms

www.baidu.com.          1200    IN      CNAME   www.a.shifen.com.
a.shifen.com.           1200    IN      NS      ns1.a.shifen.com.
a.shifen.com.           1200    IN      NS      ns2.a.shifen.com.
a.shifen.com.           1200    IN      NS      ns5.a.shifen.com.
a.shifen.com.           1200    IN      NS      ns3.a.shifen.com.
a.shifen.com.           1200    IN      NS      ns4.a.shifen.com.
;; Received 228 bytes from 220.181.37.10#53(220.181.37.10) in 8 ms

域名不存在时,dig命令如何返回


比如解析 www.not-exists-domain.com这个域名,是不存在的。
整个过程如下:
1. 由根域名返回.com顶级域的服务器地址
2. 由.com顶级域查到二级域名不存在,返回一条SOA记录

[root@jia3 ~]# dig www.not-exists-domain.com +trace

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6 <<>> www.not-exists-domain.com +trace
;; global options: +cmd
.                       319714  IN      NS      b.root-servers.net.
.                       319714  IN      NS      e.root-servers.net.
.                       319714  IN      NS      h.root-servers.net.
.                       319714  IN      NS      d.root-servers.net.
.                       319714  IN      NS      g.root-servers.net.
.                       319714  IN      NS      j.root-servers.net.
.                       319714  IN      NS      f.root-servers.net.
.                       319714  IN      NS      m.root-servers.net.
.                       319714  IN      NS      c.root-servers.net.
.                       319714  IN      NS      a.root-servers.net.
.                       319714  IN      NS      k.root-servers.net.
.                       319714  IN      NS      i.root-servers.net.
.                       319714  IN      NS      l.root-servers.net.
;; Received 228 bytes from 202.106.0.20#53(202.106.0.20) in 105 ms

com.                    172800  IN      NS      e.gtld-servers.net.
com.                    172800  IN      NS      c.gtld-servers.net.
com.                    172800  IN      NS      j.gtld-servers.net.
com.                    172800  IN      NS      l.gtld-servers.net.
com.                    172800  IN      NS      k.gtld-servers.net.
com.                    172800  IN      NS      g.gtld-servers.net.
com.                    172800  IN      NS      m.gtld-servers.net.
com.                    172800  IN      NS      a.gtld-servers.net.
com.                    172800  IN      NS      i.gtld-servers.net.
com.                    172800  IN      NS      h.gtld-servers.net.
com.                    172800  IN      NS      b.gtld-servers.net.
com.                    172800  IN      NS      f.gtld-servers.net.
com.                    172800  IN      NS      d.gtld-servers.net.
;; Received 503 bytes from 192.112.36.4#53(192.112.36.4) in 228 ms

com.                    900     IN      SOA     a.gtld-servers.net. nstld.verisign-grs.com. 1524576381 1800 900 604800 86400
;; Received 116 bytes from 192.12.94.30#53(192.12.94.30) in 333 ms

################################################################


nslookup - query Internet name servers interactively


nslookup有交互式和非交互式两种使用方式如下图:
这里写图片描述


nslookup还可以指定到某个域名服务器做解析命令格式如下:
nslookup www.baidu.com 8.8.8.8(域名服务器地址)
这里写图片描述

  • 4
    点赞
  • 2
    评论
  • 20
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

Preface Audience for This Book Organization What's New in This Edition Example Programs Using Code Examples Conventions Used in This Book Comments and Questions Safari® Enabled Acknowledgments for the Second Edition Acknowledgments for the First Edition Chapter 1. Introduction to SNMP and Network Management Section 1.1. What Is SNMP? Section 1.2. The Concept of Network Management Section 1.3. Applying the Concepts of Network Management Section 1.4. Change Management Section 1.5. Getting More Information Chapter 2. SNMPv1 and SNMPv2 Section 2.1. SNMP and UDP Section 2.2. SNMP Communities Section 2.3. The Structure of Management Information Section 2.4. Extensions to the SMI in Version 2 Section 2.5. A Closer Look at MIB-II Section 2.6. SNMP Operations Section 2.7. Host Management Revisited Section 2.8. Remote Monitoring Revisited Section 2.9. Reverse Engineering SNMP Chapter 3. SNMPv3 Section 3.1. Changes in SNMPv3 Section 3.2. USM Section 3.3. VACM Section 3.4. SNMPv3 in the Real World Chapter 4. NMS Architectures Section 4.1. Hardware Considerations Section 4.2. NMS Architectures Section 4.3. A Look Ahead Chapter 5. Configuring Your NMS Section 5.1. HP's OpenView Network Node Manager Section 5.2. Castle Rock's SNMPc Enterprise Edition Chapter 6. Configuring SNMP Agents Section 6.1. Parameter Settings Section 6.2. Security Concerns Section 6.3. Agent Configuration Walkthroughs Chapter 7. Polling and Setting Section 7.1. Retrieving a Single MIB Value Section 7.2. Retrieving Multiple MIB Values Section 7.3. Setting a MIB Value Section 7.4. Error Responses Chapter 8. Polling and Thresholds Section 8.1. Internal Polling Section 8.2. External Polling Chapter 9. Traps Section 9.1. Understanding Traps Section 9.2. Receiving Traps Section 9.3. Sending Traps Chapter 10. Extensible SNMP Agents Section 10.1. Net-SNMP Section 10.2. SystemEDGE Section 10.3. OpenView's Extensible Agent Chapter 11. Adapting SNMP to Fit Your Environment Section 11.1. General Trap-Generation Program Section 11.2. Who's Logging into My Machine? (I-Am-In) Section 11.3. Throw Core Section 11.4. Veritas Disk Check Section 11.5. Disk-Space Checker Section 11.6. Port Monitor Section 11.7. Service Monitoring Section 11.8. Pinging with Cisco Section 11.9. Simple SNMP Agent Section 11.10. Switch Port Control Section 11.11. Wireless Networking Section 11.12. SNMP: The Object-Oriented Way Section 11.13. Final Words Chapter 12. MRTG Section 12.1. Using MRTG Section 12.2. Viewing Graphs Section 12.3. Graphing Other Objects Section 12.4. Other Data-Gathering Applications Section 12.5. Pitfalls Section 12.6. Getting Help Chapter 13. RRDtool and Cricket Section 13.1. RRDtool Section 13.2. Cricket Chapter 14. Java and SNMP Section 14.1. SNMP4J Section 14.2. SNMP getnext Section 14.3. SNMP set Section 14.4. Sending Traps and Informs Section 14.5. Receiving Traps and Informs Section 14.6. Resources Appendix A. Using Input and Output Octets Appendix B. More on OpenView's NNM Section B.1. Using External Data Section B.2. Adding a Menu to NNM Section B.3. Profiles for Different Users Section B.4. Using NNM for Communications Appendix C. Net-SNMP Tools Section C.1. Net-SNMP and MIB Files Section C.2. Common Command-Line Arguments Section C.3. Net-SNMP Command-Line Tools Appendix D. SNMP RFCs Section D.1. SMIv1 Data Definition Language Section D.2. SMIv2 Data Definition Language Section D.3. SNMPv3 Protocol Section D.4. SNMP Agent Extensibility Section D.5. SMIv1 MIB Modules Section D.6. SMIv2 MIB Modules Section D.7. IANA-Maintained MIB Modules Section D.8. Related Documents Appendix E. SNMP Support for Perl Section E.1. SNMP_Util Section E.2. Net-SNMP Appendix F. Network Management Software Section F.1. SNMP Agents Section F.2. NMS Suites Section F.3. Element Managers (Vendor-Specific Management) Section F.4. Trend Analysis Section F.5. Supporting Software Appendix G. Open Source Monitoring Software Section G-1. Big Brother Section G-2. Nagios Section G-3. JFFNMS Section G-4. OpenNMS Section G-5. NINO Appendix H. Network Troubleshooting Primer Section H-1. ping Section H-2. ipconfig and ifconfig Section H-3. arp Section H-4. netstat Section H-5. traceroute and tracert Section H-6. nslookup and dig Section H-7. whois Section H-8. Ethereal About the Authors Colophon Index
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值