dig
ネットワーク
書き方
dig [@server] <name> [type]DNS サーバーに直接尋ねて記録をそのまま見せます。/etc/hosts と系のキャッシュを飛ばすため、ブラウザーが見るものと違うことがあり、配布物によっては dnsutils か bind-utils の導入が必要です。
よく使うオプション
| オプション | 意味 |
|---|---|
| +short | Just the answer, one record per line. |
| @1.1.1.1 | Ask a specific resolver instead of the system one. |
| A / AAAA / MX / TXT / NS / CNAME | The record type goes last, with no dash. |
| +noall +answer | Trim the output to the answer section only. |
| -x <ip> | Reverse lookup, address to name. |
| +trace | Walk down from the root servers, which shows where a delegation breaks. |
| +ttlunits | Print TTLs as 1h30m instead of raw seconds. |
例
dig +short example.comThe A records, nothing else.
dig @1.1.1.1 example.com MX +noall +answerMail records straight from a public resolver.
dig -x 8.8.8.8 +shortWhich name that address claims.
つながらないとき、どこまで行けたのかを絞ります — 名前が引けないのか、経路がないのか、ポートが閉じているのか。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. dig は何をしますか。
DNS サーバーに直接尋ねて記録をそのまま見せます。/etc/hosts と系のキャッシュを飛ばすため、ブラウザーが見るものと違うことがあり、配布物によっては dnsutils か bind-utils の導入が必要です。
Q. どう打ちますか。
dig [@server] <name> [type] — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは7個です。全部は man dig にあります。このコマンドはネットワークの仲間です。
関連するコマンド
man ページ: man dig