The host command performs DNS lookups. Give it a domain name and you’ll see the associated IP address. Give it an IP address and you’ll see the associated domain name.
The host is a simple and essential command line tool. It is used for the following purposes:
- Performing DNS name lookups.
- Finding the IP address of a host or vice versa.
- List and validate various types of DNS resource records such as as NS and MX names.
- Verify ISP dns server and Internet connectivity.
- Verify spam and blacklisting records.
- Verifying and troubleshooting dns server problems.
Use host command to resolve a host name into an Internet Protocol (IP) address or an IP address into a host name.
The basic syntax:
host host-name-here [DNS-Server-Name-Here]
host [options] IPAddress | Hostname [DNS-Server-Name-Here]
List of DNS record types
Before you use the host command you should aware of common types of resource records of the DNS. Here are most common resource records:
|A||IPv4 IP address||192.168.1.5 or 126.96.36.199|
|AAAA||IPv6 IP address||2607:f0d0:1002:51::4|
|CNAME||Canonical name record (Alias)||s0.cyberciti.org is an alias
|MX||Email server host names||smtp.cyberciti.biz or mx1.nixcraft.com|
|NS||Name (DNS) server names||ns1.cyberciti.biz or ns-243.awsdns-30.com|
|PTR||Pointer to a canonical name.
Mostly used for implementing reverse DNS lookups
|SOA||Authoritative information about a DNS zone||see below|
|TXT||Text record||see below|
By default, host command looks for A, AAAA, and MX records only.
Host command examples
Let us see how to use host command on Linux and Unix. You need to give a hostname or an IP address as an argument to get various information about that host. Open the Terminal applications and type the following commands.
Find the IP address of a Hostname
To find the address of a host machine called wks05, run: