본문 바로가기
Computer Engineering

nslookup 과 dig 명령어 결과 차이

by ybs 2022. 1. 12.
반응형

서버에서 ybs.api.com 도메인으로 http api 를 보내다 connection timed out 에러가 발생했다. 

errorCode: connection timed out: ybs.api.com.ybs.svc.io.com/10.1.2.3:8080;
nested exception is io.netty.channel.ConnectTimeoutException: connection timed out

 

그런데 에러로그에서 ybs.api.com.ybs.svc.io.com 도메인으로 출력됐고 이해가 안가서 확인해봤다. 먼저 nslookup 으로 ybs.api.com DNS 정보를 확인했는데, ybs.api.com.ybs.svc.io.com 도메인이 DNS CNAME 으로 등록되어 있었다.

$ nslookup ybs.api.com

... (생략)

ybs.api.com.ybs.svc.io.com    canonical name = ybs.api.com.
Name:    ybs.api.com
Address: 10.1.2.3

 

더 이해가 안갔다. ybs.api.com.ybs.svc.io.com 도메인을 만든적도 없고 CNAME 으로 등록하지도 않았기 때문이다. 

그래서 dig 명령어로 정확한 결과를 확인해봤다. 그런데 dig 결과 에서는 CNAME 이 출력되지 않았다. 즉 CNAME 으로 등록된건 아니다.

$ dig ybs.api.com

... (생략)

;; QUESTION SECTION:
;ybs.api.com.	IN	A

;; ANSWER SECTION:
ybs.api.com. 300	IN	A	10.1.2.3

 

만약 진짜 CNAME 이 등록된거라면 아래와 같이 출력되야 한다.

;; ANSWER SECTION:
ybs.api.com.ybs.svc.io.com. 21600 IN CNAME ybs.api.com.

 

그렇다면 nslookup 에는 왜 저런 결과가 나왔을까? 원인은 resolv.conf search 옵션 에 있었다. 

$ cat /etc/resolv.conf 
... 생략
search ybs.svc.io.com

 

nslookup 의 경우 resolv.conf 설정에 따라 search 옵션을 적용하기 때문에, search 에 있는 ybs.svc.io.com 이 추가됐고 결국 ybs.api.com.ybs.svc.io.com 도메인이 나온것이다.

The search list is normally determined from the local domain name; by default, it contains only the local domain name. This may be changed by listing the desired domain search path following the search keyword with spaces or tabs separating the names. Resolver queries having fewer than ndots dots (default is 1) in them will be attempted using each component of the search path in turn until a match is found. For environments with multiple subdomains please read options ndots:n below to avoid man-in-the-middle attacks and unnecessary traffic for the root-dns-servers. Note that this process may be slow and will generate a lot of network traffic if the servers for the listed domains are not local, and that queries will time out if no server is available for one of the domains.

The search list is currently limited to six domains with a total of 256 characters.

 

 

반응형