惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Full Disclosure
WordPress大学
WordPress大学
小众软件
小众软件
Cloudbric
Cloudbric
AWS News Blog
AWS News Blog
腾讯CDC
量子位
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
Scott Helme
Scott Helme
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Hacker News
The Hacker News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
Jina AI
Jina AI
Attack and Defense Labs
Attack and Defense Labs
S
SegmentFault 最新的问题
Simon Willison's Weblog
Simon Willison's Weblog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
Google Online Security Blog
Google Online Security Blog
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
罗磊的独立博客
L
LINUX DO - 最新话题
博客园 - Franky
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
The Last Watchdog
The Last Watchdog
J
Java Code Geeks
AI
AI
C
Cisco Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
Help Net Security
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
I
Intezer
S
Securelist

Ittavern.com

Wimage - Hosting Open-Source Image Uploader with Podman and external S3 Storage Switching from Hugo to picopaper Encryption using SSH Keys with age in Linux ETag in nginx - Simple Resource Caching Sending nginx Logs to Loki with Grafana Alloy How to: Cisco ISE backup to SFTP repository with public key authentication Dummy IP & MAC Addresses for Documentation & Sanitization Deploying ISSO Commenting System for Static Content using Docker Generate a Vanity v3 Hidden Service Onion Address with mkp224o ssh-audit Primer - Audit your SSH Server mtr - More Detailed Traceroute - Network Troubleshooting My Personal Backup Strategy - August 2024 iperf3 - User Authentication with Password and RSA Public Keypair Adding a trash can to Linux with trash-cli Bandwidth Measurement using netcat on Linux Getting started with rsync - Comprehensive Guide Cron Jobs on Linux - Comprehensive Guide with Examples SSH Server Hardening Guide v2 Port Knocking with knockd and Linux - Server Hardening Getting started with rclone - Data transmission Getting started with Fail2Ban on Linux Getting started with netcat on Linux with examples URL explained - The Fundamentals Troubleshooting Asking The Right Questions Create tmux layouts using bash scripts Getting started with tcpdump - Ittavern.com Curl on Linux - Reference Guide Getting started with nmap scripts My Offsite Backup - March 2023 Getting started with iperf3 - Network Troubleshooting ICMP echo requests on Linux and Windows - Reference Guide Simulate an unreliable network connection with tc and netem on Linux Detecting Rogue DHCP Server - Ittavern.com Basics of the Linux Bash Command History with Examples Getting started with GNU screen - Beginners Guide Basics of Power over Ethernet (PoE) Difference between RSS and Atom SSH Troubleshooting Guide - Ittavern.com Backup Guide - how to secure crucial data SSH - run script or command at login Linux - unmount a busy target safely Visual guide to SSH tunneling and port forwarding Guide to Wireshark display filters Online Security Guide - Ittavern.com My IT EDC tool kit v2212 10 prompts - 1000 AI generated images - openAI Dall-E SSH - How to use public key authentication on Linux Ways to support open-source projects Getting started with nmap - Ittavern.com nginx - simple and native authentication function Linux - How to work with complex commands EICAR test file - riskless method to test your antivirus and firewall solution Linux - connect to a serial port with screen Podman / Docker - expose port only to the localhost of the host machine Tmux - reload .tmux.conf configuration file My use cases for CyberChef Nginx - simple permanent or temporary redirects Getting started with tmux - Ittavern.com Tmux - synchronize the input of all panes within a window Nginx - check your public IP CyberChef - How to remove empty lines
Getting started with dig - DNS troubleshooting
2023-10-24 · via Ittavern.com

Getting started with dig

Please note that this blog post is not an in-depth guide on DNS and dig. It will provide you with the basics, and more advanced topics that are out of the scope. Some more advanced topics are DNS over HTTPs/TLS, all kinds of methods to format the results, DNSSEC, and so on. I'll go into more detail in separate posts.

Basic usage

Dig stands for 'Domain Information Groper' and is a great tool to troubleshoot DNS issues or get information about certain domains. It is an excellent alternative to nslookup and host and generally presents results that are more script-friendly.

The typical syntax is the following:
dig @server name type
@server - is the IP or name of the name server you want to handle the request. It is optional and if it is not specified, dig checks /etc/resolv.conf.
name - is the host or domain name for the request
type - the DNS type that is requested. It is optional and if it is not specified, dig will use the A record.

Basic example with line numbers added:

kuser@pleasejustwork:~$ dig ittavern.com

 1 ; <<>> DiG 9.18.12-0ubuntu0.22.04.3-Ubuntu <<>> ittavern.com
 2 ;; global options: +cmd
 3 ;; Got answer:
 4 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64814
 5 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
 6 
 7 ;; OPT PSEUDOSECTION:
 8 ; EDNS: version: 0, flags:; udp: 65494
 9 ;; QUESTION SECTION:
10 ;ittavern.com.                  IN      A
11 
12 ;; ANSWER SECTION:
13 ittavern.com.           600     IN      A       95.216.194.187
14 
15 ;; Query time: 40 msec
16 ;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
17 ;; WHEN: Fri Oct 13 20:26:34 CEST 2023
18 ;; MSG SIZE  rcvd: 67

Without providing too many options, we already get a lot of information, and I'll try to get into more detail in the following sections.

Let us start with line 4: the status field is the first indicator of the request's success.

NOERROR:
There was no problem. All requested information were delivered.
SERVFAIL:
The requested name exists, but there's no data available or the data is invalid.
NXDOMAIN:
The requested name doesn't exist.
REFUSED:
The zone doesn't exist at the name server.

I'll go into more detail of the other information when we talk about the usage.


Basic commands #

To get the version of dig:
-v
To get more information
-h
man dig
Chose the DNS record type:
dig ittavern.com mx
this would be an example of requesting an MX record. The default is an A record.
you can add the flag -t in front of it to separate it from the rest and make it more verbose
the ANY request to get all entries won't be answered from most name servers
I couldn't find a way to request all records for a domain without a script
Start a reverse lookup:
-x
if you want to lookup a name behind an IP
you don't have to specify the PTR type or IN class.

Choose a specific name server with @:
dig @9.9.9.9 ittavern.com
Specify the source IP and source port:
-b address[#port]
dig ittavern.com -b 10.10.10.10#12345
Specify the destination port:
-p port # the default port is 53, but some name servers listen to another one.

Send query over TCP:
+tcp
the default is UDP
Specify the query class:
-c CLASS # default is IN
Specify the IP version:
-4 # IPv4
-6 # IPv6

Multiple queries

You can write them in a single command one after the other, like the following example, or use a batch file like described in the following section.

dig ittavern.com ittavern.com mx brrl.net

Using a batch file #

Simply use batch files when you have a high number of requests. Every request should stand in a single line.

Using the -f flag to do so.

Sample file:

kuser@pleasejustwork: $ cat batch.txt 
ittavern.com a
ittavern.com mx
brrl.net a
You then can tell dig to use this file to send the queries:
dig -f batch.txt

You can use the usual options to shorten the output:

kuser@pleasejustwork: $ dig -f batch.txt +short
95.216.194.187
10 mxext2.mailbox.org.
10 mxext1.mailbox.org.
20 mxext3.mailbox.org.
94.130.76.189

Verbosity

As mentioned before, without additional options, dig provides you with a lot of information by default - more than nslookup or host.

To get less information, simply use +short:

kuser@pleasejustwork:~$ dig +short ittavern.com
95.216.194.187

To get even more information, use +trace:

kuser@pleasejustwork: $ dig +trace ittavern.com

; <<>> DiG 9.18.12-0ubuntu0.22.04.3-Ubuntu <<>> +trace ittavern.com
;; global options: +cmd
.                       40164   IN      NS      l.root-servers.net.
.                       40164   IN      NS      m.root-servers.net.
.                       40164   IN      NS      f.root-servers.net.
.                       40164   IN      NS      d.root-servers.net.
.                       40164   IN      NS      e.root-servers.net.
.                       40164   IN      NS      b.root-servers.net.
.                       40164   IN      NS      c.root-servers.net.
.                       40164   IN      NS      a.root-servers.net.
.                       40164   IN      NS      h.root-servers.net.
.                       40164   IN      NS      k.root-servers.net.
.                       40164   IN      NS      g.root-servers.net.
.                       40164   IN      NS      j.root-servers.net.
.                       40164   IN      NS      i.root-servers.net.
;; Received 239 bytes from 127.0.0.53#53(127.0.0.53) in 40 ms

;; communications error to 199.7.91.13#53: connection refused
;; communications error to 199.7.91.13#53: connection refused
;; communications error to 199.7.91.13#53: connection refused
;; communications error to 202.12.27.33#53: connection refused
;; communications error to 192.112.36.4#53: connection refused
[...]

It gives you more insight into the DNS process.

Conclusion

I hope this blog post will help you to get started with dig. It provides even more options to troubleshoot certain issues, but I'll tackle those topics in a separate post.