GNU/Linux >> Linux の 問題 >  >> Linux

10 Linux nslookup コマンドの DNS ルックアップの例

nslookup は、ドメイン ネーム システム (DNS) にクエリを実行して、ドメイン名または IP アドレスのマッピング、またはその他の特定の DNS レコードを取得するためのネットワーク管理ツールです。

また、DNS 関連の問題のトラブルシューティングにも使用されます。この記事では、nslookup コマンドの使用例をいくつか紹介します。

nslookup は、「対話モード」と「非対話モード」の両方で動作します。インタラクティブ モードでは、ユーザーはさまざまなホストやドメインについて DNS サーバーに問い合わせることができます。非対話モードでは、ユーザーはホストまたはドメインの情報を照会できます。この記事で説明するコマンドはすべて「非対話モード」です。

1. nslookup – 簡単な例

nslookup の後にドメイン名を入力すると、ドメインの「A レコード」(IP アドレス) が表示されます。

$ nslookup redhat.com

Server:		192.168.19.2
Address:	192.168.19.2#53

Non-authoritative answer:
Name:	redhat.com
Address: 209.132.183.181

上記の出力で、server は DNS サーバーの IP アドレスを指します。次に、以下のセクションは、ドメイン「redhat.com」の「A レコード」(IP アドレス) を提供します。

nslookup コマンドのデフォルトの出力は、dig コマンドのデフォルトの出力よりもすっきりしています。 DNS ルックアップに dig コマンドを使い慣れている人もいるでしょう。

2. -query=mx

を使用して MX レコードをクエリします。

MX ( Mail Exchange ) レコードは、ドメイン名をそのドメインのメール交換サーバーのリストにマップします。 MX レコードは、「@redhat.com」に送信されたすべてのメールがそのドメインのメール サーバーにルーティングされる必要があることを示しています。

$ nslookup -query=mx redhat.com
Server:		192.168.19.2
Address:	192.168.19.2#53

Non-authoritative answer:
redhat.com	mail exchanger = 10 mx2.redhat.com.
redhat.com	mail exchanger = 5 mx1.redhat.com.

Authoritative answers can be found from:
mx2.redhat.com	internet address = 66.187.233.33
mx1.redhat.com	internet address = 209.132.183.28

上記の例では、ドメイン「redhat.com」に 2 つの MX レコードがあります。 MX レコードに関連付けられた数字 ( 5, 10 ) は、メール サーバーの設定を示します。数値が小さいほど優先度が高くなります。したがって、「@redhat.com」にメールが送信されると、最初に「mx1.redhat.com」が優先され、次に「mx2.redhat.com」が優先されます。

信頼できる回答と信頼できない回答

また、上記の出力で「権威ある回答」と「権威のない回答」というキーワードに気づいたかもしれません。

ドメインで利用可能な完全なゾーン ファイル情報を持つ DNS サーバーからの応答は、信頼できる応答と呼ばれます。

多くの場合、DNS サーバーには、特定のドメインで利用できる完全なゾーン ファイル情報がありません。代わりに、信頼できる応答を得た過去に実行されたすべてのクエリの結果を含むキャッシュ ファイルを維持します。 DNS クエリが与えられると、キャッシュ ファイルを検索し、利用可能な情報を「権限のない回答」として返します。

3. -query=ns を使用して NS レコードをクエリします

NS ( Name Server ) レコードは、ドメイン名を、そのドメインに対して権限のある DNS サーバーのリストにマップします。指定されたドメインに関連付けられているネーム サービスを出力します。

nslookup -type=ns redhat.com
Server:		192.168.19.2
Address:	192.168.19.2#53

Non-authoritative answer:
redhat.com	nameserver = ns4.redhat.com.
redhat.com	nameserver = ns2.redhat.com.
redhat.com	nameserver = ns1.redhat.com.
redhat.com	nameserver = ns3.redhat.com.

Authoritative answers can be found from:
ns4.redhat.com	internet address = 209.132.188.218
ns2.redhat.com	internet address = 209.132.183.2
ns1.redhat.com	internet address = 209.132.186.218
ns3.redhat.com	internet address = 209.132.176.100

4. -query=soa を使用して SOA レコードを照会します

SOA レコード (権限の開始) は、ドメインに関する正式な情報、ドメイン管理者の電子メール アドレス、ドメインのシリアル番号などを提供します…

$ nslookup -type=soa redhat.com
Server:		192.168.19.2
Address:	192.168.19.2#53

Non-authoritative answer:
redhat.com
	origin = ns1.redhat.com
	mail addr = noc.redhat.com
	serial = 2012071601
	refresh = 300
	retry = 180
	expire = 604800
	minimum = 14400

Authoritative answers can be found from:
ns1.redhat.com	internet address = 209.132.186.218
  • mail addr – ドメイン管理者 ( [email protected] ) のメールアドレスを指定します
  • serial – リビジョン番号付けシステムの一種。標準的な規則では、「YYYYMMYYNN」形式を使用します。 (2012-07-16.01 は、同じ日に複数の編集が行われた場合、増分されます)
  • refresh – シリアル番号が増加したかどうかを確認するために、セカンダリ DNS がプライマリ DNS をポーリングするタイミング (秒単位) を指定します。増加すると、セカンダリは新しいゾーン ファイルをコピーするための新しいリクエストを作成します。
  • retry – プライマリ DNS に再接続する間隔を指定します
  • expire – セカンダリ DNS がキャッシュされたゾーン ファイルを有効として保持する時間を指定します
  • minimum – セカンダリ DNS がゾーン ファイルをキャッシュする時間を指定します

5. -query=any を使用して利用可能な DNS レコードを表示

-query=any オプションを使用して、利用可能なすべての DNS レコードを表示することもできます。

$ nslookup -type=any google.com
Server:		192.168.19.2
Address:	192.168.19.2#53

Non-authoritative answer:
Name:	google.com
Address: 173.194.35.7
Name:	google.com
Address: 173.194.35.8

google.com	nameserver = ns1.google.com.
google.com	nameserver = ns2.google.com.
google.com
	origin = ns1.google.com
	mail addr = dns-admin.google.com
	serial = 2012071701
	refresh = 7200
	retry = 1800
	expire = 1209600
	minimum = 300
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 = 50 alt4.aspmx.l.google.com.
google.com	mail exchanger = 10 aspmx-v4v6.l.google.com.
google.com	has AAAA address 2a00:1450:4002:801::1004

Authoritative answers can be found from:
ns4.google.com	internet address = 216.239.38.10
ns3.google.com	internet address = 216.239.36.10

6.逆引き DNS ルックアップ

IP アドレスを引数として nslookup に指定することで、逆引き DNS ルックアップを実行することもできます。

$ nslookup 209.132.183.181
Server:		192.168.19.2
Address:	192.168.19.2#53

Non-authoritative answer:
181.183.132.209.in-addr.arpa	name = origin-www2.redhat.com.

7.特定の DNS サーバーの使用

クエリにデフォルトの DNS サーバーを使用する代わりに、特定のネーム サーバーを指定してドメイン名を解決することもできます。

$ nslookup redhat.com ns1.redhat.com

Server:		209.132.186.218
Address:	209.132.186.218#53

Name:	redhat.com
Address: 209.132.183.181

上記のコマンドでは、ns1.redhat.com を DNS サーバーとして使用しました。ここで、ns1.redhat.com には redhat.com のすべてのゾーン情報があるため、"Non-authoritative answer:" ヘッダーが取得されないことに気付くかもしれません

8.接続するポート番号を変更

デフォルトでは、DNS サーバーはポート番号 53 を使用します。何らかの理由でポート番号が変更された場合は、-port オプションを使用してポート番号を指定できます

$ nslookup -port 56 redhat.com

9.タイムアウト間隔を変更して応答を待つ

-timeout オプションを使用して、応答を待つデフォルトのタイムアウトを変更できます。

$ nslookup -timeout=10 redhat.com

10. -debug を使用してデバッグ モードを有効にする

コマンドラインで -debug オプションを使用して、デバッグのオン/オフを切り替えることができます

$ nslookup -debug redhat.com
Server:		192.168.19.2
Address:	192.168.19.2#53

------------
    QUESTIONS:
	redhat.com, type = A, class = IN
    ANSWERS:
    ->  redhat.com
	internet address = 209.132.183.181
	ttl = 5
    AUTHORITY RECORDS:
    ADDITIONAL RECORDS:
------------
Non-authoritative answer:
Name:	redhat.com
Address: 209.132.183.181

デバッグ モードでは、検索中にパケット情報が表示されます。

nslookup コマンドと同様に、dig コマンドを使用して DNS 情報を照会することもできます。


Linux
  1. 初心者向けのLinuxkillallコマンド(8例)

  2. nslookupコマンド:7つの実用的な例

  3. 17 HP サーバー上の Linux での hpacucli コマンドの例

  1. Linuxユーザー向けの12のIPコマンド例

  2. Linux初心者向けの10の「rm」コマンド例

  3. LinuxでのDigコマンド(DNSルックアップ)

  1. 初心者向けのLinuxdirコマンド(10例)

  2. 初心者向けのLinuxrmコマンドの説明(8例)

  3. 初心者向けのLinuxlnコマンドチュートリアル(5つの例)