DNS 명령어 · 3 min read · Sep 08, 2025

리눅스에서 dig 명령어를 사용하여 DNS 도메인 이름 해결하기

dig 명령어는 “Domain Information Groper”의 약자로, DNS (Domain Name System) 서버를 쿼리하는 데 사용되는 네트워크 관리 도구입니다. 이 도구는 사용자가 도메인 이름에 대한 정보, 예를 들어 IP 주소, 메일 서버(MX 레코드) 및 기타 DNS 리소스 레코드를 검색할 수 있게 해줍니다. 주로 DNS 문제를 해결하는 데 사용되며, dig는 쿼리의 응답 시간과 정보를 제공한 DNS 서버를 포함한 자세한 출력을 제공합니다. 그 유연성과 정확성 덕분에 네트워크 관리자들 사이에서 DNS 문제 진단, 도메인 구성 테스트 및 DNS 조회를 수행하는 데 선호되는 도구입니다. nslookup과 같은 더 기본적인 명령어에 비해.

dig 명령어를 사용하여 도메인 이름 해결하기

도메인 example.com 해결하기:

dig example.com

도메인이 해결될 수 있다면 결과는 다음과 유사할 것입니다:

root@server1:~# dig howtoforge.com  
  
; <<>> DiG 9.11.3-1ubuntu1.1-Ubuntu <<>> howtoforge.com  
;; global options: +cmd  
;; Got answer:  
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50297  
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1  
  
;; OPT PSEUDOSECTION:  
; EDNS: version: 0, flags:; udp: 512  
;; QUESTION SECTION:  
;howtoforge.com. IN A  
  
;; ANSWER SECTION:  
howtoforge.com. 299 IN A 104.24.0.68  
howtoforge.com. 299 IN A 104.24.1.68  
  
;; Query time: 233 msec  
;; SERVER: 8.8.8.8#53(8.8.8.8)  
;; WHEN: Wed Aug 08 12:35:15 CEST 2024  
;; MSG SIZE rcvd: 75

dig로 로컬 DNS 서버 쿼리하기

로컬 웹 서버가 이 도메인에 대한 책임이 있는지 확인하려면 다음 명령어를 사용하세요:

dig @localhost example.com

dig로 메일 서버 이름 가져오기

example.com의 메일을 처리하는 메일 서버가 무엇인지 알고 싶다면 다음 명령어를 사용할 수 있습니다:

dig MX example.com

결과는 다음과 유사할 것입니다:

root@server1:~# dig MX howtoforge.com  
  
; <<>> DiG 9.11.3-1ubuntu1.1-Ubuntu <<>> MX howtoforge.com  
;; global options: +cmd  
;; Got answer:  
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14115  
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1  
  
;; OPT PSEUDOSECTION:  
; EDNS: version: 0, flags:; udp: 512  
;; QUESTION SECTION:  
;howtoforge.com. IN MX  
  
;; ANSWER SECTION:  
howtoforge.com. 299 IN MX 10 mail.howtoforge.com.  
  
;; Query time: 205 msec  
;; SERVER: 8.8.4.4#53(8.8.4.4)  
;; WHEN: Wed Aug 08 10:36:30 CEST 2024  
;; MSG SIZE rcvd: 64

dig 명령어의 더 많은 옵션 가져오기

dig 명령어의 모든 사용 가능한 옵션을 보려면 다음을 실행할 수 있습니다:

dig --help

더 자세한 설명은 dig 명령어의 매뉴얼 페이지에서 확인할 수 있습니다:

man dig

다음은 도구의 매뉴얼 페이지에서 발췌한 내용으로, dig를 사용하는 방법을 명확하게 설명합니다:

A typical invocation of dig looks like:  
  
dig @server name type  
  
where:  
  
 server  
     is the name or IP address of the name server to query. This can be an IPv4 address in   
     dotted-decimal notation or an IPv6 address in colon-delimited notation. When the supplied   
     server argument is a hostname, dig resolves that name before querying that name server.  
  
     If no server argument is provided, dig consults /etc/resolv.conf; if an address is found   
     there, it queries the name server at that address. If either of the -4 or -6 options are in   
     use, then only addresses for the corresponding transport will be tried. If no usable addresses  
     are found, dig will send the query to the local host. The reply from the name server that   
     responds is displayed.  
  
 name  
     is the name of the resource record that is to be looked up.  
  
 type  
     indicates what type of query is required — ANY, A, MX, SIG, etc.  type can be any valid query  
     type. If no type argument is supplied, dig will perform a lookup for an A record.

원하는 경우 dig 명령어가 출력 표시에서 특정 섹션을 제거하도록 강제할 수 있습니다. 예를 들어, 출력에서 주석 줄이나 쿼리의 질문 섹션을 토글하려면 +nocomments+noquestion 옵션을 사용하세요.

다음 스크린샷은 이러한 옵션이 작동하는 모습을 보여줍니다:

Dig 명령어 nocomments 옵션

도메인의 네임 서버 가져오기

계속해서, dig 명령어를 통해 MX 레코드처럼 NS 레코드를 쿼리할 수 있습니다. 다음은 그 방법입니다:

dig NS example.com

다음은 이 명령어가 우리 경우에 생성한 출력입니다:

dig로 도메인의 네임 서버 가져오기

dig 명령어로 도메인 이름의 IP 주소 가져오기

서버의 IP 주소만 표시하도록 dig를 원한다면 +short 옵션을 사용하세요.

예를 들어:

dig example.com +short

한 번에 여러 웹사이트/서버를 쿼리하려면 파일에 이름 목록을 만들고, 해당 파일의 이름을 dig 명령어의 -f 옵션에 입력으로 전달할 수 있습니다.

-f file  
  
Batch mode: dig reads a list of lookup requests to process from the given file. Each line in the   
file should be organized in the same way they would be presented as queries to dig using the   
command-line interface.

다음은 예시입니다:

Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.