- команда host в Linux с примерами
- Linux host command
- Description
- Syntax
- Options
- Examples
- Related commands
- Linux and Unix host Command Examples
- Purpose
- Syntax
- List of DNS record types
- host command examples
- Find the IP address of a Hostname
- Find the hostname of an IP address
- How do I select the DNS query type?
- To query CNAME record type, type
- To query SOA record type for the domain, enter
- To query TXT record type for the domain, enter
- Tip: Query of type ANY record for the domain, enter:
- Show the SOA records for DNS zone name
- Force queries over TCP/IP
- Specifies number of retries for UDP packets
- Use either IPv4 or IPv6 transport
- How do I lists all hosts in a domain called example.com?
- host command options
- Related media
команда host в Linux с примерами
Команда host в системе Linux используется для операций поиска DNS (Domain Name System). Проще говоря, эта команда используется для поиска IP-адреса конкретного доменного имени или, если вы хотите узнать доменное имя определенного IP-адреса, команда хоста становится удобной. Вы также можете найти более подробную информацию о домене, указав соответствующую опцию вместе с именем домена.
Синтаксис:
Команда хоста без какой-либо опции: она напечатает общий синтаксис команды вместе с различными опциями, которые можно использовать с командой хоста, а также даст краткое описание каждой опции.
Пример:
Различные параметры с помощью команды host:
- host domain_name: будет напечатана информация об IP-адресе указанного домена.
Пример:
host IP_Address: здесь будут отображаться сведения о домене указанного IP-адреса.
Пример:
-a или -v: используется для указания типа запроса или включает подробный вывод.
Пример:
-t: используется для указания типа запроса.
Пример 1:
Пример 2: Распечатать запись SOA
Пример 3: Распечатать текстовую запись
-C: для сравнения записей SOA на авторитетных серверах имен.
Пример:
-R: чтобы указать количество повторных попыток, которые вы можете выполнить в случае неудачи одной попытки. Если попытка удастся, команда останавливается.
Пример:
-l: для того, чтобы вывести список всех хостов в домене. Чтобы эта команда работала, вы должны быть администратором или сервером узлов.
Источник
Linux host command
On Unix-like operating systems, the host command is a DNS lookup utility, finding the IP address of a domain name. It also performs reverse lookups, finding the domain name associated with an IP address.
This page describes the GNU/Linux version of host.
Description
host performs DNS lookups, converting domain names to IP addresses and vice versa. When no arguments or options are given, host prints a summary of its command line arguments and options.
In the syntax listed below, name is the domain name that is to be looked up. The name can also be a dotted-decimal IPv4 address or a colon-delimited IPv6 address, where host, by default, performs a reverse lookup for that address. The server is an optional argument that is either the name or IP address of the name server that host should query instead of the server or servers listed in /etc/resolv.conf.
Syntax
Options
-a | The -a (all) option is equivalent to setting the -v option and asking host to make a query of type ANY. |
-C | When the -C option is used, host attempts to display the SOA records for zone name from all the listed authoritative name servers for that zone. The list of name servers is defined by the NS records that are found for the zone. |
-c class | The -c option instructs host to make a DNS query of class class. This can lookup Hesiod or Chaosnet class resource records. The default class is IN (Internet). |
-d | Verbose output is generated by host when the -d or -v option is used. The two options are equivalent. They are provided for backward compatibility. In previous versions, the -d option switched on debugging traces and -v enabled verbose output. |
-l | List mode is selected by the -l option. This makes host perform a zone transfer for zone name. Transfer the zone printing out the NS, PTR, and address records (A/AAAA). If combined with -a, all records are printed. |
-i | The -i option specifies that reverse lookups of IPv6 addresses should use the IP6.INT domain as defined in RFC1886. The default is to use IP6.ARPA. |
-N ndots | The -N option sets the number of dots that have to be in name to be considered absolute. The default value is that defined using the ndots statement in /etc/resolv.conf, or 1 if no ndots statement is present. Names with fewer dots are interpreted as relative names and are searched for in the domains listed in the search or domain directive in /etc/resolv.conf. |
-R number | The number of UDP retries for a lookup can be changed with the -R option. number indicates how many times host repeats a query that does not get answered. The default number of retries is 1. If number is negative or zero, the number of retries defaults to 1. |
-r | Non-recursive queries can be made via the -r option. Setting this option clears the RD («recursion desired») bit in the query which host makes. This should mean the name server receiving the query does not attempt to resolve name. The -r option enables host to mimic the behavior of a name server by making non-recursive queries and expecting to receive answers to those queries that are usually referrals to other name servers. |
-T | By default, host uses UDP when making queries. The -T option makes it use a TCP connection when querying the name server. TCP is automatically selected for queries that require it, such as AXFR (zone transfer) requests. |
-4 | The -4 option forces host to only use IPv4 query transport. |
-6 | The -6 option forces host to only use IPv6 query transport. |
-t type | The -t option is used to select the query type. The type can be any recognized query type: CNAME, NS, SOA, SIG, KEY, AXFR, etc. When no query type is specified, host automatically selects an appropriate query type. By default, it looks for A, AAAA, and MX records, but if the -C option was given, queries are made for SOA records, and if name is a dotted-decimal IPv4 address or colon-delimited IPv6 address, host queries for PTR records. If a query type of IXFR is chosen, the starting serial number can be specified by appending an equal sign followed by the starting serial number (e.g., -t IXFR=12345678). |
-W wait, -w | The time to wait for a reply can be controlled through the -W and -w options. The -W option makes host wait for wait seconds. If wait is less than 1, the wait interval is set to one second. When the -w option is used, host effectively waits forever for a reply. The time to wait for a response is set to the number of seconds given by the hardware’s maximum value for an integer quantity. |
-s | The -s option tells host not to send the query to the next nameserver if any server responds with a SERVFAIL response, which is the reverse of normal stub resolver behavior. |
-m flag | The -m can set the memory usage debugging flags record, usage and trace. |
Examples
This command performs a reverse lookup on the IP address 204.228.150.3, which results in the output:
Related commands
dig — DNS lookup utility.
nslookup — Query a name server for information about a remote host.
ping — Send ICMP ECHO_REQUEST packets to network hosts.
Источник
Linux and Unix host Command Examples
I am a new Linux and command line user. How do I use host command line utility to verify DNS settings on Linux and Unix-like operating systems? How do I use dig command to find the IP address of a host name or host Name of an IP address?
host command details | |
---|---|
Description | DNS lookup |
Category | Network Utilities |
Difficulty | Easy |
Root privileges | No |
Est. reading time | 15 minutes |
Table of contents
|
Purpose
Use host command to resolve a host name into an Internet Protocol (IP) address or an IP address into a host name.
Syntax
The basic syntax:
host ip-address-here
host host-name-here
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:
Type | Purpose | Examples |
A | IPv4 IP address | 192.168.1.5 or 75.126.153.206 |
AAAA | IPv6 IP address | 2607:f0d0:1002:51::4 |
CNAME | Canonical name record (Alias) | s0.cyberciti.org is an alias for d2m4hyssawyie7.cloudfront.net |
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 | 82.236.125.74.in-addr.arpa |
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:
host wks05
Sample outputs:
To show the address of a for the domain named google.com or cyberciti.biz, type:
host google.com
OR
host www.cyberciti.biz
Sample outputs:
Find the hostname of an IP address
To find the host whose address is 192.168.1.254, type:
host 192.168.1.254
Sample outputs:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
In this example, find the domain name whois address is 75.126.153.206, run:
host 75.126.153.206
Sample outputs:
How do I select the DNS query type?
Pass the -t option as follows to specifies the query type:
host -t query Hostname|IPAddress
To query NS record type for the domain cyberciti.biz, enter:
host -t ns cyberciti.biz
Sample outputs:
To query CNAME record type, type
host -t CNAME s0.cyberciti.org
Sample outputs:
To query SOA record type for the domain, enter
host -t SOA cyberciti.biz
Sample outputs:
To query TXT record type for the domain, enter
host -t txt google.com
Sample outputs:
Tip: Query of type ANY record for the domain, enter:
host -a cyberciti.biz
OR
host -v cyberciti.biz
Sample outputs:
Fig.01: The -a option displays any type of dns records
Show the SOA records for DNS zone name
Pass the -C option to display the SOA records for zone name from all the listed authoritative name servers for that zone. This is useful to compare SOA records on authoritative nameservers. The syntax is:
$ host -C cyberciti.biz
Sample outputs:
Force queries over TCP/IP
By default, host command will use UDP protocol when making queries. Pass the -T option to use a TCP connection when querying the name server. This is useful to see if the name server works over TCP and firewall is allowing queries over the TCP:
host -T IPAddress
host -T cyberciti.biz
host -a -T google.com
Specifies number of retries for UDP packets
If you are on unraialbe network, you can set retry number for packats. In this example, try to find out the IP address of the domain called example.com in three retries:
host -t a -R 3 example.com
Use either IPv4 or IPv6 transport
To use IPv4 query transport only pass the -4 option to the host command:
host -4 IP|Host
host -4 example.com
To use IPv6 query transport only pass the -6 option to the host command. This is useful to test if your IPv6 enabled name servers are working or not:
host -6 IP|Host
host -6 example.com
How do I lists all hosts in a domain called example.com?
Pass the -l option to list all hostnames and server in a domain. This only works if you are making query from a slave (secondary) and/or from master dns server IP address only. As a dns server admin you can get the list of all hosts in a domain without opening a zone file:
# Note must be on slave/master server where AXFR is alowed ##
host -l example.com
Please note that the AXFR is a special resource record type. It is used for Authoritative Zone Transfer i.e. transfer entire zone file from the master name server to secondary name servers.
host command options
Here is the summary of all important options of the host command on Linux or Unix-like operating systems:
Option | Usage |
-a | It is equivalent to -v -t ANY options. |
-c | Specifies query class for non-IN data |
-C | Compares SOA records on authoritative nameservers |
-d | It is equivalent to -v |
-l | Lists all hosts in a domain, using AXFR |
-i | IP6.INT reverse lookups |
-N | Changes the number of dots allowed before root lookup is done |
-r | Disables recursive processing |
-R | Specifies number of retries for UDP packets |
-s | A SERVFAIL response should stop query |
-t | Specifies the query type |
-T | Enables TCP/IP mode |
-v | Enables verbose output |
-w | Specifies to wait forever for a reply |
-W | Specifies how long to wait for a reply |
-4 | Use IPv4 query transport only |
-6 | Use IPv6 query transport only |
-m | Set memory debugging flag (trace|record|usage) |
Related media
This tutorials is also available in a quick video format:
See also
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник