Skip to content

Linux host command (DNS lookups)

The Host Command in Linux is used to search the DNS name resolution service.

Take the example where it says which records are found for the address www.certificacaolinux.com.br:

$ host www.certificacaolinux.com.br www.certificacaolinux.com.br is an alias for myload-1433566614.us-east-1.elb.amazonaws.com.

myload-1433566614.us-east-1.elb.amazonaws.com has address 23.23.152.168 myload-1433566614.us-east-1.elb.amazonaws.com has address 23.21.124.198 The ping command is also capable of resolving names and testing connectivity between the host and the requested address.

If an address doesn’t exist, the host will return an error:

$ host esteendereconaoexiste.com Host esteendereconaoexiste.com not found: 3 (NXDOMAIN)

It is also possible to query a specific DNS server by simply entering the IP address of the target DNS server:

$ host google.com 1.1.1.1 Using domain server: Name: 1.1.1.1 Address: 1.1.1.1 #53 Aliases: google.com has address 172.217.162.110 google.com has IPv6 address 2800:3 f 0:4001:815: :200e

If the host command takes too long to respond and returns the following error, it is because the IP address of the DNS server specified in /etc/resolv.conf is not accessible:

$ host google.com;; connection timed out; no servers could be reached

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it?

Share