NXDOMAINだろうが、DNSサーバーからなんらかのレスポンスがあった時点で、とりあえず0が返るらしい….- 通信不能系など、明らかなエラー状態の場合のみ、非ゼロ値がリターンコードとして返る
# man dig
RETURN CODES
Dig return codes are:
0: Everything went well, including things like NXDOMAIN
1: Usage error
8: Couldn't open batch file
9: No reply from server
10: Internal error
iptablesでDNSサーバーへのパケットをdropして確認。
どうやっても、connection timed out のコメント的な出力は消せないので、grep -v ';' などとして消しましょう….
# dig @8.8.8.8 +short town.biz ;; connection timed out; no servers could be reached # dig @8.8.8.8 +noall +answer town.biz ;; connection timed out; no servers could be reached # dig +noall +answer +nocomment @8.8.8.8 town.biz ;; connection timed out; no servers could be reached # echo $? 9
+short をつけると、余計な出力がでなくなるのでよい。
# dig @8.8.8.8 +short town.biz xxx.xxx.xxx.xxx


