一)、DNS服务搭建
使用bind搭建dns服务:
yum install -y bind
yum install -y bind-utils
cp /etc/named.conf /etc/named.conf.bak
>/etc/named.conf
vim /etc/named.conf
123456789101112131415 options {
directory "/var/named";
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
};
chown named /etc/named.conf
cd /var/named/
dig -t NS . > named.ca
vim localhost.zone
123456789 @ IN SOA localhost. admin.localhost. (
2013081601
1H
10M
7D
1D
)
@ IN NS localhost.
localhost. IN A 127.0.0.1
vim named.loca
12345678910 $TTL 86400
@ IN SOA localhost. admin.localhost. (
2013081601
1H
10M
7D
1D
)
@ IN NS localhost.
1 IN PTR localhost.
做到这里呢,我们的主配置文件及域配置文件基本就搭建好了。但是呢,这里我们就要注意了,假如你的selinux是开着的话呢,接下来的步骤呢就不好做下去了,你可以通过getenforce命令来查看是否关闭。所以呢,你不妨先关闭下你的selinux啦,你选择永久关闭呢,就进入到/etc/selinux/config将SELINUX修改成disabled就可以啦。OK,我们就继续走着。。。。
检测配置是否有问题: named-checkconf
检测正解析: named-checkzone "localhost" /var/named/localhost.zone
检测反解析: named-checkzone "0.0.127.in-addr.arpa" /var/named/named.local
如果都“OK”那就可以了
rndc-confgen -r /dev/urandom -a // 这一步是生成 rndc.key, 如果没有这个key namd 是启动不了的
chown named:named /etc/rndc.key
/etc/init.d/named start
netstat -lnp |grep named // 查看一下named进程是否监听了53端口
首先测试正向解析:dig @127.0.0.1 localhost.
接着测试反解析:dig @127.0.0.1 -x 127.0.0.1
都正常了,那么我呢就加个域名来试试。。。
vim /etc/named.conf 后面增加