dig (domain information groper) ๋?
dig๋ ๋คํธ์ํฌ ๊ด๋ฆฌ ๋๊ตฌ ์ค ํ๋๋ก DNS (Domain Name System) ๋ฅผ ์ง์ํ ์ ์๋ ๋๊ตฌ์ ๋๋ค.
nslookup ๋๊ตฌ๋ฅผ ์ฌ์ฉํ์ฌ DNS ๋ฅผ ์ง์ํ ์ ์์ง๋ง, ๋ณด๋ค ๋ ํธํ ์ธํฐํ์ด์ค์ ์ฌ์ฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค.
์ด์ ๋๋ถ์ด IDN (Internationalized Domain Name) ์ฟผ๋ฆฌ๋ฅผ ์ง์ํฉ๋๋ค. (nslookup๋ ์ง์)
dig ์ค์น
์ต๊ทผ OS๋ค์๋ dig ์ปค๋งจ๋๊ฐ ๊ธฐ๋ณธ์ผ๋ก ์ค์น๋์ด ์์ต๋๋ค.
๋ง์ฝ, dig ์ปค๋งจ๋๊ฐ ์์ ๊ฒฝ์ฐ ์๋์ ๋ฐฉ๋ฒ์ผ๋ก ์ค์นํ๋ฉด ๋ฉ๋๋ค.
Mac
brew install dig
Windows
์ฒซ ๋ฒ์งธ ๋ฐฉ๋ฒ์ผ๋ก๋, ISC ๋ค์ด๋ก๋ ์ ์ ์ํ์ฌ ๋ค์ด๋ก๋ ํ ์ ์์ต๋๋ค.
windows dig ์ค์น
๋ ๋ฒ์งธ ๋ฐฉ๋ฒ์ผ๋ก๋ WSL (Windows Subsystem for Linux) ๋ฅผ ๋ค์ด๋ก๋ ํ์ฌ ์ฌ์ฉํ๋ ๊ฒ ์ ๋๋ค.
dig ์ฌ์ฉ๋ฒ
dig๋ ๊ฐ๋จํ๊ฒ ์กฐํํ๊ณ ์ ํ๋ ๋๋ฉ์ธ๋ช ์ ์ ๋ ฅํ๋ฉด ๋ฉ๋๋ค.
dig ๊ธฐ๋ณธ ๋ฌธ๋ฒ์ ์๋์ ๊ฐ์ต๋๋ค.
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} [...]]
์ฐ์ , www.naver.com ์ ip ์ฃผ์๋ฅผ ์๊ณ ์ถ์ ๋, ์๋์ ๊ฐ์ด ์ ๋ ฅํ๋ฉด ๋ฉ๋๋ค.
$ dig www.naver.com
; <<>> DiG 9.10.6 <<>> www.naver.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56148
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.naver.com. IN A
;; ANSWER SECTION:
www.naver.com. 21427 IN CNAME www.naver.com.nheos.com.
www.naver.com.nheos.com. 151 IN A 210.89.160.88
www.naver.com.nheos.com. 151 IN A 125.209.222.142
;; Query time: 8 msec
;; SERVER: 210.220.163.82#53(210.220.163.82)
;; WHEN: Sun May 17 21:46:54 KST 2020
;; MSG SIZE rcvd: 108
+short ์ต์ ์ ์ฃผ๋ฉด, ์ง์ ๊ฒฐ๊ณผ๋ฅผ ์งง๊ฒ ๋ณผ ์ ์์ต๋๋ค.
$ dig www.naver.com +short
www.naver.com.nheos.com.
125.209.222.142
210.89.160.88
์ฟผ๋ฆฌ ํ์ ์ง์ ์กฐํ (CNAME ๋ ์ฝ๋ ์กฐํ)
๋๋ฉ์ธ์ ์ง์ํ ๋, ์ฟผ๋ฆฌ ํ์ ์ ์ง์ ํ ์ ์์ต๋๋ค.
์ฌ๊ธฐ์๋ CNAME์ ์ง์ ํ๊ฒ ์ต๋๋ค.
$ dig www.naver.com cname
; <<>> DiG 9.10.6 <<>> www.naver.com cname
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52572
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.naver.com. IN CNAME
;; ANSWER SECTION:
www.naver.com. 18905 IN CNAME www.naver.com.nheos.com.
;; Query time: 26 msec
;; SERVER: 210.220.163.82#53(210.220.163.82)
;; WHEN: Sun May 17 21:47:18 KST 2020
;; MSG SIZE rcvd: 79
๋ฐ์ดํฐ ํ์ ์ any๋ก ์ง์ ํ ๊ฒฝ์ฐ, ํด๋น ์กด (zone)์ ์ค์ ๋ ๋ค์ํ ํ์ ์ ํ์ธํ ์ ์์ต๋๋ค.
$ dig naver.com any
; <<>> DiG 9.10.6 <<>> naver.com any
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48210
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;naver.com. IN ANY
;; ANSWER SECTION:
naver.com. 0 IN TXT "v=spf1 include:_spfblocka.naver.com include:_spfblockb.naver.com include:_spfblockc.naver.com include:_spfblockd.naver.com include:_spfblocke.naver.com include:_spfblockf.naver.com include:spf.worksmobile.com ~all"
naver.com. 0 IN TXT "google-site-verification=fK9dDFcEOeNM2Wr3xzNAN-XLcerfAGpOABdSYiqw4_s"
naver.com. 0 IN TXT "google-site-verification=TX2ZPeYhsJwJ-zQKOLMgqsTx4R5mAlBy2CjxIcl2Xgc"
naver.com. 300 IN SOA ns1.naver.com. webmaster.naver.com. 2020051502 21600 1800 1209600 180
naver.com. 51181 IN NS ns2.naver.com.
naver.com. 51181 IN NS ns1.naver.com.
;; Query time: 8 msec
;; SERVER: 210.220.163.82#53(210.220.163.82)
;; WHEN: Sun May 17 21:47:48 KST 2020
;; MSG SIZE rcvd: 508
๋ค์์๋ฒ ์ง์
@[๋ค์์๋ฒ์ด๋ฆ] ์ ํตํด ํน์ ๋ค์์๋ฒ๋ฅผ ์ ํํด ์ง์ํ ์ ์์ต๋๋ค.
ํด๋น ์ต์ ์ ์ฌ์ฉํ์ฌ ํน์ ๊ตญ๊ฐ์ cache dns ์ ์ง์๋ฅผ ํด๋ณผ ์ ์์ต๋๋ค. (์์, ์ค๊ตญ cache dns)
๊ตฌ๊ธ public dns ์ธ 8.8.8.8 ๋ฅผ ์ง์ ํ์ฌ, ์ง์ ํ ๊ฒฝ์ฐ ์๋์ ๊ฐ์ต๋๋ค.
$ dig @8.8.8.8 www.naver.com
; <<>> DiG 9.10.6 <<>> @8.8.8.8 www.naver.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27776
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.naver.com. IN A
;; ANSWER SECTION:
www.naver.com. 21182 IN CNAME www.naver.com.nheos.com.
www.naver.com.nheos.com. 10479 IN CNAME www.naver.com.edgekey.net.
www.naver.com.edgekey.net. 21539 IN CNAME e6030.a.akamaiedge.net.
e6030.a.akamaiedge.net. 19 IN A 23.46.23.18
;; Query time: 63 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sun May 17 21:53:47 KST 2020
;; MSG SIZE rcvd: 164
DNS ์ง์ ์ถ์
+trace ์ต์ ์ ํตํด root ๋ค์์๋ฒ ๋ถํฐ, ์ง์ํ ๋๋ฉ์ธ์ ๋ค์์๋ฒ๊น์ง์ ํ๋ฆ์ ํ์ธํ ์ ์์ต๋๋ค.
$ dig www.naver.com +trace
; <<>> DiG 9.10.6 <<>> www.naver.com +trace
;; global options: +cmd
. 497291 IN NS m.root-servers.net.
. 497291 IN NS l.root-servers.net.
. 497291 IN NS b.root-servers.net.
. 497291 IN NS j.root-servers.net.
. 497291 IN NS c.root-servers.net.
. 497291 IN NS d.root-servers.net.
. 497291 IN NS a.root-servers.net.
. 497291 IN NS e.root-servers.net.
. 497291 IN NS k.root-servers.net.
. 497291 IN NS g.root-servers.net.
. 497291 IN NS h.root-servers.net.
. 497291 IN NS i.root-servers.net.
. 497291 IN NS f.root-servers.net.
;; Received 251 bytes from 210.220.163.82#53(210.220.163.82) in 14 ms
com. 172800 IN NS a.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.
com. 172800 IN NS c.gtld-servers.net.
com. 172800 IN NS d.gtld-servers.net.
com. 172800 IN NS e.gtld-servers.net.
com. 172800 IN NS f.gtld-servers.net.
com. 172800 IN NS g.gtld-servers.net.
com. 172800 IN NS h.gtld-servers.net.
com. 172800 IN NS i.gtld-servers.net.
com. 172800 IN NS j.gtld-servers.net.
com. 172800 IN NS k.gtld-servers.net.
com. 172800 IN NS l.gtld-servers.net.
com. 172800 IN NS m.gtld-servers.net.
com. 86400 IN DS 30909 8 2 E2D3C916F6DEEAC73294E8268FB5885044A833FC5459588F4A9184CF C41A5766
com. 86400 IN RRSIG DS 8 1 86400 20200530050000 20200517040000 48903 . T2Y9wYpYfgrt4Eebf81byyhpG/Pbc+Q8CMeIWeKMaAjxf/emVuZqIb/r P4XDVmAhjxbe4LT/7HN8zrimSw5fFPcMCRd904dERQSJn5+NlsIZCNUw nv9IoHlzSZUUHCa8GiLPtXX4V2PA7cIlomEJ1qRk2ZEksLYWNcjklOVi Otsiy1wpx9VX0APaM8MEO1SbIgY4BsFweALU8mKBUS697XzO4cjDz+O8 tnp6rY0zF0sYsExrZlgRxX36CN6B0VnakuTBK0jVHUQBohnzBo+efPYG tWdNQ5U5ID/sa0uj6CMXhFwciJw2OTxrs057rdqq2L7GYfEYhMNpqtqG eV7vqQ==
;; Received 1173 bytes from 199.7.91.13#53(d.root-servers.net) in 159 ms
naver.com. 172800 IN NS ns2.naver.com.
naver.com. 172800 IN NS ns1.naver.com.
CK0POJMG874LJREF7EFN8430QVIT8BSM.com. 86400 IN NSEC3 1 1 0 - CK0Q1GIN43N1ARRC9OSM6QPQR81H5M9A NS SOA RRSIG DNSKEY NSEC3PARAM
CK0POJMG874LJREF7EFN8430QVIT8BSM.com. 86400 IN RRSIG NSEC3 8 2 86400 20200521044944 20200514033944 39844 com. Uq5A4YKkaCM5nGg2yT6X/Tr81YIIM+nQbFDCxKZ+TpfyIhUnuG0fL8jA lDTGAJRIZbYDObcT7eF54Y3Q4Xs+YSzyDciBppTmv1DSVQQ3M4VUwmXf 9m+UUAFyTyN8tyG42+AAHOD21j6wCbXUZhzd27JSAHfvmeLRy3WkOBn9 huGPmwnMwiD6ueYSXrIMRX+dvcqV76um4wFw/gYIsii/jw==
6P7ERTLUIGM2RTE9MP0JB6J2THEI5ARD.com. 86400 IN NSEC3 1 1 0 - 6P7H26V3O7PUHS3BBHAED1P6LBRKMDR3 NS DS RRSIG
6P7ERTLUIGM2RTE9MP0JB6J2THEI5ARD.com. 86400 IN RRSIG NSEC3 8 2 86400 20200521052504 20200514041504 39844 com. G4AlHR0LqClWuo0Scyhq2DAKauP7uSqbR5ud2Svg1rynUqLFatKdX4wp vlR+6HbHX/nZ5ORiNpX9hb1g9AKPVLiAFQ5lzlEUZ7bdhoPR2rVoK/nU jS/73wULFTpt3Eb4GjDpvTJdtmOwN1o/QvXVbyaSWGkPJQAxkEcy6eBX gSjywAhmufrnwA6HjWeQB1ROH9/TtEaUsRfkBh9zSCz73A==
;; Received 659 bytes from 192.54.112.30#53(h.gtld-servers.net) in 40 ms
www.naver.com. 21600 IN CNAME www.naver.com.nheos.com.
;; Received 76 bytes from 125.209.248.6#53(ns1.naver.com) in 9 ms
์ฌ๋ฌ ๋๋ฉ์ธ ์ง์ (ํ์ผ ์ฝ๊ธฐ)
-f ์ต์ ์ ์ฌ์ฉํ๋ฉด, ํ์ผ์ ์ ํ ๋๋ฉ์ธ๋ค์ ํ ๋ฒ์ ์ง์ํ ์ ์์ต๋๋ค.
$ cat domain_list.txt
www.naver.com
www.google.com
www.apple.com
$ dig -f domain_list.txt
; <<>> DiG 9.10.6 <<>> www.naver.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50822
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.naver.com. IN A
;; ANSWER SECTION:
www.naver.com. 21360 IN CNAME www.naver.com.nheos.com.
www.naver.com.nheos.com. 160 IN A 210.89.160.88
www.naver.com.nheos.com. 160 IN A 210.89.164.90
;; Query time: 37 msec
;; SERVER: 210.220.163.82#53(210.220.163.82)
;; WHEN: Sun May 17 22:01:30 KST 2020
;; MSG SIZE rcvd: 108
; <<>> DiG 9.10.6 <<>> www.google.com
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54003
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.google.com. IN A
;; ANSWER SECTION:
www.google.com. 294 IN A 172.217.174.100
;; Query time: 6 msec
;; SERVER: 210.220.163.82#53(210.220.163.82)
;; WHEN: Sun May 17 22:01:30 KST 2020
;; MSG SIZE rcvd: 59
; <<>> DiG 9.10.6 <<>> www.apple.com
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36643
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.apple.com. IN A
;; ANSWER SECTION:
www.apple.com. 1790 IN CNAME www.apple.com.edgekey.net.
www.apple.com.edgekey.net. 21480 IN CNAME www.apple.com.edgekey.net.globalredir.akadns.net.
www.apple.com.edgekey.net.globalredir.akadns.net. 3381 IN CNAME e6858.dsce9.akamaiedge.net.
e6858.dsce9.akamaiedge.net. 19 IN A 104.74.172.164
;; Query time: 6 msec
;; SERVER: 210.220.163.82#53(210.220.163.82)
;; WHEN: Sun May 17 22:01:30 KST 2020
;; MSG SIZE rcvd: 193