下面列出的命令是我们常用的命令,但还有更多命令存在。查看 man 手册和文档以获取更多详细信息。
nslookup。 nslookup 程序允许用户以交互或非交互方式查询 Internet 域名服务器。在交互模式下,用户可以查询名称服务器以获取有关各种主机和域的信息,并打印域中主机的列表。在非交互模式下,用户可以只打印名称并请求主机或域的信息。交互模式有很多选项和命令;建议您查看 nslookup 的 man 手册,或 nslookup 交互模式下的帮助。
要进入 nslookup 交互模式,请使用命令
[root@deep] /# nslookup |
Default Server: deep.openna.com Address: 208.164.186.1 > help $Id: nslookup.help,v 8.4 1996/10/25 18:09:41 vixie Exp $ Commands: (identifiers are shown in uppercase, [] means optional) NAME - print info about the host/domain NAME using default server NAME1 NAME2 - as above, but use NAME2 as server help or ? - print info on common commands; see nslookup(1) for details set OPTION - set an option all - print options, current server and host [no]debug - print debugging information [no]d2 - print exhaustive debugging information |
要在非交互模式下运行,请使用命令
[root@deep] /# nslookup www.redhat.com |
Server: deep.openna.com Address: 208.164.186.1 Non-authoritative answer: Name: www.portal.redhat.com Addresses: 206.132.41.202, 206.132.41.203 Aliases: www.redhat.com |
dnsquery。 dnsquery 程序通过解析器库调用查询域名服务器/etc/resolv.conf。要使用解析器查询域名服务器,请使用命令
[root@deep] /# dnsquery <host> |
示例 21-1. dnsquery
[root@deep] /# dnsquery www.redhat.com |
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40803 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 4 ;; www.redhat.com, type = ANY, class = IN www.redhat.com. 2h19m46s IN CNAME www.portal.redhat.com. redhat.com. 2h18m13s IN NS ns.redhat.com. redhat.com. 2h18m13s IN NS ns2.redhat.com. redhat.com. 2h18m13s IN NS ns3.redhat.com. redhat.com. 2h18m13s IN NS speedy.redhat.com. ns.redhat.com. 1d2h18m8s IN A 207.175.42.153 ns2.redhat.com. 1d2h18m8s IN A 208.178.165.229 ns3.redhat.com. 1d2h18m8s IN A 206.132.41.213 speedy.redhat.com. 2h18m13s IN A 199.183.24.251 |
host。 host 程序使用 DNS 查找主机名。要使用域名服务器查找主机名,请使用命令
[root@deep] /# host <FQDN, domain names, host names, or host numbers> |
示例 21-2. 查找主机名
[root@deep] /# host redhat.com |
redhat.com has address 207.175.42.154 |
要查找由 DNS 维护的关于主机的全部信息,请使用命令
[root@deep] /# host -a <domain names > |
示例 21-3. 使用 host
[root@deep] /# host -a redhat.com |
Trying null domain rcode = 0 (Success), ancount=6 The following answer is not authoritative: The following answer is not verified as authentic by the server: redhat.com 8112 IN NS ns.redhat.com redhat.com 8112 IN NS ns2.redhat.com redhat.com 8112 IN NS ns3.redhat.com redhat.com 8112 IN NS speedy.redhat.com redhat.com 8112 IN A 207.175.42.154 redhat.com 11891 IN SOA ns.redhat.com noc.redhat.com( 2000021402 ;serial (version) 3600 ;refresh period 1800 ;retry refresh this often 604800 ;expiration period 86400 ;minimum TTL ) For authoritative answers, see: redhat.com 8112 IN NS ns.redhat.com redhat.com 8112 IN NS ns2.redhat.com redhat.com 8112 IN NS ns3.redhat.com redhat.com 8112 IN NS speedy.redhat.com Additional information: ns.redhat.com 94507 IN A 207.175.42.153 ns2.redhat.com 94507 IN A 208.178.165.229 ns3.redhat.com 94507 IN A 206.132.41.213 speedy.redhat.com 8112 IN A 199.183.24.251 |
要列出完整域,请使用命令
[root@deep] /# host -l <domain names > |
示例 21-4. 列出完整域
[root@deep] /# host -l openna.com |
openna.com name server deep.openna.com openna.com name server mail.openna.com localhost.openna.com has address 127.0.0.1 deep.openna.com has address 208.164.186.1 mail.openna.com has address 208.164.186.2 www.openna.com has address 208.164.186.3 |