Linux每日一篇 - 47 - host
Linux DNS快速查询工具!掌握host命令,快速检查域名解析,诊断DNS问题!
host命令是什么?
host命令是一个用于执行DNS查询的简单工具,主要用于查找主机名到IP地址的映射,或者执行反向查询,是DNS诊断中最直观、最简单的工具之一。
基本用法
# 查询域名的IP地址
host google.com
# 指定DNS服务器查询
host google.com 8.8.8.8
# 反向DNS查询(IP到域名)
host 8.8.8.8
# 查询特定类型的DNS记录
host -t MX example.com
# 查询邮件服务器记录
host -t MX google.com
# 查询名称服务器记录
host -t NS google.com
实用技巧
# 查询CNAME记录
host -t CNAME www.google.com
# 查询TXT记录
host -t TXT google.com
# 查询SOA记录
host -t SOA google.com
# 查询PTR记录(反向)
host -t PTR 8.8.8.8
# 查询所有记录
host -t ANY google.com
# 显示详细信息
host -v google.com
# 使用TCP协议查询
host -T google.com
常用场景
# 快速查询IP地址
host github.com
# 检查邮件服务器配置
host -t MX outlook.com
# 查询域名的NS记录
host -t NS google.com
# 检查反向DNS
host 8.8.8.8
# 使用特定DNS服务器
host google.com 1.1.1.1
# 验证域名解析
host -t A example.com
# 批量查询域名
cat domains.txt | xargs -I {} host {}