查看A记录,例: 查看baidu.com 对应的多个ip (dns 轮询)
>host baidu.com
baidu.com has address 202.108.22.46
baidu.com has address 220.181.38.84
查看别名,例:
>host -t cname gongyi.sina.com.cn
gongyi.sina.com.cn is an alias for ad.sina.com.cn.
查看mx记录,例:
>host -t mx sina.cn
sina.cn mail is handled by 10 sinamx.vip.sina.com.cn.
sina.cn mail is handled by 20 mx2.vip.sina.com.cn.
是否递归, -r 不递归 ,否则递归
-r : 在第一个dns server中没有查到,但不负责去存在的dns上查,只是返回存在该记录的dns
[root@ljj ~]# host -r -v phpor.cn
Trying "phpor.cn"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8681
;; flags: qr ra; QUERY: 1, ANSWER: 0, AUTHORITY: 2, ADDITIONAL: 2
;; QUESTION SECTION:
;phpor.cn. IN A
;; AUTHORITY SECTION:
phpor.cn. 17253 IN NS ns.dns.net.cn.
phpor.cn. 17253 IN NS ns7.dns.net.cn.
;; ADDITIONAL SECTION:
ns7.dns.net.cn. 1812 IN A 61.135.129.16
ns.dns.net.cn. 1812 IN A 61.135.129.2
Received 101 bytes from 10.210.12.10#53 in 34 ms
不使用-r 选项,返回一个查询结果,并且返回2个存在该记录的dns及其ip地址
[root@ljj ~]# host -v phpor.cn
Trying "phpor.cn"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48013
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; QUESTION SECTION:
;phpor.cn. IN A
;; ANSWER SECTION:
phpor.cn. 3600 IN A 61.236.150.132
;; AUTHORITY SECTION:
phpor.cn. 17206 IN NS ns.dns.net.cn.
phpor.cn. 17206 IN NS ns7.dns.net.cn.
;; ADDITIONAL SECTION:
ns7.dns.net.cn. 1765 IN A 61.135.129.16
ns.dns.net.cn. 1765 IN A 61.135.129.2
Received 117 bytes from 10.210.12.10#53 in 42 ms
现在再使用-r 也能取到phpor.cn的ip地址了,因为最近的那个dns已经缓存了该记录,(成为非授权的,即:not authoritative)
[root@ljj ~]#host -r -v phpor.cn
Trying "phpor.cn"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4402
;; flags: qr ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; QUESTION SECTION:
;phpor.cn. IN A
;; ANSWER SECTION:
phpor.cn. 3326 IN A 61.236.150.132
;; AUTHORITY SECTION:
phpor.cn. 16932 IN NS ns.dns.net.cn.
phpor.cn. 16932 IN NS ns7.dns.net.cn.
;; ADDITIONAL SECTION:
ns7.dns.net.cn. 1491 IN A 61.135.129.16
ns.dns.net.cn. 1491 IN A 61.135.129.2
Received 117 bytes from 10.210.12.10#53 in 44 ms
[root@ljj ~]#
注意: host 命令不参考hosts文件