최신 리눅스는 host 명령어 를 사용하는 것을 권장하고 있습니다.


nslookup 은 name server 관련한 조회를 할 수 있는 명령어이다. 서버의 네트워크가 제대로 설정되었는지 확인하는 용도로도 사용하는데 자주 쓰는 명령어가 아니다 보니 사용법을 잊어버려서 용도별 nslookup 명령을 정리해 본다.

기본 사용법

IP 조회

nslookup 명령어 뒤에 조회하려는 도메인을 지정. 예로 아래는 google.com 의 IP 를 출력

$ nslookup google.com

Server:         192.168.152.2
Address:        192.168.152.2#53
Non-authoritative answer:
Name:   google.com
Address: 58.229.92.103
Name:   google.com
Address: 58.229.92.88
BASH


MX(Mail Record) 확인

$ nslookup -query=mx google.com

Server:         192.168.152.2
Address:        192.168.152.2#53
Non-authoritative answer:
google.com      mail exchanger = 20 alt1.aspmx.l.google.com.
google.com      mail exchanger = 30 alt2.aspmx.l.google.com.
google.com      mail exchanger = 40 alt3.aspmx.l.google.com.
google.com      mail exchanger = 10 aspmx.l.google.com.
google.com      mail exchanger = 50 alt4.aspmx.l.google.com.
Authoritative answers can be found from:
BASH


CNAME 조회

Canonical Name 필드를 조회할 경우 -q=cname 옵션 사용

$  nslookup -q=cname example.com
BASH


TEXT 조회

Domain validation 이나 SPF(Sender Policy Framework) 설정시 사용하는 TEXT 필드 조회

$  nslookup -q=txt gmail.com
BASH


NS 레코드로 DNS 목록 확인

$ nslookup -type=ns google.com 

Server:         192.168.152.2
Address:        192.168.152.2#53
Non-authoritative answer:
google.com      nameserver = ns1.google.com.
google.com      nameserver = ns3.google.com.
google.com      nameserver = ns2.google.com.
google.com      nameserver = ns4.google.com.
Authoritative answers can be found from:
BASH


그외

Reverse DNS lookup

IP 로 Domain Name 을 찾는 기능이다. 옵션으로 -type=ptr 를 준 것과 동일하며 찾는 주소가 IP 경우 nslookup 이 자동으로 -type=ptr 을 설정해서 검색하는 듯 하다. 찾으려는 서버가 속한 DNS의 설정에 PTR 항목이 설정되어 있어야 조회가 가능하다.

$ nslookup 209.132.183.181

Server:         192.168.152.2
Address:        192.168.152.2#53
Non-authoritative answer:
181.183.132.209.in-addr.arpa    name = origin-www2.redhat.com.
Authoritative answers can be found from:
BASH

특정 DNS 사용하여 조회

기본 설정된 DNS 가 아닌 외부의 DNS 를 지정해서 조회할 수 있다. 지정할 DNS 는 조회할 도메인 이름 뒤에 써주면 된다. 다음은 구글의 공개 DNS 인 8.8.8.8 을 사용하여 조회하는 예제이다

$ nslookup redhat.com 8.8.8.8

Server:         8.8.8.8
Address:        8.8.8.8#53
Non-authoritative answer:
Name:   redhat.com
Address: 209.132.183.105
BASH

KT 의 Name Server 를 사용할 경우 168.126.63.1 를 사용한다.

$ gmail.com 168.126.63.1

Server:         168.126.63.1
Address:        168.126.63.1#53

Non-authoritative answer:
Name:   gmail.com
Address: 216.58.197.165
Name:   gmail.com
Address: 2404:6800:4004:81e::2005
BASH

같이 보기

Ref