Skip to content

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
``
# Reverse DNS lookup (IP to domain)
host 8.8.8.8
``
# IPv6 reverse lookup
host 2001:4860:4860::8888
``
# Using specific DNS server
host google.com 8.8.8.8
``

Record Type Queries

# A record (IPv4 address)
host -t A google.com
``
# AAAA record (IPv6 address)
host -t AAAA google.com
``
# MX record (Mail Exchange)
host -t MX google.com
``
# NS record (Name Server)
host -t NS google.com
``
# TXT record (Text records)
host -t TXT google.com
``
# CNAME record (Canonical Name)
host -t CNAME www.google.com
``
# SOA record (Start of Authority)
host -t SOA google.com
``
# PTR record (Pointer for reverse lookup)
host -t PTR 8.8.8.8
``
# SRV record (Service record)
host -t SRV _sip._tcp.example.com
``

Advanced Options

Verbose and Debug Output

# Verbose output (equivalent to -a)
host -v google.com
``
# All records (ANY query type)
host -a google.com
``
# Debug output
host -d google.com
``

Timeout and Connection Options

# Set timeout (5 seconds)
host -W 5 google.com
``
# Wait indefinitely for reply
host -w google.com
``
# Use TCP instead of UDP
host -T google.com
``
# Set number of UDP retries
host -R 3 google.com
``

Query Behavior Options

# Non-recursive query
host -r google.com
``
# Specify query class (default: IN)
host -c IN google.com
``
# Show SOA records from all authoritative servers
host -C example.com
``
# Zone transfer (list mode)
host -l example.com
``

Using Different DNS Providers

# Google DNS
host google.com 8.8.8.8
``
# Cloudflare DNS
host google.com 1.1.1.1
``
# OpenDNS
host google.com 208.67.222.222
``
# Quad9 DNS
host google.com 9.9.9.9
``

Common Use Cases

Email Server Troubleshooting

# Check MX records for email routing
host -t MX example.com
``
# Verify mail server IP
host mail.example.com
``
# Check multiple mail servers
host -t MX gmail.com yahoo.com outlook.com
``

Domain Verification

# Check TXT records for domain verification
host -t TXT example.com
``
# Verify SPF records
host -t TXT example.com|grep "v=spf1"
``
# Check DKIM records
host -t TXT default._domainkey.example.com
``

Network Diagnostics

# Check authoritative name servers
host -t NS example.com
``
# Verify domain authority information
host -t SOA example.com
``
# Check CNAME aliases
host -t CNAME www.example.com
``
# Comprehensive domain analysis
host -a example.com
``

Reverse DNS Lookups

# Check hostname for IP
host 192.168.1.1
``
# Verify server identity
host 208.67.222.222
``
# IPv6 reverse lookup
host 2001:4860:4860::8844
``

Troubleshooting Commands

Debug and Verbose Queries

# Debug mode with specific record type
host -d -t A google.com
``
# Verbose TCP query
host -v -T google.com
``
# Non-recursive NS query
host -r -t NS google.com
``
# Extended timeout with MX query
host -W 10 -t MX example.com
``

Command Options Reference

Option Description
-a Equivalent to -v and -t ANY
-C Show SOA records from all authoritative servers
-c class Specify query class (default: IN)
-d Enable debug output
-l List mode (zone transfer)
-n Use IP6.INT domain for IPv6 reverse lookups
-N ndots Set number of dots for absolute names
-r Make non-recursive queries
-R retries Set number of UDP retries
-t type Specify query type (A, AAAA, MX, NS, etc.)
-T Use TCP connection
-v Verbose output
-W seconds Set timeout in seconds
-w Wait indefinitely for reply

Record Types

Type Description Example
A IPv4 address host -t A google.com
AAAA IPv6 address host -t AAAA google.com
CNAME Canonical name host -t CNAME www.google.com
MX Mail exchange host -t MX google.com
NS Name server host -t NS google.com
PTR Pointer (reverse) host -t PTR 8.8.8.8
SOA Start of authority host -t SOA google.com
SRV Service record host -t SRV _sip._tcp.example.com
TXT Text record host -t TXT google.com
ANY All records host -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

Error Meaning
Host not found Domain doesn't exist (NXDOMAIN)
No address associated with hostname No A/AAAA records found
Connection timed out DNS server unreachable
Server failure DNS server error (SERVFAIL)
Query refused DNS 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