host (一个DNS查找实用程序,用于查找域名的IP地址)

瑞兹 发表于 2021-01-21 09:07
浏览次数:
在手机上阅读

在类似Unix的操作系统上,host命令是一个DNS查找实用程序,用于查找域名的IP地址。它还执行反向查找,查找与IP地址关联的域名。

查看英文版

目录

1 host 运行系统环境

2 host 描述

3 host 语法

4 host 例子

host 运行系统环境

Unix&Linux

host 描述

host执行DNS查找,将域名转换IP地址,反之亦然。如果未提供任何参数或选项,host将打印其命令行 参数和选项的简短摘要

在下面列出的语法中,name是要查找的域名。该名称也可以是点分十进制的IPv4地址或冒号分隔的IPv6地址,在这种情况下,host默认情况下将对该地址执行反向查找。服务器是一个可选参数是名称或名称服务器的IP地址,host应该改为查询中列出的服务器或服务器/etc/resolv.conf

host performs DNS lookups, converting domain names to IP addresses and vice versa. When no arguments or options are given, host prints a short 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, in which case host will by default perform 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.

查看英文版

查看中文版

host 语法

host [-aCdlnrsTwv] [-c class] [-N ndots] [-R number] [-t type] [-W wait]
     [-m flag] [-4] [-6] {name} [server]

选件

-a

-a所有)选项相当于设置-v选项,并要求host做一个查询类型的任何。

-C

使用-C选项时,host将尝试从该区域的所有列出的权威名称服务器中显示该区域名称的SOA记录。名称服务器列表由在区域中找到的NS记录定义。

-c class

-c命令选项host做出DNS类的查询。这可用于查找Hesiod或Chaosnet类资源记录。默认类是IN(Internet)。

-d

使用-d-v选项时,host会生成详细的输出。这两个选项是等效的。提供它们是为了向后兼容。在以前的版本中,-d选项打开调试跟踪并启用-v的详细输出。

-l

列表模式由-l选项选择。这使host可以对区域名称执行区域传输。转移打印出NS,PTR和地址记录(A / AAAA)的区域。如果与-a结合使用,则将打印所有记录。

-i

-i选项指定IPv6地址的反向查找应使用如在RFC1886中定义的IP6.INT域。默认值为使用IP6.ARPA。

-N ndots

-N选项设置必须在名称为它被认为是绝对的点数。缺省值是使用所定义的ndots语句/etc/resolv.conf中,或1,如果没有的ndots语句存在。点号较少的名称将被解释为相对名称,并将在/etc/resolv.conf的search或domain指令中列出的域中进行搜索。

-R number

可以使用-R选项更改查找的UDP重试次数。数字表示host将重复一次没有得到答复的查询的次数。默认重试次数为1。如果number为负数或零,则重试次数将默认为1

-r

可以通过-r选项进行非递归查询。设置此选项将清除host进行的查询中的RD(“需要递归”)位。这应该意味着接收查询的名称服务器将不会尝试解析名称。该-r选项使host通过使非递归查询,并能接收答案,那些通常转介到其他域名服务器查询的名称服务器的模仿行为。

-T

默认情况下,host在进行查询时使用UDP。该-T选项,可以使用一个TCP请求名字服务器时连接。将自动为需要它的查询选择TCP,例如区域传输(AXFR)请求。

-4

-4选项强制host仅使用IPv4查询传输。

-6

-6选项强制host仅使用IPv6查询传输。

-t type

-t选项用于选择查询类型。该类型可以是任何可识别的查询类型:CNAMENSSOASIGKEYAXFR等。如果未指定查询类型,host将自动选择适当的查询类型。默认情况下,它将查找A,AAAA和MX记录,但是如果提供-C选项,将查询SOA记录,并且如果name是点分十进制的IPv4地址或冒号分隔的IPv6地址,host将查询PTR记录。如果选择查询类型为IXFR,则起始序列号可以通过在后面加上一个等于序列号的起始序列号来指定(例如-t IXFR = 12345678)。

-W wait-w

等待答复的时间可以通过-W-w选项控制。该-W选项使host等待等待秒。如果wait小于1,则将等待时间间隔设置为一秒。使用-w选项时,host将有效地永远等待答复。等待响应的时间将设置为整数的硬件最大值所指定的秒数。

-s

-s选项告诉host不是将查询发送到下一个域名服务器,如果任何服务器响应以SERVFAIL响应,这是正常的存根解析器行为相反。

-m flag

-m可以用于设置内存使用调试标志记录,使用和跟踪。

host [-aCdlnrsTwv] [-c class] [-N ndots] [-R number] [-t type] [-W wait]
     [-m flag] [-4] [-6] {name} [server]

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 will attempt 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 be used to 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 have been 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 will be 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 for it 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 will be 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 will repeat a query that does not get answered. The default number of retries is 1. If number is negative or zero, the number of retries will default 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 that the name server receiving the query will 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 will be automatically selected for queries that require it, such as zone transfer (AXFR) 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: CNAMENSSOASIGKEYAXFR, 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 will be made for SOA records, and if name is a dotted-decimal IPv4 address or colon-delimited IPv6 address, host will query for PTR records. If a query type of IXFR is chosen the starting serial number can be specified by appending an equal 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 will effectively wait forever for a reply. The time to wait for a response will be 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 be used to set the memory usage debugging flags record, usage and trace.

查看英文版

查看中文版

host 例子

host 204.228.150.3

此命令在IP地址204.228.150.3上执行反向查找,结果为:

3.150.228.204.in-addr.arpa domain name pointer www.computerhope.com.
host 204.228.150.3

This command performs a reverse lookup on the IP address 204.228.150.3, which results in the output:

3.150.228.204.in-addr.arpa domain name pointer www.computerhope.com.

查看英文版

查看中文版

其他命令行

hash | head | hostid | hostname | halt | help |

如此好文,分享给朋友
发表评论
验证码:
评论列表
共0条