通过host命令测试
$ host www.baidu.com 192.168.3.102
Using domain server:
Name: 192.168.3.102
Address: 192.168.3.102#53
Aliases:
www.baidu.com is an alias for www.a.shifen.com.
www.a.shifen.com has address 14.119.104.189
www.a.shifen.com has address 14.119.104.254
扩展命令
$ host [-t type] name [SERVER]
$ host –t NS abcd.com 172.16.0.1
$ host –t soa abcd.com
$ host –t mx abcd.com
$ host –t axfr abcd.com
$ host 1.2.3.4
通过dig命令测试
$ dig www.baidu.com @192.168.3.102
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.9 <<>> www.baidu.com @192.168.3.102
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64530
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 5, ADDITIONAL: 10
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.baidu.com. IN A
;; ANSWER SECTION:
www.baidu.com. 1048 IN CNAME www.a.shifen.com.
www.a.shifen.com. 149 IN A 14.119.104.189
www.a.shifen.com. 149 IN A 14.119.104.254
;; AUTHORITY SECTION:
a.shifen.com. 1049 IN NS ns4.a.shifen.com.
a.shifen.com. 1049 IN NS ns2.a.shifen.com.
a.shifen.com. 1049 IN NS ns3.a.shifen.com.
a.shifen.com. 1049 IN NS ns1.a.shifen.com.
a.shifen.com. 1049 IN NS ns5.a.shifen.com.
;; ADDITIONAL SECTION:
ns5.a.shifen.com. 1049 IN A 180.76.76.95
ns1.a.shifen.com. 1049 IN A 110.242.68.42
ns2.a.shifen.com. 1049 IN A 220.181.33.32
ns3.a.shifen.com. 1049 IN A 36.152.45.198
ns3.a.shifen.com. 1049 IN A 112.80.255.253
ns4.a.shifen.com. 1049 IN A 111.20.4.28
ns4.a.shifen.com. 1049 IN A 14.215.177.229
ns5.a.shifen.com. 449 IN AAAA 240e:bf:b801:1006:0:ff:b04f:346b
ns5.a.shifen.com. 449 IN AAAA 240e:940:603:a:0:ff:b08d:239d
;; Query time: 4 msec
;; SERVER: 192.168.3.102#53(192.168.3.102)
;; WHEN: 五 4月 07 09:24:11 CST 2023
;; MSG SIZE rcvd: 359
$ dig www.baidu.com @dns22.hichina.com.
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.9 <<>> www.baidu.com @dns22.hichina.com.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 48083
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.baidu.com. IN A
;; AUTHORITY SECTION:
baidu.com. 600 IN SOA ns1.alidns.com. hostmaster.hichina.com. 2022052002 3600 1200 86400 600
;; Query time: 45 msec
;; SERVER: 39.96.153.61#53(39.96.153.61)
;; WHEN: 五 4月 07 09:26:31 CST 2023
;; MSG SIZE rcvd: 114
补充
抓取dns服务器上相关域名的所有解析
格式:dig -t axfr 域名
$ dig -t axfr hxg.com
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.9 <<>> -t axfr hxg.com
;; global options: +cmd
hxg.com. 86400 IN SOA master.hxg.com. hexuguang_94.163.com. 0 86400 3600 604800 10800
hxg.com. 86400 IN NS master.hxg.com.
*.hxg.com. 86400 IN CNAME a.hxg.com.
a.hxg.com. 86400 IN A 10.0.0.11
a.hxg.com. 86400 IN A 10.0.0.12
master.hxg.com. 86400 IN A 10.0.0.11
www.hxg.com. 86400 IN CNAME a.hxg.com.
hxg.com. 86400 IN SOA master.hxg.com. hexuguang_94.163.com. 0 86400 3600 604800 10800
;; Query time: 0 msec
;; SERVER: 10.0.0.11#53(10.0.0.11)
;; WHEN: 六 4月 08 15:41:16 CST 2023
;; XFR size: 8 records (messages 1, bytes 230)
通过nslookup
交互模式访问
使用方式
nslookup>
server IP: 指明使用哪个DNS server进行查询
set q=RR_TYPE: 指明查询的资源记录类型
NAME: 要查询的名称
例子
$ nslookup
#手动指定dns服务器地址
> server 192.168.3.102
Default server: 192.168.3.102
Address: 192.168.3.102#53
#输入需要解析的地址
> www.baidu.com
Server: 192.168.3.102
Address: 192.168.3.102#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 14.215.177.38
Name: www.a.shifen.com
Address: 14.215.177.39
>
命令模式
命令格式nslookup [-option] [name | -] [server]
例子
$ nslookup www.baidu.com 192.168.140.3
#格式 nslookup 待解析域名 dns服务器地址
Server: 192.168.140.3
Address: 192.168.140.3#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 14.119.104.189
Name: www.a.shifen.com
Address: 14.119.104.254
标签:baidu,www,hxg,192.168,DNS,测试工具,86400,com
From: https://www.cnblogs.com/guangdelw/p/17300869.html