host Command in Linux: DNS Queries and Domain Name Resolution
The host command in Linux is used to perform queries on the DNS name resolution service.
See in the example that it shows which records were found for the address www.certificacaolinux.com.br:
$ host www.certificacaolinux.com.brwww.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.168myload-1433566614.us-east-1.elb.amazonaws.com has address 23.21.124.198
The ping command is also able to resolve names and test connectivity between the host and the requested address.
If an address does not exist, host will return an error:
$ host esteendereconaoexiste.comHost esteendereconaoexiste.com not found: 3(NXDOMAIN)
It is also possible to query a specific DNS server, just inform the IP address of the target DNS server:
$ host google.com 1.1.1.1Using domain server:Name: 1.1.1.1Address: 1.1.1.1#53Aliases: google.com has address 172.217.162.110google.com has IPv6 address 2800:3f0:4001:815::200e
If the host command takes too long to respond and returns the following error, it means 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 enroll here. If you already have an account, or want to create one, just log in or create your user here.
Like it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.