>>>安装bind服务器
yum install -y bind*
>>>启动DNS服务
systemctl start named
systemctl enable named
>>>修改主配置文件
vi /etc/named.conf
listen-on port 53 { any; }; #127.0.0.1修改为any
allow-query { any; }; # localhost修改为any
>>>添加域名解析区域
vi /etc/named.rfc1912.zones
zone "abc.com" IN {
type master;
file "abc.com.zone";
allow-update { none; };
};
>>>添加域名及A记录
vi /var/named/abc.com.zone
$TTL 3H @ IN SOA @ abc.com. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @ A 1.2.3.4 www A 2.3.4.5
域名abc.com绑定ip:1.2.3.4
www子域名绑定ip:2.3.4.5
>>>添加反向解析
添加反向解析区域
vi /etc/named.rfc1912.zones
zone "3.2.1.in-addr.arpa" IN {
type master;
file "abc.com.zone";
allow-update {none; };
};
添加PTR记录
vi /var/named/abc.com.zone
$TTL 3H @ IN SOA @ abc.com. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @ A 1.2.3.4 www A 2.3.4.5
4 PTR abc.com.
>>>重启DNS服务,使配置生效
systemctl restart named
>>>解析测试
dig abc.com @x.x.x.x # x.x.x.x为DNS服务器IP
dig www.abc.com @x.x.x.x
dig -x 1.2.3.4 @x.x.x.x # 测试DNS反向解析