标签:bind9 源码编译安装
1、编译前环境准备
[root@centfils ~]# yum groupinstall "Development Tools" "Server Platform Development"
2、至isc.org bind官网下载bind源码,并展开
[root@centfils ~]# tar xf bind-9.9.9-P2.tar.gz [root@centfils ~]# cd bind-9.9.9-P2
3、创建named用户
[root@centfils bind-9.9.9-P2]# group -r -g 53 named [root@centfils bind-9.9.9-P2]# useradd -u 53 -g named named -r #使用53端口作为named组和named用户的ID号
4、编译安装
[root@centfils bind-9.9.9-P2]# ./configure --prefix=/usr/local/bind9.9 --sysconfdir=/etc/named/ --disable-chroot --enable-threads #指明安装位置,配置文件位置,关闭chroot,开启线程 [root@centfils bind-9.9.9-P2]# make [root@centfils bind-9.9.9-P2]# make install
至此,安装完成,但自行编译bind源码包会产生如下问题
(1)没有配置文件
(2)没有区域解析文件(包括13个根服务器的解析文件)
(3)没有rndc的相关配置文件
解决上述问题
#1、将bind下配置文件加入PATH中 [root@centfils bind9.9]# vim /etc/profile.d/named.sh export PATH=/usr/local/bind9.9/bin:/usr/local/bind9.9/sbin:$PATH [root@centfils bind9.9]# . /etc/profile.d/named.sh #2、导出库文件搜索路径 [root@centfils bind9.9]# vim /etc/ld.so.conf.d/named.conf /usr/local/bind9.9/lib [root@centfils bind9.9]# ldconfig -v #3、导出头文件搜索路径 [root@centfils bind9.9]# ln -sv /usr/local/bind9.9/include /usr/include/named "/usr/include/named" -> "/usr/local/bind9.9/include" #4、导出帮助文档搜索路径 [root@centfils bind9.9]# vim /etc/man.config MANPATH /usr/local/bind9.9/share/man
然后编辑配置文件
[root@centfils bind9.9]# cd /etc/named
[root@centfils named]# vim named.conf
options {
directory "/var/named";
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "locaihost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
[root@centfils named]# mkdir /var/named
[root@centfils named]# named-checkconf
#然后创建各区域的配置文件
[root@centfils named]# cd /var/named
#在联网的情况下直接将查询根的结果导入根区域配置文件
[root@centfils named]# dig -t NS . > /var/named/named.ca
#配置正向解析区域
[root@centfils named]# vim localhost.zone
$TTL 86400
@ IN SOA localhost. admin.localhost. (
2016091301
1H
5M
7D
1D )
IN NS localhost.
localhost. IN A 127.0.0.1
#配置反向解析区域
[root@centfils named]# vim named.local
$TTL 86400
@ IN SOA localhost. admin.localhost. (
2016091301
1H
5M
7D
1D )
IN NS localhost.
1 IN PTR localhost.接下来,更改配置文件的属组和权限
[root@centfils named]# chown :named localhost.zone named.local named.ca [root@centfils named]# chmod 640 localhost.zone named.local named.ca [root@centfils named]# chmod 640 /etc/named/named.conf [root@centfils named]# chown :named /etc/named/named.conf
之后,生成rndc配置文件
[root@centfils ~]# rndc-confgen -r /dev/urandom > /etc/named/rndc.conf
#使用随机数生成rndc.conf文件
[root@centfils ~]# rndc-confgen -r /dev/urandom
# Start of rndc.conf
key "rndc-key" {
algorithm hmac-md5;
secret "3FMQn6XQIuzAXNhl+19EvA==";
};
options {
default-key "rndc-key";
default-server 127.0.0.1;
default-port 953;
};
# End of rndc.conf
#----------------将本段内容复制到named.conf文件中--------------------------------------
# Use with the following in named.conf, adjusting the allow list as needed:
# key "rndc-key" {
# algorithm hmac-md5;
# secret "3FMQn6XQIuzAXNhl+19EvA==";
# };
#
# controls {
# inet 127.0.0.1 port 953
# allow { 127.0.0.1; } keys { "rndc-key"; };
# };
# End of named.conf
#----------------------------------结束------------------------------------------------将文中标识的内容复制到named.conf中,并取消注释
到此,准备工作结束,
[root@centfils named]# named -u named -f -g -d 3 #-u 为指定named用户执行 #-f 为运行在前台 #-g 把标准错误显示出来 #-d 指明调试等级 [root@centfils ~]# ss -tunl | grep 53 udp UNCONN 0 0 192.168.0.196:53 *:* udp UNCONN 0 0 127.0.0.1:53 *:* tcp LISTEN 0 10 192.168.0.196:53 *:* tcp LISTEN 0 10 127.0.0.1:53 *:* #现在53端口已经处于监听状态了
本文出自 “linux启航” 博客,请务必保留此出处http://jiayimeng.blog.51cto.com/10604001/1852411
标签:bind9 源码编译安装
原文地址:http://jiayimeng.blog.51cto.com/10604001/1852411