#获取bind软件包
[root@sever ~]# yum install bind -y
DNS正向解析
#服务端主机配置dns服务器主文件
[root@server ~]# vim /etc/named.conf
options {
listen-on port 53 { 192.168.101.200; }; #监听端口53 {服务端主机IP}
directory "/var/named"; #正反解文件默认存储目录
allow-query { any; };};
zone "wechat.com" IN { #正向解析wechat.com
type master; #主服务器类型
file "named.wechat.com"; #区域文件名
};#配置正向解析文件
[root@server ~]# vim /var/named/named.wechat.com
$TTL 1D
@ IN SOA @ admin.wechat.com. (
0
1D
1H
3D
1D )
@ IN NS dns.wechat.com.
dns IN A 192.168.101.200
www IN A 192.168.101.10
en IN A 192.169.101.20
ftp IN A 192.168.101.30
fff IN CNAME ftp
# Generated by NetworkManager#重启服务
[root@server ~]# systemctl restart named#临时更改客户端主机DNS服务器为服务端主机
[root@localhost ~]# vim /etc/resolv.conf
search localdomain
nameserver 192.168.101.200
#客户端主机测试
[root@localhost ~]# dig -t A www.wechat.com @192.168.101.200; <<>> DiG 9.11.26-RedHat-9.11.26-6.el8 <<>> -t A www.wechat.com @192.168.101.200
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38093
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: 93fc8467349314f3065fcad46310b5d24d031b0a92327a37 (good)
;; QUESTION SECTION:
;www.wechat.com. IN A;; ANSWER SECTION:
www.wechat.com. 86400 IN A 192.168.101.10;; AUTHORITY SECTION:
wechat.com. 86400 IN NS dns.wechat.com.;; ADDITIONAL SECTION:
dns.wechat.com. 86400 IN A 192.168.101.200;; Query time: 0 msec
;; SERVER: 192.168.101.200#53(192.168.101.200)
;; WHEN: Thu Sep 01 21:38:32 CST 2022
;; MSG SIZE rcvd: 121
DNS逆向解析
#服务端主机配置dns服务器主文件
[root@sever ~]# vim /etc/namde.conf
zone "101.168.192.in-addr.arpa" IN { #逆向解析192.168.101
type master;
file "named.192.168.101";
};#配置逆向解析文件
[root@server ~]# vim /var/named/named.192.168.101
$TTL 1D
@ IN SOA @ admin.wechat.com. (
0
1D
1H
3D
1D )
@ IN NS dns.wechat.com.
200 IN PTR dns.wechat.com.
10 IN PTR www.wechat.com.
20 IN PTR en.wechat.com.
30 IN PTR ftp.wechat.com.
ftp IN CNAME fff#重启服务
[root@server ~]# systemctl restart named
#客户端主机测试
[root@localhost ~]# nslookup 192.168.101.200
200.101.168.192.in-addr.arpa name = dns.wechat.com.