查询 DNS 记录

2024-04-10#Linux#DNS

在 Linux 和 macOS 上,有多种方式查询 DNS 记录。比如 hostdig 等命令。

host 🔗

$ host google.com
google.com has address 172.217.194.138
google.com has address 172.217.194.139
google.com has address 172.217.194.102
google.com has address 172.217.194.113
google.com has address 172.217.194.101
google.com has address 172.217.194.100
google.com has IPv6 address 2404:6800:4003:c04::8a
google.com has IPv6 address 2404:6800:4003:c04::66
google.com has IPv6 address 2404:6800:4003:c04::65
google.com has IPv6 address 2404:6800:4003:c04::8b
google.com mail is handled by 10 smtp.google.com.

dig 🔗

查询特定DNS服务器上的DNS记录 🔗

比如查询 google.com 在 Cloudflare 的 DNS 服务器 1.1.1.1 上的记录:

➜  dig @1.1.1.1 google.com

; <<>> DiG 9.10.6 <<>> @1.1.1.1 google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46978
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.			IN	A

;; ANSWER SECTION:
google.com.		60	IN	A	93.46.8.90

;; Query time: 42 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)
;; WHEN: Sun Sep 29 11:36:35 CST 2024
;; MSG SIZE  rcvd: 54

加载中...