LoginSignup
6
8

More than 5 years have passed since last update.

digコマンドでドメイン名からIPの割り出し/IPからドメイン名の割り出し

Posted at

TL;DR

DNSサーバーが正常動作しているか確認したい。
dig コマンドでドメイン名からIPの割り出しと逆アドレス変換を行う。

# domain name => IP
dig <domain name>

# IP => domain name
dig <IP address>

実行例

ドメインからIPを調べる

ドメインからIPを調べる例
$ dig www.google.co.jp

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> www.google.co.jp
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10697
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 5

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.google.co.jp.              IN      A

;; ANSWER SECTION:
www.google.co.jp.       201     IN      A       216.58.197.195

;; AUTHORITY SECTION:
google.co.jp.           43171   IN      NS      ns2.google.com.
google.co.jp.           43171   IN      NS      ns3.google.com.
google.co.jp.           43171   IN      NS      ns4.google.com.
google.co.jp.           43171   IN      NS      ns1.google.com.

;; ADDITIONAL SECTION:
ns1.google.com.         129488  IN      A       216.239.32.10
ns2.google.com.         129488  IN      A       216.239.34.10
ns3.google.com.         129488  IN      A       216.239.36.10
ns4.google.com.         129488  IN      A       216.239.38.10

;; Query time: 76 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Sun Apr 24 22:13:36 JST 2016
;; MSG SIZE  rcvd: 207

IPからドメインを調べる

IPからドメインを調べる例
$ dig -x 216.58.197.195

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> -x 216.58.197.195
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33430
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 5

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;195.197.58.216.in-addr.arpa.   IN      PTR

;; ANSWER SECTION:
195.197.58.216.in-addr.arpa. 84600 IN   PTR     nrt13s48-in-f3.1e100.net.

;; AUTHORITY SECTION:
197.58.216.in-addr.arpa. 45233  IN      NS      ns3.google.com.
197.58.216.in-addr.arpa. 45233  IN      NS      ns1.google.com.
197.58.216.in-addr.arpa. 45233  IN      NS      ns4.google.com.
197.58.216.in-addr.arpa. 45233  IN      NS      ns2.google.com.

;; ADDITIONAL SECTION:
ns1.google.com.         133902  IN      A       216.239.32.10
ns2.google.com.         130335  IN      A       216.239.34.10
ns3.google.com.         131156  IN      A       216.239.36.10
ns4.google.com.         133902  IN      A       216.239.38.10

;; Query time: 76 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Sun Apr 24 22:13:50 JST 2016
;; MSG SIZE  rcvd: 240

参考

Linuxコマンド集 - 【 dig 】 ドメイン情報をDNSサーバーから取得する:ITpro
digコマンド 使い方 オプション DNS BIND

6
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
8