參考文獻(xiàn)1:https://blog.51cto.com/sw5720/1611777
參考文獻(xiàn)2:https://blog.csdn.net/orapeasant/article/details/1801395
參考文獻(xiàn)3:http://www.linuxfromscratch.org/blfs/view/stable/server/bind.html
1、下載最新bind軟件,此次使用bind-9.12.1.tar.gz
官方網(wǎng)站https://www.isc.org/downloads/
2、解壓至/root下
tar -zxvf bind-9.10.1-P1.tar.gz
3、進(jìn)入解壓后的文件夾
cd bind-9.10.1-P1
4、安裝必備的openssl等插件
yum install gcc gcc-c++ openssl openssl-dev*
5、設(shè)置安裝路徑等參數(shù)、編譯、安裝
創(chuàng)新互聯(lián)網(wǎng)站建設(shè)由有經(jīng)驗(yàn)的網(wǎng)站設(shè)計(jì)師、開(kāi)發(fā)人員和項(xiàng)目經(jīng)理組成的專業(yè)建站團(tuán)隊(duì),負(fù)責(zé)網(wǎng)站視覺(jué)設(shè)計(jì)、用戶體驗(yàn)優(yōu)化、交互設(shè)計(jì)和前端開(kāi)發(fā)等方面的工作,以確保網(wǎng)站外觀精美、成都做網(wǎng)站、成都網(wǎng)站制作易于使用并且具有良好的響應(yīng)性。
- 下面命令參數(shù)為:指定路徑 多線程功能 大文件支持 DNSSEC支持
設(shè)置安裝路徑為/usr/local/named,多線程,大文件支持,DNSSEC支持
#./configure --prefix=/usr/local/named --enable-threads --enable-largefile --with-tuning=large --with-openssl - 創(chuàng)建服務(wù)專用賬戶named,禁止本地登陸
#useradd -d /usr/local/named -s /sbin/nologin named - 編譯
#make - 安裝
#make install - 進(jìn)入安裝后的配置文件夾
#cd /usr/local/named/etc - 生成rndc.conf文件
#/usr/local/named/sbin/rndc-confgen > rndc.conf - 將rndc.conf內(nèi)容導(dǎo)入named.conf
#tail -10 rndc.conf | head -9 | sed s/#\ //g > named.conf - 編輯主配置文件
#vim named.conf
options {
listen-on port 53 { 127.0.0.1; };
directory "/usr/local/named/var"; //域名文件存放的絕對(duì)路徑
pid-file "named.pid";
recursion yes;
allow-query { any; };
recursive-clients 30000;
query-source ...; //如果查不到要解析地址,將會(huì)查詢其它域名服務(wù)器
notify-source ...; //使用本地的源地址和可選的UDP端口,用于發(fā)送NOTIFY消息
};
logging {
channel query_log { //查詢?nèi)罩?br/>file "/var/log/named/query.log" versions 20 size 300m;
severity info;
print-time yes;
print-category yes;
};
channel error_log { //報(bào)錯(cuò)日志
file "/var/log/named/error.log" versions 3 size 10m;
severity info;
print-time yes;
print-severity yes;
print-category yes;
};
category queries { query_log; };
category default { error_log; };
};
zone "." IN {
type hint;
file "named.root"; //存放在//usr/local/named/var目錄
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
}; - 生成根服務(wù)器文件
#cd /usr/local/named/var
#dig @a.root-servers.net . ns > named.root - 創(chuàng)建本地域文件
#vim localhost.zone
$TTL 86400
$ORIGIN localhost.
@ 1D IN SOA @ root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS @
1D IN A 127.0.0.1
#vim named.local
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost. - 創(chuàng)建服務(wù)起停腳本
#vi /etc/rc.d/init.d/named //服務(wù)啟停腳本
#!/bin/bash
named a network name service.
# chkconfig: 345 35 75
# description: a name server
if [ `id -u` -ne 0 ]
then
echo -e "\e[31mERROR:For bind to port 53,must run as root.\e[0m"
exit 1
fi
case "$1" in
start)
if [ -x /usr/local/named/sbin/named ]; then
/usr/local/named/sbin/named -c /usr/local/named/etc/named.conf -u named && echo . && echo -e 'BIND9 server \e[32mstarted\e[0m'
fi
;;
stop)
kill `cat /usr/local/named/var/named.pid` && echo . && echo -e 'BIND9 server \e[33mstopped\e[0m'
;;
restart)
echo .
echo "Restart BIND9 server"
$0 stop
sleep 1
echo -n "." && sleep 2 && echo -n "." && sleep 2 && echo -n "." && sleep 2
$0 start
;;
reload)
/usr/local/named/sbin/rndc reload
;;
status)
/usr/local/named/sbin/rndc status
;;
*)
echo "$0 start | stop | restart |reload |status"
;;
esac
- 更改腳本文件權(quán)限
#chmod 755 /etc/rc.d/init.d/named - 添加至服務(wù)控制
#chkconfig --add named - 為named賦權(quán)限
#chown -R named.named /usr/local/named/ - 創(chuàng)建軟連接
#ln -s /usr/local/named/sbin/named /sbin - 創(chuàng)建日志文件夾
#mkdir /var/log/named/ - 日志文件夾權(quán)限修改
#chown -R named.named /var/log/named/ - 調(diào)試模式測(cè)試是否正常啟動(dòng)
#named -g //調(diào)試模式啟動(dòng) 設(shè)置開(kāi)機(jī)服務(wù)自啟動(dòng)
#chkconfig named on && service named start
- 排錯(cuò),參考http://bbs.chinaunix.net/thread-4187966-1-1.html
啟動(dòng)異常時(shí)查看日志
named -g
tail -n 30 /var/log/messages
分享名稱:centos7安裝bind9.12
URL分享:
http://weahome.cn/article/jhgpio.html