Javatpoint Logo
Javatpoint Logo

Linux host Command

Linux host command displays domain name for given IP address or vice-versa. It also performs DNS lookups related to the DNS query. The host command's default behavior displays a summary of its command-line arguments and supported options.

Syntax:

The host command supports various command-line arguments and options. The basic syntax for the host command is as follows:

where,

name: The name can be a domain name or an IP address (Ipv4 or Ipv6). It will lookup for the given name.

Options:

The following command-line arguments and options can be used with the host command:

-4: It is used for Ipv4 address only for the query.

-6: It is used for IPv6 address only for the query.

-a: The '-a' option stands for "All." It is equivalent to '-v', '-r', 's', any option. But, it influences the behavior of the '-l ' option.

-c class: It is used to specify the Query class. The default value of the class is In (Internet).

-C: It is used to check the consistency.

-d: It is used to display debugging traces. This option is similar to the '-v' verbose option.

-i: It is used for the obsolete value.

-l: It is used to list zones. The host command is also used to transfer zones and displays records such as NS, PTR, A, and more.

-N ndots: It is used to specify the number of dots that have to be in the name.

-r: It is used for the non-recursive query. It is useful for mimicking the behavior of a name server by using the non-recursive queries.

-R number: It is used for the number of retries for UDP queries. For the negative numbers or zero, the number of retries will be 1 (i.e., default).

-s: If a server does not respond, it will not send a query to the next name server.

-t type: It is used to specify the query type. This option will recognize any query type such as 'CNAME', 'NS', 'SOA', 'TXT', 'DNSKEY', 'AXFR', and more. If we do not specify a query type, it will automatically select an appropriate type. By default it will search for the 'A', 'AAAA', and MX records. If the name is an IP address, it will search for the 'PTR' record.

-T or -U: It is used for the TCP/UDP connections: By default, the host command selects 'UDP' connection while making queries. The '-T' option specifies the TCP connection, and '-U' specifies the 'UDP' connection.

-m flag: It is used for memory usage debugging. The 'flag' argument can be recorded, used, or traced. We can set multiple flags by using this option.

-v: It is used to display detailed (verbosely) output. This option is similar to the '-d' option.

-V: It is used to display the version information.

-w: It is used for wait forever mode. It will set the query timeout to the maximum possible value.

-W wait: It is used to wait for a specified upto time (in seconds). It can not take a value less than one. The default query wait time is 5 seconds (for UDP responses) and 10 seconds (for TCP connections).

Examples of the host Command

Let' see the following examples of the host command:

  • Default host command
  • Display domain IP address
  • Use only Ipv4 address for query transport
  • Use only Ipv6 address for query transport
  • Display the domain name servers
  • Display only Cname records
  • Display only MX records
  • Display only TXT records
  • Display only SOA records
  • Query a particular name server
  • Display all information of domain name server
  • Display TTL Information

Default host Command

If we execute the host command without any arguments, it will display a summary of command-line arguments and supported options. Execute the command as follows:

The above command will display a list of supported command-line options. Consider the below output:

Linux Host

Display Domain's IP Address

To display the Domain's IP address, execute the host command followed by the domain name, as follows:

The above command will display the IP address of the given domain name. Consider the below output:

Linux Host

Use only Ipv4 for Query Transport

We can use Ipv4 query transport for a domain. To use the IPv4 address, execute the command with the '-4' option as follows:

The above command will use the Ipv4 address for query transport on the given domain name. Consider the below output:

Linux Host

Use only Ipv6 for Query Transport

The '-6' option is used to use Ipv6 query transport. It can be useful for checking if the Ipv6 enabled name server is working or not. Execute the command as follows:

Consider the below output:

Linux Host

Display Domain Name Servers

The 'ns' option with '-t' arguments are used to display the domain name servers. Consider the below command:

The above command will display the name servers of 'javatpoint.' Consider the below output:

Linux Host

Display only Cname Records

The 'cname' option with '-t' arguments are used to display the cname records. Consider the below command:

The above command will display the cname records of 'javatpoint.' Consider the below output:

Linux Host

Display only MX Records

The 'mx' option with '-t' arguments are used to display the mx records. Consider the below command:

The above command will display the mx records of 'javatpoint.' Consider the below output:

Linux Host

Display only TXT Records

The 'txt' option with '-t' arguments are used to display the TXT records. Consider the below command:

The above command will display the txt records of 'javatpoint.' Consider the below output:

Linux Host

Display only SOA records

We can list the SOA records for a specified zone by using the host command. It will display the authoritative name servers for the given zone. To display the SOA records, execute the host command with the '-C' option as follows:

The above command will display the SOA records of 'javatpoint'. Consider the below output:

Linux Host

Query a Particular Name Server

We can query a particular name server by specifying the name server after domain name or IP address. To query a specific name server, execute the host command as follows:

The above command will display the information on the given name server. Consider the below output:

Linux Host

Display all Information of Domain Name Server

To display the detailed information of any domain name server, pass the '-a' option followed by the domain name with the host command. Consider the below command:

The above command will display detailed information of the 'javatpoint' domain. Consider the below output:

Linux Host

Display TTL Information

To display a TTL (Time To Live) information of any server, execute the host command as follows:

The above command will display the TTL information on 'Javatpoint.com.' You can choose any other domain name. Consider the below output:

Linux Host
Next TopicLinux arp




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA