매번 잊어버려서 따로 정리함.
자주 활용되는 것만 정리.

dig command 란?

dig 는 도메인 네임 시스템 네임서버에 질의하기 위한 네트워크 관리 명령 줄 인터페이스 도구 입니다.

Domain 의 IP 확인

Domain 에 연결된 IP 를 확인하는 방법입니다.

chhan@chhanPC:~$ dig chhanz.mooo.com

; <<>> DiG 9.16.1-Ubuntu <<>> chhanz.mooo.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31021
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;chhanz.mooo.com.               IN      A

;; ANSWER SECTION:
chhanz.mooo.com.        3028    IN      A       193.123.241.21x

;; Query time: 74 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Mon Jul 25 10:15:07 KST 2022
;; MSG SIZE  rcvd: 60

일반적인 질의이며 A record 확인 및 질의에 응답한 Name server 의 정보를 확인 할 수 있습니다.

참고) A record 정보만 간단하게 확인하기 위해서는 +short 옵션을 이용합니다.

chhan@chhanPC:~$ dig chhanz.mooo.com +short
193.123.241.21x

특정 DNS 를 지정하여 질의

특정 DNS 를 지정하여 질의하는 방법은 아래와 같습니다.

chhan@chhanPC:~$ dig @1.1.1.1 chhanz.mooo.com

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

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;chhanz.mooo.com.               IN      A

;; ANSWER SECTION:
chhanz.mooo.com.        3600    IN      A       193.123.241.21x

;; Query time: 181 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)          << 변경된 name server
;; WHEN: Mon Jul 25 10:18:30 KST 2022
;; MSG SIZE  rcvd: 60

@<dns IP> 옵션을 이용하여 특정 DNS 로 질의를 할 수 있습니다.

Domain 이 등록된 Name Server 확인

특정 Domain 이 등록된 Name Server 를 확인하는 방법은 아래와 같습니다.

chhan@chhanPC:~$ dig naver.com NS +short
e-ns.naver.com.
ns2.naver.com.
ns1.naver.com.
chhan@chhanPC:~$ dig google.com NS +short
ns4.google.com.
ns1.google.com.
ns2.google.com.
ns3.google.com.

아래와 같은 방법으로도 확인이 가능합니다. (+nssearch 옵션)

chhan@chhanPC:~$ dig google.com +nssearch
SOA ns1.google.com. dns-admin.google.com. 462911687 900 900 1800 60 from server 216.239.34.10 in 55 ms.
SOA ns1.google.com. dns-admin.google.com. 462799232 900 900 1800 60 from server 216.239.38.10 in 51 ms.
SOA ns1.google.com. dns-admin.google.com. 462911687 900 900 1800 60 from server 216.239.36.10 in 58 ms.
SOA ns1.google.com. dns-admin.google.com. 462911687 900 900 1800 60 from server 216.239.32.10 in 74 ms.

MX type 질의 (mail server 확인)

Domain 의 Mail Server 확인은 아래와 같습니다.

chhan@chhanPC:~$ dig google.com MX +short
10 smtp.google.com.
chhan@chhanPC:~$ dig naver.com MX +short
10 mx1.naver.com.
10 mx3.naver.com.
10 mx2.naver.com.

DNS 질의 경로 확인

root DNS 로부터 DNS 의 질의 경로를 확인 할 수 있습니다.

chhan@chhanPC:~$ dig chhanz.mooo.com +trace

; <<>> DiG 9.16.1-Ubuntu <<>> chhanz.mooo.com +trace
;; global options: +cmd
.                       86691   IN      NS      a.root-servers.net.
.                       86691   IN      NS      b.root-servers.net.
...생략
;; Received 525 bytes from 8.8.8.8#53(8.8.8.8) in 51 ms

com.                    172800  IN      NS      a.gtld-servers.net.
com.                    172800  IN      NS      b.gtld-servers.net.
...생략
;; Received 1175 bytes from 198.41.0.4#53(a.root-servers.net) in 39 ms

mooo.com.               172800  IN      NS      ns1.afraid.org.
mooo.com.               172800  IN      NS      ns2.afraid.org.
mooo.com.               172800  IN      NS      ns3.afraid.org.
mooo.com.               172800  IN      NS      ns4.afraid.org.
...생략
;; Received 675 bytes from 192.5.6.30#53(a.gtld-servers.net) in 11 ms

chhanz.mooo.com.        3600    IN      A       193.123.241.21x
mooo.com.               3600    IN      NS      ns4.afraid.org.
mooo.com.               3600    IN      NS      ns2.afraid.org.
mooo.com.               3600    IN      NS      ns3.afraid.org.
mooo.com.               3600    IN      NS      ns1.afraid.org.
;; Received 290 bytes from 69.65.50.223#53(ns2.afraid.org) in 186 ms

참고 자료

chhanz's profile image

chhanz

2022-07-25

Read more posts by this author