memos/linux/dig.md
2024-08-26 20:55:58 +09:00

1.4 KiB

domain information groper, DNS 쿼리를 위한 CLI 툴

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} [...]]

1. basic

dig host
dig naver.com
; <<>> DiG 9.18.28-0ubuntu0.24.04.1-Ubuntu <<>> naver.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50695
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;naver.com.                     IN      A

;; ANSWER SECTION:
naver.com.              25      IN      A       223.130.192.247
naver.com.              25      IN      A       223.130.200.236
naver.com.              25      IN      A       223.130.192.248
naver.com.              25      IN      A       223.130.200.219

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Sat Aug 24 16:56:24 UTC 2024
;; MSG SIZE  rcvd: 102

2. +short

답변을 간단하게 볼 때 사용

dig host +short
dig naver.com +short
223.130.200.219
223.130.192.247
223.130.200.236
223.130.192.248

3. record 지정

dig host record
dig naver.com a

4. dns 지정

dig @dns-address host
dig @8.8.8.8 google.com

5. Using DoH (DNS over Https)

dig +https @dns-address host