>>>安装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
>>>解析测试
dig abc.com @x.x.x.x #x.x.x.x为DNS服务器IP
dig www.abc.com @x.x.x.x