正向解析
服务器
1.装包
[root@localhost ~]# yum install bind -y
2.定义bind主配置文件
[root@localhost ~]# vim /etc/named.conf
options {
listen-on port 53 { 192.168.108.132; };
directory "/var/named";
};
zone "openlab.com" IN {
type master;
file "named.openlab.com";
};
3.定义文件
vim /var/named/named.openlab.com
$TTL 1D
@ IN SOA @ root.localhost. (
2023071200
2D
4H
1D
1D )
IN NS dns.openlab.com.
dns IN A 192.168.108.132
www IN A 192.168.108.100
ftp IN A 192.168.108.111
w3 IN CNAME www
4.关防火墙重启
[root@localhost ~]# systemctl restart named
[root@localhost ~]# systemctl disable firewalld --now
客户端
改dns服务器
namesever 192.168.108.132
测试
[root@localhost ~]# host www.openlab.com
[root@localhost ~]# nslookup www.openlab.com
反向解析
1.装包
[root@localhost ~]# yum install bind -y
2.定义bind主配置文件加一条
[root@localhost ~]# vim /etc/named.conf
options {
listen-on port 53 { 192.168.10.130; };
directory "/var/named";
};
zone "openlab.com" IN {
type master;
file "named.openlab.com";
};
zone "10.168.192.in-addr.arpa" IN {
type master;
file "named.192";
};
3.定义文件
[root@localhost ~]# cat /var/named/named.192
$TTL 1D
@ IN SOA @ root.localhost. (
2023071200
2D
4H
1D
1D )
@ IN NS dns.openlab.com.
132 IN PTR dns.openlab.com.
100 IN PTR www.openlab.com.
111 IN PTR ftp.openlab.com.
4.关防火墙重启
[root@localhost ~]# systemctl restart named
[root@localhost ~]# systemctl disable firewalld --now
5.客户端测试
[root@localhost ~]# nslookup192.168.108.132