DNSルックアップのトラブルシューティングのための8つのLinux Nslookupコマンド
nslookupは、DNSサーバー(ドメインネームサーバー)のテストとトラブルシューティングのためのコマンドライン管理ツールです。これは特定のDNSリソースレコード(RR)を問い合わせるためにも使用されます。ほとんどのオペレーティングシステムには、組み込みのnslookup機能が備わっています。
この記事では、広く使用されているnslookupコマンドについて詳しく説明します。nslookupは、インタラクティブモードと非インタラクティブモードの2つのモードで実行できます。
インタラクティブモードは、さまざまなドメインやホストについてDNSサーバーに問い合わせるために使用されます。非インタラクティブモードは、ドメインまたはホストの情報について問い合わせるために使用されます。
以下の記事にもご興味があるかもしれません:
- Linuxのfindコマンドの実用的な例 35選
- Linuxネットワーク管理のための20のNetstatコマンド
- パッケージ管理のための20のLinux YUM(Yellowdog Updater, Modified)コマンド
- LinuxにおけるRPMパッケージ管理のための27の「DNF」(Yumのフォーク)コマンド
1. ドメインの「A」レコード(IPアドレス)を見つける
# nslookup yahoo.com
Server: 4.2.2.2
Address: 4.2.2.2#53
Non-authoritative answer:
Name: yahoo.com
Address: 72.30.38.140
Name: yahoo.com
Address: 98.139.183.24
Name: yahoo.com
Address: 209.191.122.70上記のコマンドは、4.2.2.2のパブリックDNSサーバーを使ってwww.yahoo.comのクエリドメインを実行し、以下のセクションには非認証応答が表示されます:www.yahoo.comのAレコードが表示されます。
2. リバースドメインルックアップを調べる
# nslookup 209.191.122.70
Server: 4.2.2.2
Address: 4.2.2.2#53
Non-authoritative answer:
70.122.191.209.in-addr.arpa name = ir1.fp.vip.mud.yahoo.com.
Authoritative answers can be found from:3. 特定のドメインルックアップを見つける。
# nslookup ir1.fp.vip.mud.yahoo.com.
Server: 4.2.2.2
Address: 4.2.2.2#53
Non-authoritative answer:
Name: ir1.fp.vip.mud.yahoo.com
Address: 209.191.122.704. MX(メール交換)レコードを照会する。
# nslookup -query=mx www.yahoo.com
Server: 4.2.2.2
Address: 4.2.2.2#53
Non-authoritative answer:
www.yahoo.com canonical name = fd-fp3.wg1.b.yahoo.com.
fd-fp3.wg1.b.yahoo.com canonical name = ds-fp3.wg1.b.yahoo.com.
ds-fp3.wg1.b.yahoo.com canonical name = ds-any-fp3-lfb.wa1.b.yahoo.com.
ds-any-fp3-lfb.wa1.b.yahoo.com canonical name = ds-any-fp3-real.wa1.b.yahoo.com.
Authoritative answers can be found from:
wa1.b.yahoo.com
origin = yf1.yahoo.com
mail addr = hostmaster.yahoo-inc.com
serial = 1344827307
refresh = 30
retry = 30
expire = 86400
minimum = 1800
MXレコードは、ドメイン名をそのドメインのメール交換サーバーのリストにマッピングするために使用されています。そのため、@yahoo.comに送信されたり受信されたりするメールは、メールサーバーにルーティングされることを示しています。
5. NS(ネームサーバー)レコードをクエリすること。
# nslookup -query=ns www.yahoo.com
Server: 4.2.2.2
Address: 4.2.2.2#53
Non-authoritative answer:
www.yahoo.com canonical name = fd-fp3.wg1.b.yahoo.com.
fd-fp3.wg1.b.yahoo.com canonical name = ds-fp3.wg1.b.yahoo.com.
ds-fp3.wg1.b.yahoo.com canonical name = ds-any-fp3-lfb.wa1.b.yahoo.com.
ds-any-fp3-lfb.wa1.b.yahoo.com canonical name = ds-any-fp3-real.wa1.b.yahoo.com.
Authoritative answers can be found from:
wa1.b.yahoo.com
origin = yf1.yahoo.com
mail addr = hostmaster.yahoo-inc.com
serial = 1344827782
refresh = 30
retry = 30
expire = 86400
minimum = 18006. SOA(権威の開始)レコードを問い合わせる。
# nslookup -type=soa www.yahoo.com
Server: 4.2.2.2
Address: 4.2.2.2#53
Non-authoritative answer:
www.yahoo.com canonical name = fd-fp3.wg1.b.yahoo.com.
fd-fp3.wg1.b.yahoo.com canonical name = ds-fp3.wg1.b.yahoo.com.
ds-fp3.wg1.b.yahoo.com canonical name = ds-any-fp3-lfb.wa1.b.yahoo.com.
ds-any-fp3-lfb.wa1.b.yahoo.com canonical name = ds-any-fp3-real.wa1.b.yahoo.com.
Authoritative answers can be found from:
wa1.b.yahoo.com
origin = yf1.yahoo.com
mail addr = hostmaster.yahoo-inc.com
serial = 1344827965
refresh = 30
retry = 30
expire = 86400
minimum = 18007. すべての利用可能なDNSレコードをクエリする。
# nslookup -query=any yahoo.com
Server: 4.2.2.2
Address: 4.2.2.2#53
Non-authoritative answer:
yahoo.com
origin = ns1.yahoo.com
mail addr = hostmaster.yahoo-inc.com
serial = 2012081016
refresh = 3600
retry = 300
expire = 1814400
minimum = 600
Name: yahoo.com
Address: 98.139.183.24
Name: yahoo.com
Address: 209.191.122.70
Name: yahoo.com
Address: 72.30.38.140
yahoo.com mail exchanger = 1 mta7.am0.yahoodns.net.
yahoo.com mail exchanger = 1 mta5.am0.yahoodns.net.
yahoo.com mail exchanger = 1 mta6.am0.yahoodns.net.
yahoo.com nameserver = ns3.yahoo.com.
yahoo.com nameserver = ns4.yahoo.com.
yahoo.com nameserver = ns2.yahoo.com.
yahoo.com nameserver = ns8.yahoo.com.
yahoo.com nameserver = ns1.yahoo.com.
yahoo.com nameserver = ns6.yahoo.com.
yahoo.com nameserver = ns5.yahoo.com.
Authoritative answers can be found from:8. デバッグモードを有効にする
デバッグモードを有効にするには、「set debug」と入力すると、TTLなどの詳細情報が得られます。こちらが出力結果です。
# nslookup -debug yahoo.com
> set debug
> yahoo.com
Server: 4.2.2.2
Address: 4.2.2.2#53
------------
QUESTIONS:
yahoo.com, type = A, class = IN
ANSWERS:
-> yahoo.com
internet address = 72.30.38.140
ttl = 1523
-> yahoo.com
internet address = 98.139.183.24
ttl = 1523
-> yahoo.com
internet address = 209.191.122.70
ttl = 1523
AUTHORITY RECORDS:
ADDITIONAL RECORDS:
------------
Non-authoritative answer:
Name: yahoo.com
Address: 72.30.38.140
Name: yahoo.com
Address: 98.139.183.24
Name: yahoo.com
Address: 209.191.122.70この記事では、DNS(ドメインネームサービス)関連の情報を検索するのに役立つ可能性のあるnslookupコマンドについて説明しました。
次の記事は、nslookupに似たLinuxのdigコマンドについてです。この記事が気に入ったら、友達と共有してください。また、コメントボックスを通じて貴重なフィードバックを忘れずにお寄せください。