본문 바로가기
리눅스

DNS dig로 역방향확인하기

by 혜룐 2015. 11. 10.

lhr@Sch-Sysng:/lhr># dig test.com
;<<>>DiG 9.3.4-P1<<>>test.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42794
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 0
;; QUESTION SECTION:
;test.com. IN A -->A는 도메인에 아이피를 부여하는 레코드
;; ANSWER SECTION:
test.com. 346 IN A 203.226.253.11 -->A는 도메인에 아이피 응답 확인 할수있음
;; AUTHORITY SECTION:
test.com. 582 IN NS ns2.test.com.
test.com. 582 IN NS ns3.test.com.
test.com. 582 IN NS ns1.test.com. ->3개의 인증 DNS가 있다(DNS 분산)
;; Query time: 1 msec
;; SERVER: 192.168.11.6#53(192.168.11.6)
;; WHEN: Thu Sep 9 13:18:36 2010
;; MSG SIZE rcvd: 96
* 해당 도메인의 아이피를 알았다.
리버스가 되어있는지 확인해보자.
lhr@Sch-Sysng:/lhr># dig -x 203.226.253.11 short -->아무것도 뜨지않으면 리버스 도메인 설정안된것
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 14281
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;11.253.226.203.in-addr.arpa. IN PTR ->없다! 고로 SOA 쪽에 인버스 요청헤야한다.
;; AUTHORITY SECTION:
253.226.203.in-addr.arpa. 3600 IN SOA ns1.s.com. lhr.ns1.s.com. 2009050700 3600 1800 604800 86400
;; Query time: 13 msec
;; SERVER: 192.168.11.6#53(192.168.11.6)
;; WHEN: Thu Sep 9 13:18:47 2010
;; MSG SIZE rcvd: 110
;<<>>DiG 9.3.4-P1<<>>-x 203.226.253.11 short
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 56970
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;short. IN A
;; AUTHORITY SECTION:
. 9074 IN SOA a.lhr-servers.net. nstld.verisign-grs.com. 2010090801 1800 900 604800 86400
;; Query time: 0 msec
;; SERVER: 192.168.11.6#53(192.168.11.6)
;; WHEN: Thu Sep 9 13:18:47 2010
;; MSG SIZE rcvd: 98
* 위임 순서를 다시 확인
lhr@Sch-Sysng:/lhr># dig -x 203.226.253.11 +trace
;<<>>DiG 9.3.4-P1<<>>-x 203.226.253.11 +trace
;; global options: printcmd
. 190332 IN NS a.lhr-servers.net.
. 190332 IN NS b.lhr-servers.net.
. 190332 IN NS c.lhr-servers.net.
. 190332 IN NS d.lhr-servers.net.
. 190332 IN NS e.lhr-servers.net.
. 190332 IN NS f.lhr-servers.net.
. 190332 IN NS g.lhr-servers.net.
. 190332 IN NS h.lhr-servers.net.
. 190332 IN NS i.lhr-servers.net.
. 190332 IN NS j.lhr-servers.net.
. 190332 IN NS k.lhr-servers.net.
. 190332 IN NS l.lhr-servers.net.
. 190332 IN NS m.lhr-servers.net.
;; Received 468 bytes from 192.168.11.6#53(192.168.11.6) in 16 ms
203.in-addr.arpa. 86400 IN NS SEC1.AUTHDNS.RIPE.NET.
203.in-addr.arpa. 86400 IN NS NS3.APNIC.NET.
203.in-addr.arpa. 86400 IN NS DNS1.TELSTRA.NET.
203.in-addr.arpa. 86400 IN NS NS1.APNIC.NET.
203.in-addr.arpa. 86400 IN NS NS4.APNIC.NET.
203.in-addr.arpa. 86400 IN NS TINNIE.ARIN.NET.
;; Received 193 bytes from 198.41.0.4#53(a.lhr-servers.net) in 138 ms
226.203.in-addr.arpa. 86400 IN NS f.dns.kr.
226.203.in-addr.arpa. 86400 IN NS b.dns.kr.
226.203.in-addr.arpa. 86400 IN NS g.dns.kr.
226.203.in-addr.arpa. 86400 IN NS c.dns.kr.
226.203.in-addr.arpa. 86400 IN NS d.dns.kr.
226.203.in-addr.arpa. 86400 IN NS e.dns.kr.
;; Received 147 bytes from 193.0.9.3#53(SEC1.AUTHDNS.RIPE.NET) in 293 ms
253.226.203.in-addr.arpa. 43200 IN NS NS2.s.com.
253.226.203.in-addr.arpa. 43200 IN NS NS1.s.com.
253.226.203.in-addr.arpa. 43200 IN NS NS4.s.com.
253.226.203.in-addr.arpa. 43200 IN NS NS3.s.com.
;; Received 137 bytes from 218.38.181.90#53(f.dns.kr) in 1 ms
253.226.203.in-addr.arpa. 3600 IN SOA ns1.s.com. lhr.ns1.s.com. 2009050700 3600 1800 604800 86400
;; Received 110 bytes from 124.137.97.18#53(NS4.s.com) in 3 ms
lhr@Sch-Sysng:/lhr># nslookup -type=ptr 203.226.253.11 ->이렇게 에러가뜨면 리버스 도메인 설정안된것
Server: 192.168.11.6
Address: 192.168.11.6#53
** server can't find 11.253.226.203.in-addr.arpa: NXDOMAIN
인버스 도메인은 IP에 대해 해당 도메인을 역으로 찾을 수 있도록 하는 서비스이다. 보통 ISP(Internet Service Provider)에서 IP를 할당받을 때 같이 신청한다. 다음과 같이 인버스 도메인에 대한 네임서버가 in-addr.arpa 네임스페이스에 등록되어 있는지 확인한다.
$ nslookup -type=ns 253.226.203.in-addr.arpa. (C Class 로 할당받았을경우)
ㄱ) 인버스확인!
lhr@Sch-Sysng:/lhr># nslookup -type=ns 253.226.203.in-addr.arpa. Server: 192.168.11.6Address: 192.168.11.6#53
253.226.203.in-addr.arpa nameserver = ns1.s.com.253.226.203.in-addr.arpa nameserver = ns2.s.com.253.226.203.in-addr.arpa nameserver = ns3.s.com.253.226.203.in-addr.arpa nameserver = ns4.s.com.
lhr@Sch-Sysng:/lhr># 
ㄴ) 인버스 에러
Server: ns.nobreak.com
Address: 0.0.0.0
79.105.210.in-addr.arpa nameserver = ns.nobreak.com
79.105.210.in-addr.arpa nameserver = ns2.nobreak.com
ns.nobreak.com internet address = 210.105.79.2
ns2.nobreak.com internet address = 210.105.79.3
만약 다음과 같은 메시지가 나온다면, 인버스 도메인 등록이 안되어 있는 것이므로, 해당 ISP에 신청하여야 한다.
*** ns.nobreak.com can't find 79.105.210.in-addr.arpa.: Non-existent host/domain
해당 아이피가 상위기관 어디서 위임받는지 확인해보자
lhr@Sch-Sysng:/lhr># dig -x 203.226.253.11 
;<<>>DiG 9.3.4-P1<<>>-x 203.226.253.11
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 25235
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;11.253.226.203.in-addr.arpa. IN PTR
;; AUTHORITY SECTION:
253.226.203.in-addr.arpa. 3600 IN SOA ns1.s.com. lhr.ns1.s.com. 2009050700 3600 1800 604800 86400
;; Query time: 0 msec
;; SERVER: 192.168.11.6#53(192.168.11.6)
;; WHEN: Thu Sep 9 13:21:15 2010
;; MSG SIZE rcvd: 110
;; AUTHORITY SECTION: -->이 부분에 서 SOA를 받는것인데 리버스 도메인 셋팅 요청을 하면 된다.
253.226.203.in-addr.arpa. 3600 IN SOA ns1.s.com. lhr.ns1.s.com. 2009050700 3600 1800 604800 86400