首頁·終端機命令

host

網路

用法

host [-t <type>] <name> [server]

查一個名稱時用兩三行短短地給出位址和郵件伺服器;快速確認最省事,但要看完整記錄還得用 dig。

常用選項

選項含義
-t MXRestrict to one record type.
-aEverything, equivalent to -t ANY -v.
-vVerbose output closer to what dig prints.
-CFetch the SOA from every authoritative server, to spot one that is out of sync.
<ip>Give it an address and it does the reverse lookup by itself.

範例

host example.com

Addresses and mail servers in three short lines.

host -t TXT example.com

Read the SPF or verification records.

host 8.8.8.8

Reverse lookup without needing -x.

連不上的時候,這些能把範圍縮小——是名稱解析不了、沒有路由,還是連接埠被擋。

怎麼看

  • 方括號 [ ] 表示這部分可以不寫。
  • 省略號 … 表示可以寫多個。
  • 選項區分大小寫——有些命令裡 -r 和 -R 不是一回事。

常見問題

Q. host 是做什麼的?

查一個名稱時用兩三行短短地給出位址和郵件伺服器;快速確認最省事,但要看完整記錄還得用 dig。

Q. 怎麼寫?

host [-t <type>] <name> [server] —— 方括號表示可以省略的部分。

Q. 值得記的選項有幾個?

這裡列了 5 個,完整列表在 man host。這條命令屬於網路。

相關命令

man 手冊: man host