Skip to main content

Module 9: Networking

Lesson 87: host Command

In this lesson, you'll learn how to use the host command to perform DNS lookups and query various DNS record types in Linux.

,host command is a minimal and easy-to-use CLI utility for performing DNS lookups, which translate domain names to IP addresses and vice versa.

It can also be used to list and verify various types of DNS records, such as NS and MX, test and validate ISP DNS server and Internet connectivity, spam and blacklisting records, and detect and troubleshoot DNS server issues, among others.

Let's now use the host command with a few useful examples in Linux to perform DNS lookups.

host Command Syntax

$ host [OPTIONS] [DOMAIN] [DNS_SERVER]

host Command Options

Option Description
-t ns Find domain name servers
-t cname Find domain CNAME record
-t mx Find domain MX (Mail Exchange) record
-t txt Find domain TXT record
-t a Find domain A record with TTL information
-C Display SOA records from all authoritative name servers
-a Query all record types (equivalent to -v)
-4 Force IPv4 query transport only
-6 Force IPv6 query transport only
-r Perform non-recursive queries
-R N Set the number of UDP retries (default: 1)
-W N Wait N seconds for a reply
-w Wait forever for a reply
-T Use TCP instead of UDP for queries

1. Find the Domain IP Address

This is the simplest host command you can run, just provide a domain name such as google.com to get the associated IP addresses.

$ host google.com
google.com has address 216.58.201.46
google.com has address 216.58.201.46
google.com has address 216.58.201.46
google.com has IPv6 address 2a00:1450:4009:80b::200e
google.com mail is handled by 20 alt1.aspmx.l.google.com.
google.com mail is handled by 30 alt2.aspmx.l.google.com.
google.com mail is handled by 10 aspmx.l.google.com.
google.com mail is handled by 40 alt3.aspmx.l.google.com.
google.com mail is handled by 50 alt4.aspmx.l.google.com.

2. Find Domain Name Servers

To find out the domain name servers, use the -t option with ns.

$ host -t ns google.com
google.com name server ns1.google.com.
google.com name server ns2.google.com.
google.com name server ns4.google.com.
google.com name server ns3.google.com.

3. Find Domain CNAME Record

Pro TecMint Β· Root Plan
This Article is for Root Members
Join Root to read the full article and unlock everything

Full Access to Every Article, Course & Certification Track

Join thousands of Linux professionals who use Pro TecMint to advance their careers.

Ad-free access to all premium articles
All courses: Learn Linux, Bash, Golang, Ubuntu and more
RHCSA, RHCE, LFCS & LFCA certification prep
New courses added every month
Private Telegram community & priority support
Root Plan
$8/mo
or $59/year billed annually
Save $37 with annual plan
Start Reading This Article in the Next 60 Seconds
Join Root Plan β†’