1.安装bind
yum install bind-chroot -y
2.修改DNS服务监听设置
vi /etc/named.conf
将其中的
listen-on port 53 { 127.0.0.1; }; 修改为 listen-on port 53 { any; };
allow-query { localhost; }; 修改为 allow-query { any; };
3.新建该DNS的域
vi /etc/named.rfc1912.zones
追加以下内容:
zone "coretek.com" IN {
type master;
file "coretek.com.zone";
allow-update { none; };
};
zone "1.168.192.in-addr.arpa" IN {
type master;
file "192.168.2.arpa";
allow-update { none; };
};
检查一下配置看是否报错:
named-checkconf
4.新建该域的正向配置文件
cd /var/named
touch coretek.com.zone
chown named:named coretek.com.zone
vi coretek.com.zone
在该.zone文件内增加如下内容:
$TTL 1D
@ IN SOA test.com. rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
ns IN A 192.168.2.244
node1 IN A 192.168.2.245
node2 IN A 192.168.2.246
node3 IN A 192.168.2.250
5.新建该域的反向配置文件:
touch 192.168.2.arpa
chown root:named 192.168.2.arpa
vi 192.168.2.arpa
复制如下内容在这个新建文件中:
$TTL 1D
@ IN SOA test.com. rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS @
A 127.0.0.1
AAAA ::1
PTR localhost.
ns IN A 192.168.2.244
244 IN PTR ns.test.com
245 IN PTR node1.test.com
246 IN PTR node2.test.com
250 IN PTR node3.test.com
6.启动前检查防火墙等
named-checkzone "test.com" /var/named/test.com.zone
zone test.com/IN: loaded serial 0
OK
named-checkzone "192.168.2.in-addr.arpa" /var/named/192.168.2.arpa
OK
7.启动DNS服务
注意启动前将本机配置的DNS服务器IP改为新建的DNS服务器IP
systemctl restart network
systemctl start named
测试:
nslookup + IP/Domainname
例如:
nslookup node1.test.com