プロが教えるわが家の防犯対策術!

nslookupでネームサーバNSを調べるバッチを作りたいと考えております。

【実施内容】
C:\Users\test>nslookup
既定のサーバー: xxx.xxx
Address: 192.168.1.1

> set type=NS
> google.co.jp
サーバー: xxx.xxx
Address: 192.168.1.1

権限のない回答:
google.co.jp nameserver = ns1.google.com
google.co.jp nameserver = ns2.google.com
google.co.jp nameserver = ns3.google.com
google.co.jp nameserver = ns4.google.com

ns1.google.com internet address = 216.239.32.10
ns2.google.com internet address = 216.239.34.10
ns3.google.com internet address = 216.239.36.10
ns4.google.com internet address = 216.239.38.10

と対話モードにして調べる方法を現在とっております。
対話モードにしないで、ワンライナーでns情報を取得できないでしょうか?

ご教授お願いします。

A 回答 (2件)

nslookup -type=NS google.co.jp



使い方はUnix/Linuxのnslookupと同じなので、Google検索で man nslookup を検索してください。

>"set" コマンドを使うオプションは、ホームディレクトリの .nslookuprc ファイルに 1 行に 1 つずつ書くことでも指定できます。 オプションはコマンドラインで指定することも可能です。その場合、 前にハイフンをつけ、引数より先に書きます。

この回答への補足

教えて頂いた回答で対策が出来そうです。

ありがとうございました。

補足日時:2013/01/29 23:59
    • good
    • 0

set type=NS


google.co.jp
を記述したテキストファイルを用意して、標準入力から突っ込む…なんてのもありますかねぇ。

出力はちょっとアレですが。

P:\>nslookup < a.txt
既定のサーバー: ns.local
Address: 192.168.1.250

> > サーバー: ns.local
Address: 192.168.1.250

権限のない回答:
google.co.jp nameserver = ns2.google.com
google.co.jp nameserver = ns3.google.com
google.co.jp nameserver = ns1.google.com
google.co.jp nameserver = ns4.google.com

ns1.google.com internet address = 216.239.32.10
ns2.google.com internet address = 216.239.34.10
ns3.google.com internet address = 216.239.36.10
ns4.google.com internet address = 216.239.38.10
>
P:\>


というか、バッチで動かすなら引数で指定するのが本道でしょう…。
    • good
    • 0
この回答へのお礼

>set type=NS
google.co.jp
を記述したテキストファイルを用意して、標準入力から突っ込む…なんてのもありますかねぇ。

なるほど。別ファイルからの読み込みも可能なのですね。
参考になりました。
ありがとうございました。

お礼日時:2013/01/30 00:00

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!