实验环境:服务器IP192.168.10.30
客户端IP:192.168.10.40(客户端dns必须指向服务器IP)
[root@host ~] yum install bind bind-utils.x86_64 -y
[root@host ~] vim /etc/bind.conf
options {
listen-on port 53 { any; }; #修改为监听为所有 any
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
secroots-file "/var/named/data/named.secroots";
recursing-file "/var/named/data/named.recursing";
allow-query { any; }; #修改允许查询为所有人 any
[root@host ~]vim /etc/named.rf1912.zones
#在最后添加
zone "test.com" IN { #正向解析
type master;
file "zheng"; #正向解析文件的路径
allow-update { none; };
};
zone "10.168.192.in-addr.arpa" IN { #反向解析
type master;
file "fan"; #反向解析文件的路径
allow-update { none; };
};
[root@host ~] cd /var/named/
[root@host ~]cp -p named.localhost zhengt #复制正向解析模板
[root@host ~]cp -p named.loopback fan #辅助反向解析模板
[root@host ~]vim zheng
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
aaa A 192.168.10.30 #添加a记录
bbb A 192.168.10.40 #添加b记录
[root@host ~]vim fan
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
PTR localhost.
30 PTR aaa.test.com. #添加RTR指针记录
bbb A 192.168.10.40 #添加RTR指针记录
[root@host ~]systemctl restart named #重启
[root@host ~]firewall-cmd --add-service=dns #开启防火墙
[root@host ~]nslookup #使用测试工具来进行检测
> server 192.168.10.30 #服务器IP
Default server: 192.168.10.30
Address: 192.168.10.30#53
> aaa.test.com
Server: 192.168.10.30
Address: 192.168.10.30#53
Name: aaa.test.com
Address: 192.168.10.30
> 192.168.10.30
30.10.168.192.in-addr.arpa name = aaa.test.com.
> exit #得出以上结果则实验成功