下载所需的版本
https://gitlab.isc.org/isc-projects/bind9/-/tags?sort=version_desc
搜索自己需要的版本,然后点击下载
安装
#新建用户
$ groupadd -g 53 -r named
$ useradd -u 53 -g 53 -r named
#解压源码包
$ tar xf bind9-v9_11_36.tar.gz
$ cd bind9-v9_11_36/
#安装必要库
$ yum grouplist "Development Tools" -y
$ yum install -y python3 openssl-devel
$ pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple ply
#编译安装
$ ./configure --prefix=/usr/local/named --sysconfdir=/etc/named
$ make && make install
#新建配置文件
$ vim /etc/named/named.conf
options {
directory "/usr/local/named";
dump-file "/usr/local/named/data/cache_dump.db";
statistics-file "/usr/local/named/data/named_stats.txt";
memstatistics-file "/usr/local/named/data/named_mem_stats.txt";
recursing-file "/usr/local/named/data/named.recursing";
secroots-file "/usr/local/named/data/named.secroots";
allow-transfer {none;};
recursion yes;
dnssec-enable no;
dnssec-validation no;
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
# 生成named.ca文件
$ dig -t NS . @a.root-servers.net > /usr/local/named/named.ca
#创建默认的rndc.key文件
$ rndc-confgen -a
#创建数据文件夹
$ mkdir /usr/local/named/data
$ ln -s /usr/local/named/sbin/* /usr/local/sbin/
$ ln -s /usr/local/named/bin/* /usr/local/sbin/
#修改相关文件权限
$ chown -R named:named /etc/named/
$ chown -R named:named /usr/local/named/
#以named用户启动
$ named -g -u named
编写管理脚本
$ vim /usr/lib/systemd/system/named.service
[Unit]
Description=Berkeley Internet Name Domain (DNS)
After=network.target
[Service]
Type=forking
Environment=NAMEDCONF=/etc/named/named.conf
PIDFile=/usr/local/named/var/run/named/named.pid
ExecStart=/usr/local/named/sbin/named -u named -c ${NAMEDCONF}
ExecReload=/bin/sh -c '/usr/local/named/sbin/rndc reload > /dev/null 2>&1 || /bin/kill -HUP $MAINPID'
ExecStop=/bin/sh -c '/usr/local/named/sbin/rndc stop > /dev/null 2>&1 || /bin/kill -TERM $MAINPID'
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重新加载
$ systemctl daemon-reload
标签:named,file,data,sbin,编译,usr,版本,bind9,local
From: https://www.cnblogs.com/guangdelw/p/17300839.html