依赖包安装yum -y install libcap libcap-devel libuv libuv-devel openssl-devel
配置安装./configure --prefix=/root/a --sysconfdir=/etc/named --localstatedir=/var --with-libtool --disable-chroot --disable-static
1、报错:configure: error: Python >= 2.7 or >= 3.2 and the PLY package are required for dnssec-keymgr and other Python-based tools.
PLY may be available from your OS package manager as python-ply or python3-ply; it can also be installed via pip. To build without Python/PLY, use --without-python.
安装pip3 install ply
2、安装这个:yum install -y epel-release libuv libuv-devel libcap-devel
否则报错:checking for libuv... checking for libuv >= 1.0.0... no
configure: error: libuv not found
3、报错:configure: error: sys/capability.h header is required for Linux capabilities support. Either install libcap or use --disable-linux-caps.
安装yum install libcap-devel
创建named用户及相关目录。
使用53端口作为named组和named用户的ID号
groupadd -g 53 -r named
useradd -u 53 -s /sbin/nolgin -r named -g named
编译安装make && make install
找见sbin目录(配置那步安装的目录)
cd /root/a/sbin/
创建rndc.conf文件
./rndc-confgen > /etc/named/rndc.conf
进入
cd /etc/named/
创建named.conf文件夹 然后添加配置
tail -10 rndc.conf | head -9 | sed -e s/# //g > named.conf
编辑named.conf
options {
directory "/var/named";
pid-file "/var/named/named.pid";
dump-file "/var/named/cache_dunmp.db";
statistics-file "/var/named/named_stats.txt";
version none;
hostname none;
allow-query { any; };
listen-on port 53 { 本机ip地址; };
querylog yes;
max-cache-size 0M;
allow-recursion {none;};
allow-transfer {none;};
allow-update { none; };
};
logging {
channel query_syslog { syslog local3; severity info; print-time yes; };
channel query_log {
file "/var/dnslog/query.log" versions 5 size 500m;
print-time yes;
severity info;
};
category queries { query_log;};
channel general_log {
file "/var/dnslog/general_log" versions 5 size 500m;
print-time yes;
print-category yes;
print-severity yes;
severity info;
};
category default { general_log; };
category general { general_log; };
};
#系统生成的参数
include "/etc/named/view.conf";
添加service named start 启动
进入cd /etc/init.d/
#!/bin/bash
##chkconfig: 545 35 75
##description: named DNS service manager
data=" /root/a/sbin/named -u named -c /etc/named/named.conf -4"
function START(){
eval $data && echo -e "BIND9 start 33[32m ok 33[0m"
}
function STOP(){
kill `cat /var/named/named.pid` && echo -e "BIND9 stop 33[32m ok 33[0m"
}
function RELOAD(){
/root/a/sbin/rndc reload
}
case "$1" in
start)
START
;;
reload)
RELOAD
;;
stop)
STOP
;;
restart)
STOP
sleep 3
START
;;
*)
echo "Usage: named (start|stop|restart|reload)"
;;
esac
添加可执行权限
chmod +x named
mkdir -p /var/named
添加目录权限
chown root:named /var/named/
chmod 770 /var/named/
mkdir -p /var/run/named
chown named:named /var/run/named
mkdir -p /var/dnslog/
chown named:named /var/dnslog
添加全局命令
vim /etc/profile
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/a/sbin/:/root/a/bin/
source /etc/profile #更新