DNS部署(3)———源碼b
- 2020 年 1 月 6 日
- 筆記
其實一般使用redhat或centos中自帶的rpm安裝bind是十分簡單的,但是源碼安裝可以讓你對bind文件的整體結構有了更好的認識
先下載一個源碼包:https://www.isc.org/downloads/bind/
直接下載即可。
進入目錄後就可以編譯了,對於編譯的模塊就不細說了直接查詢即可。
但是有幾個模塊是必須要裝的gcc、openssl和perl的相關組件,如果不想安裝必須用–without把模塊排除在外,下面開始編譯:
直接安裝即可
安裝好後,就得到了這倆個文件夾
下面就開始寫named的各種配置文件,相對於rpm包,源碼包裝出來什麼都沒有。。。
首先要創建一個named系統用戶
完成腳本的鏈接:
寫入後要記得用 —————source加載
1、在/etc/named/中創建named.conf文件
在配置文件的目錄中就會有這麼幾個文件,修改它們權限為named!!!!
配置文件大致上就設置好了,下面就要根據named.conf中指定寫zone文件了
一個個開始編寫吧
在編寫localhost.zone和named.local文件
開始服務即可
這樣就算是安裝完成了,當然還可以寫一個啟動腳本放到/etc/init.d/下面,就完美了
#/bin/bash #chkconfig 2345 70 50 #description named #author joe [ -r /etc/init.d/functions ] && . /etc/init.d/functions //判斷functions庫函數是否可讀 Pidfile="/usr/local/bind9/var/run/named.pid"//默認pid路路徑 Lockfile="/var/lock/subsys/named"//腳本鎖文件 named="named"//服務 start() { [ -x "/usr/local/bind9/sbin/$named" ] || exit 4 if [ -f $Lockfile ];then echo "the $named is already running" exit 5 fi echo -n "starting $named " daemon --pidfile "$Pidfile" /usr/local/bind9/sbin/$named -u named -4 RETAVL=$? echo if [ $RETAVL -eq 0 ];then touch $Lockfile return 0 else rm -f $Lockfile $Pidfile return 1 fi } stop(){ if [ ! -f $Lockfile ];then echo "the $named is stopped.... " exit 5 fi echo -n "stopping the $named.." killproc $named RETAVL=$? echo if [ $RETAVL -eq 0 ];then rm -f $Lockfile fi } reload(){ if [ ! -f $Lockfile ];then echo "the $named is stopped " exit 5 fi echo -n "reload the config file" killproc $named -HUP RETAVL=$? echo } status(){ if pidof $named &>/dev/null && [ -f $Pidfile ];then echo "the $named is starting" else echo "the $named is stopped" fi } case $1 in start) start ;; stop) stop ;; reload) reload ;; restart) stop sleep 1 start ;; status) status ;; *) echo "Usage:||" ;; esac