1、安装bind
#yum -y install bind
#vim /etc/named.conf #修改监听地址
listen-on port 53 { any; };
allow-query { any; }; #可以对我的DNS服务器提出查询请求。any代表任何人
2、增加zone
#vim /etc/named.rfc1912.zones #增加自己需要解析的域名
zone "test.com" IN {
type master;
file "test.com.zone";
};
3、创建test.com.zone
#cp /var/named/named.localhost /var/named/test.com.zone
#vim /var/named/test.com.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
www IN A 192.168.15.101
ui1 IN A 192.168.15.102
4、开放端口
firewall-cmd --add-port=53/tcp --permanent
firewall-cmd --add-port=53/udp --permanent
firewall-cmd --add-port=953/tcp --permanent
firewall-cmd --reload
5、修改本机dns地址为本机ip
#echo "nameserver 192.168.15.101"> /etc/resolv.conf
6、启动bind服务
#chown root:named test.com.zone
#systemctl restart named && systemctl enable named
7、ping测试