Aller au contenu

Host - Simple DNS Lookup Tool

`` ``
✅ All commands copied to clipboard!

Overview

host is a simple DNS lookup utility that provides clean, easy-to-read output for DNS queries. It’s designed to be more user-friendly than dig and more straightforward than nslookup, making it ideal for quick DNS lookups and basic troubleshooting tasks.

Basic Syntax

host [options] hostname [server]
host [options] IP_address [server]

Essential Commands

Basic DNS Lookups

# Look up A and AAAA records (IPv4 and IPv6)
host google.com

<button @click='copyCommand("host google.com")' class="copy-btn">Copy

# Reverse DNS lookup (IP to domain)
host 8.8.8.8

<button @click='copyCommand("host 8.8.8.8")' class="copy-btn">Copy

# IPv6 reverse lookup
host 2001:4860:4860::8888

<button @click='copyCommand("host 2001:4860:4860::8888")' class="copy-btn">Copy

# Using specific DNS server
host google.com 8.8.8.8

<button @click='copyCommand("host google.com 8.8.8.8")' class="copy-btn">Copy

Record Type Queries

# A record (IPv4 address)
host -t A google.com

<button @click='copyCommand("host -t A google.com")' class="copy-btn">Copy

# AAAA record (IPv6 address)
host -t AAAA google.com

<button @click='copyCommand("host -t AAAA google.com")' class="copy-btn">Copy

# MX record (Mail Exchange)
host -t MX google.com

<button @click='copyCommand("host -t MX google.com")' class="copy-btn">Copy

# NS record (Name Server)
host -t NS google.com

<button @click='copyCommand("host -t NS google.com")' class="copy-btn">Copy

# TXT record (Text records)
host -t TXT google.com

<button @click='copyCommand("host -t TXT google.com")' class="copy-btn">Copy

# CNAME record (Canonical Name)
host -t CNAME www.google.com

<button @click='copyCommand("host -t CNAME www.google.com")' class="copy-btn">Copy

# SOA record (Start of Authority)
host -t SOA google.com

<button @click='copyCommand("host -t SOA google.com")' class="copy-btn">Copy

# PTR record (Pointer for reverse lookup)
host -t PTR 8.8.8.8

<button @click='copyCommand("host -t PTR 8.8.8.8")' class="copy-btn">Copy

# SRV record (Service record)
host -t SRV _sip._tcp.example.com

<button @click='copyCommand("host -t SRV _sip._tcp.example.com")' class="copy-btn">Copy

Advanced Options

Verbose and Debug Output

# Verbose output (equivalent to -a)
host -v google.com

<button @click='copyCommand("host -v google.com")' class="copy-btn">Copy

# All records (ANY query type)
host -a google.com

<button @click='copyCommand("host -a google.com")' class="copy-btn">Copy

# Debug output
host -d google.com

<button @click='copyCommand("host -d google.com")' class="copy-btn">Copy

Timeout and Connection Options

# Set timeout (5 seconds)
host -W 5 google.com

<button @click='copyCommand("host -W 5 google.com")' class="copy-btn">Copy

# Wait indefinitely for reply
host -w google.com

<button @click='copyCommand("host -w google.com")' class="copy-btn">Copy

# Use TCP instead of UDP
host -T google.com

<button @click='copyCommand("host -T google.com")' class="copy-btn">Copy

# Set number of UDP retries
host -R 3 google.com

<button @click='copyCommand("host -R 3 google.com")' class="copy-btn">Copy

Query Behavior Options

# Non-recursive query
host -r google.com

<button @click='copyCommand("host -r google.com")' class="copy-btn">Copy

# Specify query class (default: IN)
host -c IN google.com

<button @click='copyCommand("host -c IN google.com")' class="copy-btn">Copy

# Show SOA records from all authoritative servers
host -C example.com

<button @click='copyCommand("host -C example.com")' class="copy-btn">Copy

# Zone transfer (list mode)
host -l example.com

<button @click='copyCommand("host -l example.com")' class="copy-btn">Copy

Using Different DNS Providers

# Google DNS
host google.com 8.8.8.8

<button @click='copyCommand("host google.com 8.8.8.8")' class="copy-btn">Copy

# Cloudflare DNS
host google.com 1.1.1.1

<button @click='copyCommand("host google.com 1.1.1.1")' class="copy-btn">Copy

# OpenDNS
host google.com 208.67.222.222

<button @click='copyCommand("host google.com 208.67.222.222")' class="copy-btn">Copy

# Quad9 DNS
host google.com 9.9.9.9

<button @click='copyCommand("host google.com 9.9.9.9")' class="copy-btn">Copy

Common Use Cases

Email Server Troubleshooting

# Check MX records for email routing
host -t MX example.com

<button @click='copyCommand("host -t MX example.com")' class="copy-btn">Copy

# Verify mail server IP
host mail.example.com

<button @click='copyCommand("host mail.example.com")' class="copy-btn">Copy

# Check multiple mail servers
host -t MX gmail.com yahoo.com outlook.com

<button @click='copyCommand("host -t MX gmail.com yahoo.com outlook.com")' class="copy-btn">Copy

Domain Verification

# Check TXT records for domain verification
host -t TXT example.com

<button @click='copyCommand("host -t TXT example.com")' class="copy-btn">Copy

# Verify SPF records
host -t TXT example.com|grep "v=spf1"

<button @click='copyCommand("host -t TXT example.com|grep \"v=spf1\"")' class="copy-btn">Copy

# Check DKIM records
host -t TXT default._domainkey.example.com

<button @click='copyCommand("host -t TXT default._domainkey.example.com")' class="copy-btn">Copy

Network Diagnostics

# Check authoritative name servers
host -t NS example.com

<button @click='copyCommand("host -t NS example.com")' class="copy-btn">Copy

# Verify domain authority information
host -t SOA example.com

<button @click='copyCommand("host -t SOA example.com")' class="copy-btn">Copy

# Check CNAME aliases
host -t CNAME www.example.com

<button @click='copyCommand("host -t CNAME www.example.com")' class="copy-btn">Copy

# Comprehensive domain analysis
host -a example.com

<button @click='copyCommand("host -a example.com")' class="copy-btn">Copy

Reverse DNS Lookups

# Check hostname for IP
host 192.168.1.1

<button @click='copyCommand("host 192.168.1.1")' class="copy-btn">Copy

# Verify server identity
host 208.67.222.222

<button @click='copyCommand("host 208.67.222.222")' class="copy-btn">Copy

# IPv6 reverse lookup
host 2001:4860:4860::8844

<button @click='copyCommand("host 2001:4860:4860::8844")' class="copy-btn">Copy

Troubleshooting Commands

Debug and Verbose Queries

# Debug mode with specific record type
host -d -t A google.com

<button @click='copyCommand("host -d -t A google.com")' class="copy-btn">Copy

# Verbose TCP query
host -v -T google.com

<button @click='copyCommand("host -v -T google.com")' class="copy-btn">Copy

# Non-recursive NS query
host -r -t NS google.com

<button @click='copyCommand("host -r -t NS google.com")' class="copy-btn">Copy

# Extended timeout with MX query
host -W 10 -t MX example.com

<button @click='copyCommand("host -W 10 -t MX example.com")' class="copy-btn">Copy

Command Options Reference

OptionDescription
-aEquivalent to -v and -t ANY
-CShow SOA records from all authoritative servers
-c classSpecify query class (default: IN)
-dEnable debug output
-lList mode (zone transfer)
-nUse IP6.INT domain for IPv6 reverse lookups
-N ndotsSet number of dots for absolute names
-rMake non-recursive queries
-R retriesSet number of UDP retries
-t typeSpecify query type (A, AAAA, MX, NS, etc.)
-TUse TCP connection
-vVerbose output
-W secondsSet timeout in seconds
-wWait indefinitely for reply

Record Types

TypeDescriptionExample
AIPv4 addresshost -t A google.com
AAAAIPv6 addresshost -t AAAA google.com
CNAMECanonical namehost -t CNAME www.google.com
MXMail exchangehost -t MX google.com
NSName serverhost -t NS google.com
PTRPointer (reverse)host -t PTR 8.8.8.8
SOAStart of authorityhost -t SOA google.com
SRVService recordhost -t SRV _sip._tcp.example.com
TXTText recordhost -t TXT google.com
ANYAll recordshost -a google.com

Installation

Linux (Ubuntu/Debian)

sudo apt-get install dnsutils

Linux (CentOS/RHEL/Fedora)

sudo yum install bind-utils
# or
sudo dnf install bind-utils

macOS

host comes pre-installed with macOS.

Windows

Use Windows Subsystem for Linux (WSL) or install via package managers like Chocolatey.

Tips and Best Practices

  1. Clean output: host provides cleaner, more readable output than dig
  2. Quick lookups: Ideal for simple DNS queries and basic troubleshooting
  3. Multiple queries: Can query multiple domains in a single command
  4. Reverse lookups: Automatically detects IP addresses and performs reverse lookups
  5. Timeout settings: Use -W option for slow or unreliable networks
  6. TCP queries: Use -T for large responses or when UDP is blocked
  7. Combine with other tools: Use alongside dig and nslookup for comprehensive analysis

Common Error Messages

ErrorMeaning
Host not foundDomain doesn’t exist (NXDOMAIN)
No address associated with hostnameNo A/AAAA records found
Connection timed outDNS server unreachable
Server failureDNS server error (SERVFAIL)
Query refusedDNS server refused the query
  • dig - More detailed DNS lookup tool with extensive options
  • nslookup - Interactive DNS lookup utility
  • ping - Test network connectivity and resolve hostnames
  • traceroute - Trace network path to destination
  • whois - Domain registration and ownership information