《工具录》dig

news2025/2/28 18:20:16

工具录

  • 1:dig
  • 2:选项介绍
  • 3:示例
  • 4:其他


本文以 kali-linux-2023.2-vmware-amd64 为例。

1:dig

dig 是域名系统(DNS)查询工具,常用于域名解析和网络故障排除。比 nslookup 有更强大的功能。

基本语法
dig [选项]

2:选项介绍

选项总览

┌──(root㉿kali)-[~]
└─# dig -h              
Usage:  dig [@global-server] [domain] [q-type] [q-class] {q-opt}
            {global-d-opt} host [@local-server] {local-d-opt}
            [ host [@local-server] {local-d-opt} [...]]
Where:  domain    is in the Domain Name System
        q-class  is one of (in,hs,ch,...) [default: in]
        q-type   is one of (a,any,mx,ns,soa,hinfo,axfr,txt,...) [default:a]
                 (Use ixfr=version for type ixfr)
        q-opt    is one of:
                 -4                  (use IPv4 query transport only)
                 -6                  (use IPv6 query transport only)
                 -b address[#port]   (bind to source address/port)
                 -c class            (specify query class)
                 -f filename         (batch mode)
                 -k keyfile          (specify tsig key file)
                 -m                  (enable memory usage debugging)
                 -p port             (specify port number)
                 -q name             (specify query name)
                 -r                  (do not read ~/.digrc)
                 -t type             (specify query type)
                 -u                  (display times in usec instead of msec)
                 -x dot-notation     (shortcut for reverse lookups)
                 -y [hmac:]name:key  (specify named base64 tsig key)
        d-opt    is of the form +keyword[=value], where keyword is:
                 +[no]aaflag         (Set AA flag in query (+[no]aaflag))
                 +[no]aaonly         (Set AA flag in query (+[no]aaflag))
                 +[no]additional     (Control display of additional section)
                 +[no]adflag         (Set AD flag in query (default on))
                 +[no]all            (Set or clear all display flags)
                 +[no]answer         (Control display of answer section)
                 +[no]authority      (Control display of authority section)
                 +[no]badcookie      (Retry BADCOOKIE responses)
                 +[no]besteffort     (Try to parse even illegal messages)
                 +bufsize[=###]      (Set EDNS0 Max UDP packet size)
                 +[no]cdflag         (Set checking disabled flag in query)
                 +[no]class          (Control display of class in records)
                 +[no]cmd            (Control display of command line -
                                      global option)
                 +[no]comments       (Control display of packet header
                                      and section name comments)
                 +[no]cookie         (Add a COOKIE option to the request)
                 +[no]crypto         (Control display of cryptographic
                                      fields in records)
                 +[no]defname        (Use search list (+[no]search))
                 +[no]dns64prefix    (Get the DNS64 prefixes from ipv4only.arpa)
                 +[no]dnssec         (Request DNSSEC records)
                 +domain=###         (Set default domainname)
                 +[no]edns[=###]     (Set EDNS version) [0]
                 +ednsflags=###      (Set EDNS flag bits)
                 +[no]ednsnegotiation (Set EDNS version negotiation)
                 +ednsopt=###[:value] (Send specified EDNS option)
                 +noednsopt          (Clear list of +ednsopt options)
                 +[no]expandaaaa     (Expand AAAA records)
                 +[no]expire         (Request time to expire)
                 +[no]fail           (Don't try next server on SERVFAIL)
                 +[no]header-only    (Send query without a question section)
                 +[no]https[=###]    (DNS-over-HTTPS mode) [/]
                 +[no]https-get      (Use GET instead of default POST method while using HTTPS)
                 +[no]http-plain[=###]    (DNS over plain HTTP mode) [/]
                 +[no]http-plain-get      (Use GET instead of default POST method while using plain HTTP)
                 +[no]identify       (ID responders in short answers)
                 +[no]idn            (convert international domain names)
                 +[no]ignore         (Don't revert to TCP for TC responses.)
                 +[no]keepalive      (Request EDNS TCP keepalive)
                 +[no]keepopen       (Keep the TCP socket open between queries)
                 +[no]multiline      (Print records in an expanded format)
                 +ndots=###          (Set search NDOTS value)
                 +[no]nsid           (Request Name Server ID)
                 +[no]nssearch       (Search all authoritative nameservers)
                 +[no]onesoa         (AXFR prints only one soa record)
                 +[no]opcode=###     (Set the opcode of the request)
                 +padding=###        (Set padding block size [0])
                 +qid=###            (Specify the query ID to use when sending queries)
                 +[no]qr             (Print question before sending)
                 +[no]question       (Control display of question section)
                 +[no]raflag         (Set RA flag in query (+[no]raflag))
                 +[no]rdflag         (Recursive mode (+[no]recurse))
                 +[no]recurse        (Recursive mode (+[no]rdflag))
                 +retry=###          (Set number of UDP retries) [2]
                 +[no]rrcomments     (Control display of per-record comments)
                 +[no]search         (Set whether to use searchlist)
                 +[no]short          (Display nothing except short
                                      form of answers - global option)
                 +[no]showbadcookie  (Show BADCOOKIE message)
                 +[no]showsearch     (Search with intermediate results)
                 +[no]split=##       (Split hex/base64 fields into chunks)
                 +[no]stats          (Control display of statistics)
                 +subnet=addr        (Set edns-client-subnet option)
                 +[no]tcflag         (Set TC flag in query (+[no]tcflag))
                 +[no]tcp            (TCP mode (+[no]vc))
                 +timeout=###        (Set query timeout) [5]
                 +[no]tls            (DNS-over-TLS mode)
                 +[no]tls-ca[=file]  (Enable remote server's TLS certificate validation)
                 +[no]tls-hostname=hostname (Explicitly set the expected TLS hostname)
                 +[no]tls-certfile=file (Load client TLS certificate chain from file)
                 +[no]tls-keyfile=file (Load client TLS private key from file)
                 +[no]trace          (Trace delegation down from root [+dnssec])
                 +tries=###          (Set number of UDP attempts) [3]
                 +[no]ttlid          (Control display of ttls in records)
                 +[no]ttlunits       (Display TTLs in human-readable units)
                 +[no]unknownformat  (Print RDATA in RFC 3597 "unknown" format)
                 +[no]vc             (TCP mode (+[no]tcp))
                 +[no]yaml           (Present the results as YAML)
                 +[no]zflag          (Set Z flag in query)
        global d-opts and servers (before host name) affect all queries.
        local d-opts and servers (after host name) affect only that lookup.
        -h                           (print help and exit)
        -v                           (print version and exit)

3:示例

示例 3-1:查询 www.baidu.com 的 DNS 信息。

dig www.baidu.com

结果:

在这里插入图片描述

解释:

; <<>> DiG 9.18.13-1-Debian <<>> www.baidu.com    # dig 版本和要查询的域
;; global options: +cmd    # 全局选项,dig 可以查询多个域,这里显示应用于所有查询的选项。默认为 +cmd

;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8425
# 输出从 DNS 返回的技术信息
# opcode(操作码):QUERY(查询),IQUERY(反查询),STATUS(监测状态)等。
# status(状态):NOERROR 表示请求查询成功。
# id:一个随机的将请求与响应绑定在一起的数字。

;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
# qr(query)
# rd(recursion desired)
# ra(recursion avaliable)
# aa(authoritative answer)代表权威域名服务器作出了响应
# QUERY:查询数量 
# ANSWER:结果数量
# AURHORITY:来自权威域名服务器的结果数量
# ADDITIONAL:附加信息,当其值大于1的时候才会看到额外信息

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; MBZ: 0x0005, udp: 4096
# 选择伪切片

;; QUESTION SECTION:
;www.baidu.com.                 IN      A
# 查询字段,显示要查询的域名以及查询的服务
# IN(Internet)表示互联网查询
# A(Address)表示 A 记录查询,即主机查询

;; ANSWER SECTION:
www.baidu.com.          5       IN      CNAME   www.a.shifen.com.
www.a.shifen.com.       5       IN      A       110.242.68.3
www.a.shifen.com.       5       IN      A       110.242.68.4
# 查询结果

;; Query time: 8 msec
;; SERVER: 192.168.8.2#53(192.168.8.2) (UDP)
;; WHEN: Tue Jul 11 02:15:44 EDT 2023
;; MSG SIZE  rcvd: 101
# 请求所花的时间,DNS 服务器,当前时间,查询信息的大小

示例 3-2:只显示简要信息,而不显示任何其他信息。

dig www.baidu.com +short

结果:

在这里插入图片描述

示例 3-3:查询域名的邮件交换(MX)记录。

dig google.com MX

结果:

在这里插入图片描述

示例 3-4:查看 txt 记录。

dig google.com TXT

示例 3-5:得到最基本的 DNS 查询结果,不包含注释、问题、权威、附加和统计信息。

dig baidu.com +nocomments +noquestion +noauthority +noadditional +nostats

在这里插入图片描述

示例 3-6:反向查询与指定 IP 地址相关联的域名。

dig -x 114.114.114.114

在这里插入图片描述

示例 3-7:指定 DNS 服务器对相同的域名解析。

dig @114.114.114.114 www.baidu.com

在这里插入图片描述

示例 3-8:显示 DNS 查询的整个路由。

dig +trace baidu.com

示例 3-9:指定 DNS 服务端口号。如果 DNS 服务标准端口 53 被更改则可以使用此命令。

dig -p 5300 www.baidu.com

4:其他

其他资料:

《dig 命令的学习》
https://blog.csdn.net/u014029795/article/details/87226813

《linux 命令总结之 dig 命令》
https://blog.csdn.net/GzmObject/article/details/124696962

《How to Use the Dig Command in Linux》
https://www.hostinger.com/tutorials/how-to-use-the-dig-command-in-linux/

《DIG command: Query name servers》
https://www.ibm.com/docs/en/zos/2.1.0?topic=command-dig-query-name-servers


知我者,谓我心忧;不知我者,谓我何求。

——《黍离》(先秦)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1382510.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

一张图总结架构设计的40个黄金法则

尼恩说在前面 在40岁老架构师 尼恩的读者交流群(50)中&#xff0c;很多小伙伴拿到非常优质的架构机会&#xff0c;常常找尼恩求助&#xff1a; 尼恩&#xff0c;我这边有一个部门技术负责人资深架构师的机会&#xff0c;非常难得&#xff0c; 但是有一个大厂高P在抢&#xff0…

为什么很多公司选择不升级JDK版本,仍然使用JDK8?

在讨论为什么许多公司选择不升级JDK版本&#xff0c;而继续使用JDK 8时&#xff0c;我们需要从多个角度来分析这个问题。以下是根据您提供的背景信息进行的一些分析和真实案例。 本文已收录于&#xff0c;我的技术网站 ddkk.com&#xff0c;有大厂完整面经&#xff0c;工作技术…

H5网站封装成App的高效转换之旅

在移动互联网时代&#xff0c;App&#xff08;应用程序&#xff09;和H5&#xff08;HTML5网站&#xff09;是两种常见的移动解决方案。App通常提供更流畅的用户体验和更丰富的功能&#xff0c;而H5网站则以其开发成本低、更新快捷和无需安装等优势受到青睐。尽管如此&#xff…

【java八股文】之Spring系列篇

1、你怎么理解Spring&#xff1f; Spring是个轻量级的框架&#xff0c;简化了应用的开发程序&#xff0c;提高开发人员的系统维护性&#xff0c;不过配置消息比较繁琐&#xff0c;所以后面才出选了SpringBoot的框架。 Spring的核心组件 &#xff1a; Spring Core 、 Spring Con…

Video接口介绍

屏库 https://m.panelook.cn/index_cn.php Open LDI, open lvds display interface OpenLDI and LVDS是兼容的&#xff0c; 是一种电平 https://www.ti2k.com/178597.html MIPI DSI/Camera crosLink FPD-LINK(Flat panel display link)是National(TI) LVDS技术&#xff0c; …

Openstack云计算(六)Openstack环境对接ceph

一、实施步骤&#xff1a; &#xff08;1&#xff09;客户端也要有cent用户&#xff1a; useradd cent && echo "123" | passwd --stdin cent echo -e Defaults:cent !requiretty\ncent ALL (root) NOPASSWD:ALL | tee /etc/sudoers.d/ceph chmod 440 /et…

[足式机器人]Part2 Dr. CAN学习笔记-Advanced控制理论 Ch04-12+13 不变性原理+非线性系统稳定设计

本文仅供学习使用 本文参考&#xff1a; B站&#xff1a;DR_CAN Dr. CAN学习笔记-Advanced控制理论 Ch04-1213 不变性原理非线性系统稳定设计 1. Invariance Princilpe-LaSalle;s Theorem不变性原理2. Nonlinear Basic Feedback Stabilization 非线性系统稳定设计 1. Invarianc…

Java内存模型之重排序

文章目录 1.什么是重排序2.重排序的好处3.重排序的三种情况4.用volatile修正重排序问题 1.什么是重排序 首先来看一个代码案例&#xff0c;尝试分析一下 x 和 y 的运行结果。 import java.util.concurrent.CountDownLatch;/*** 演示重排序的现象&#xff0c;直到达到某个条件…

css深度选择器 /deep/

一、/deep/的含义和使用 /deep/ 是一种 CSS 深度选择器&#xff0c;也被称为深度组合器或者阴影穿透组合器&#xff0c;主要用在 Web 组件样式封装中。 在 Vue.js 或者 Angular 中&#xff0c;使用了样式封装技术使得组件的样式不会影响到全局&#xff0c;也就是说组件内部的…

java数据结构与算法:单链表 SinglyLinkedList

单链表 SinglyLinkedList 创建实现类并实现方法 package com.lhs;public class SinglyLinkedList<E> implements List<E>{// 头节点private Node<E> first;// 尾节点private Node<E> last;// 节点数量private int size;public static class Node<…

PDCA/绩效管理活动

现代绩效管理理论认为&#xff0c;绩效管理活动是一个连续的过程&#xff0c;是指管理者用来确保自己下属员工的工作行为和工作产出与组织的目标保持一致的手段及过程。人们通常用一个循环过程来描述绩效管理的整个过程。我们认为&#xff0c;一个组织的员工绩效管理活动由四个…

Dockerfile的ADD和COPY

文章目录 环境ADD规则校验远程文件checksum添加Git仓库添加私有Git仓库ADD --link COPYCOPY --parent 使用ADD还是COPY&#xff1f;参考 环境 RHEL 9.3Docker Community 24.0.7 ADD ADD 指令把 <src> 的文件、目录、或URL链接的文件复制到 <dest> 。 ADD 有两种…

element表格数据,表头上(下)角标,html字符串渲染

1. 问题描述 在动态渲染的element表格中&#xff0c;表头和表中数据是一个含有html的字符串&#xff0c;需要渲染 2. 效果 3. 代码 const columns ref([{ text: 差值<sub>-3</sub> / 10<sup>-6</sup>℃<sup>-1</sup>, value: aallowEr…

Android平台RTMP推送|轻量级RTSP服务|GB28181设备接入模块之实时快照保存JPG还是PNG?

JPG还是PNG&#xff1f; JPG和PNG是两种常见的图片文件格式&#xff0c;在压缩方式、图像质量、透明效果和可编辑性等方面存在显著差异。 压缩方式&#xff1a;JPG是一种有损压缩格式&#xff0c;通过丢弃图像数据来减小文件大小&#xff0c;因此可能会损失一些图像细节和质量…

将图片添加到 PDF 的 5 种方法

需要一种称为 PDF 编辑器的特定工具才能将图片添加到 PDF。尽管大多数浏览器在查看和注释 PDF 文件方面都非常出色&#xff0c;但如果您使用图像到 PDF 技术&#xff0c;则只能将照片放入 PDF 中。无需修改即可将 PDF 文件恢复为原始格式的能力是使用此类软件程序甚至在线服务的…

故障诊断全家桶,看这一篇就够了,精品力荐!

本期推出故障诊断全家桶&#xff0c;包含传统的分析时频诊断方法&#xff0c;依靠数据分解方法的诊断方法&#xff0c;依靠机器学习的诊断方法。还包含了6种适应度函数随意切换的VMD优化方法&#xff0c;16种数据分解方法&#xff0c;包络谱&#xff0c;包络熵等代码。以及作者…

计算机硬件 5.1机箱与电源

第五章 其他设备 第一节 机箱与电源 一、认识电源 1.功能&#xff1a;将普通交流电转换为直流电&#xff0c;再控制电压分别输出给不同部件。 2.分类&#xff1a; 3.供电插头&#xff1a; ①8Pin插头&#xff1a;为高档PCI-E显卡供电&#xff0c;或为较新的CPU供电&#xff…

2023 我的编程之旅——路人贾‘ω‘

哈喽&#xff01;大家好&#xff0c;我是路人贾&#x1f601;~今天不读论文也不讲算法&#xff0c;来聊点有意思的&#xff01; 这是我第100篇博文&#xff0c;我翻了几遍草稿箱的库存&#xff0c;正纠结选哪篇时&#xff0c;一抬头看见了这个活动&#xff0c;眼前瞬间一亮——…

学习Java API(一):基础知识点一文通✅

推荐阅读 智能化校园&#xff1a;深入探讨云端管理系统设计与实现&#xff08;一&#xff09; 智能化校园&#xff1a;深入探讨云端管理系统设计与实现&#xff08;二&#xff09; 文章目录 推荐阅读API文档注释String类创建字符串拼接字符串格式化字符串String方法substring(…