DNS工具

1.安装

~]# yum install bind-utils

2.nslookup命令

交互式

[root@hdss7-11 named]# nslookup
> server 10.4.7.11
Default server: 10.4.7.11
Address: 10.4.7.11#53
> hdss7-11.host.com
Server:		10.4.7.11
Address:	10.4.7.11#53

Name:	hdss7-11.host.com
Address: 10.4.7.11
/------------------------------------------------------------------以上是权威应答
> www.baidu.com
Server:		10.4.7.11
Address:	10.4.7.11#53

Non-authoritative answer:     --非权威应答
www.baidu.com	canonical name = www.a.shifen.com.
Name:	www.a.shifen.com
Address: 39.156.66.18
Name:	www.a.shifen.com
Address: 39.156.66.14
Name:	www.a.shifen.com
Address: 2409:8c00:6c21:104f:0:ff:b03f:3ae
Name:	www.a.shifen.com
Address: 2409:8c00:6c21:104c:0:ff:b02c:156c
/--------------------------------------------------------------------以上是非权威应答

非交互式

[root@hdss7-11 named]# nslookup www.baidu.com
Server:		10.4.7.11
Address:	10.4.7.11#53

Non-authoritative answer:
www.baidu.com	canonical name = www.a.shifen.com.
Name:	www.a.shifen.com
Address: 39.156.66.18
Name:	www.a.shifen.com
Address: 39.156.66.14
Name:	www.a.shifen.com
Address: 2409:8c00:6c21:104f:0:ff:b03f:3ae
Name:	www.a.shifen.com
Address: 2409:8c00:6c21:104c:0:ff:b02c:156c

3.host命令

[root@hdss7-11 named]# host -t A hdss7-12.host.com
hdss7-12.host.com has address 10.4.7.12
[root@hdss7-11 named]# host -t A hdss7-12.host.com 10.4.7.11
Using domain server:
Name: 10.4.7.11
Address: 10.4.7.11#53
Aliases: 
hdss7-12.host.com has address 10.4.7.12


[root@hdss7-12 named]# host -t PTR 12.7.4.10.in-addr.arpa 10.4.7.11
Using domain server:
Name: 10.4.7.11
Address: 10.4.7.11#53
Aliases: 

12.7.4.10.in-addr.arpa domain name pointer HDSS7-12.host.com.
[root@hdss7-12 named]# host -t PTR 12.7.4.10.in-addr.arpa 10.4.7.12
Using domain server:
Name: 10.4.7.12
Address: 10.4.7.12#53
Aliases: 

12.7.4.10.in-addr.arpa domain name pointer HDSS7-12.host.com.

4.dig命令

参数 说明
+tcp 使用tcp
+notcp 使用udp
+norecurse 使用迭代算法
+recurse 使用递归算法
+short 直接返回应答段
@x.x.x.x 指定dns服务器
  • 查询A记录
[root@hdss7-12 named]# dig -t A hdss7-11.host.com @10.4.7.11

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> -t A hdss7-11.host.com @10.4.7.11
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44452
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;hdss7-11.host.com.		IN	A                    //问 hdss7-11  的A记录是哪个ip

;; ANSWER SECTION:
hdss7-11.host.com.	60	IN	A	10.4.7.11      //应答段

;; AUTHORITY SECTION:                        //返回的ns记录
host.com.		600	IN	NS	ns1.od.com.
host.com.		600	IN	NS	ns2.od.com.

;; ADDITIONAL SECTION:                      //附加,把ns的A记录也查出来了
ns1.od.com.		60	IN	A	10.4.7.11
ns2.od.com.		60	IN	A	10.4.7.12

;; Query time: 0 msec
;; SERVER: 10.4.7.11#53(10.4.7.11)
;; WHEN: Thu Dec 26 03:54:37 CST 2019
;; MSG SIZE  rcvd: 133
  • 查询PTR记录
[root@hdss7-12 named]# dig -t PTR 11.7.4.10.in-addr.arpa. @10.4.7.11 +short
HDSS7-11.host.com.
[root@hdss7-12 named]# dig -x 10.4.7.11 @10.4.7.11 +short
HDSS7-11.host.com.

5.nsupdate命令(仅交互式)

注意:不常用,需要在zone配置文件里声明allow-update { acl; };
nsupdate不会写到区域文件,它会写到xxx.jnl 日志文件

[root@hdss7-11 named]# nsupdate 
> server 10.4.7.11 
> update add 13.7.4.10.in-addr.arpa. 60 PTR hdss7-13.host.com. 
> send 
> quit

[root@hdss7-11 named]# nsupdate 
> server 10.4.7.11 
> update del 13.7.4.10.in-addr.arpa. 60 PTR hdss7-14.host.com. 
> send 
> quit

[root@hdss7-11 named]# nsupdate 
> server 10.4.7.11 
> update del 13.7.4.10.in-addr.arpa. 60 PTR hdss7-13.host.com. 
> update add 13.7.4.10.in-addr.arpa. 60 PTR hdss7-14.host.com. 
> send > quit

nsupdate使用小结:

  • 优点:命令简单,便于记忆

不在手动变更SOA的serial序列号,自动滚动
不需要重启重载bind9服务/配置,生效快
可以通过配置acl实现远程管理

  • 缺点:jnl文件无法使用文本文件的方式打开

只能依赖完全区域传送查看所有的区域的记录
更新操作复杂,先删后增
远程管理有安全隐患,需要加审计
动态域在rndc管理上多一步

原文地址:https://www.cnblogs.com/wangchaolinux/p/12103357.html