源碼安裝bind
網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、小程序開發(fā)、集團企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了鶴城免費建站歡迎大家使用!1.準備源碼包:
bind官網(wǎng):http://www.isc.org/downloads/bind/
[root@dns1 ~]#ll -rw-r--r-- 1 root root 8356463 Dec 11 11:16 bind-9.10.1-P1.tar.gz2.編譯環(huán)境正常,未安裝rpm的bind程序包
[root@dns1 ~]#yumgroupinstall Development tools [root@dns1 ~]#yumgroupinstall Server Platform Development [root@dns1 ~]# rpm-qa bind [root@dns1 ~]#3.編譯安裝源碼包:
解壓源碼:
[root@dns1 ~]#tar jxf bind-9.10.1-P1.tar.gz [root@dns1 ~]#cd bind-9.10.1-P1 [root@dns1bind-9.10.1-P1]#可以從中獲取幫助:
[root@dns1bind-9.10.1-P1]#./configure --help |less
編譯:設(shè)置安裝路徑,程序配置文件路徑,禁用Ipv6,禁用chroot,允許多線程
[root@dns1bind-9.10.1-P1]#./configure --prefix=/usr/local/bind --sysconfdir=/etc/named/ --disable-ipv6 --disable-chroot --enable-threads我這里編譯出現(xiàn)了錯誤,依賴openssl-devel的包:
[root@dns1bind-9.10.1-P1]#yum install openssl-devel重新編譯:
[root@dns1bind-9.10.1-P1]#./configure --prefix=/usr/local/bind --sysconfdir=/etc/named/ --disable-ipv6 --disable-chroot --enable-threads安裝程序:
[root@dns1bind-9.10.1-P1]#make && make install4.盡量加入系統(tǒng)用戶named來管理bind
[root@dns1 ~]#groupadd -r -g 53 named [root@dns1 ~]# useradd-r -g named -u 53 named5.下面即將進行的步驟:
導(dǎo)出程序路徑至PATH中
導(dǎo)出幫助文件
導(dǎo)出庫文件和頭文件:
如果開發(fā)沒用使用其中的庫就不用導(dǎo)出
[root@dns1 ~]#ls /usr/local/bind/sbin/ arpaname dnssec-revoke lwresd named-rrchecker ddns-confgen dnssec-settime named nsec3hash dnssec-dsfromkey dnssec-signzone named-checkconf rndc dnssec-importkey dnssec-verify named-checkzone rndc-confgen dnssec-keyfromlabel genrandom named-compilezone tsig-keygen dnssec-keygen isc-hmac-fixup named-journalprint [root@dns1 ~]#ls /usr/local/bind/bin/ bind9-config delv dig host isc-config.sh nslookup nsupdate [root@dns1 ~]#vim .bash_profile PATH=$PATH:$HOME/bin:/usr/local/bind/bin:/usr/local/bind/sbin [root@dns1 ~]#source .bash_profile6.源碼安裝是沒有任何配置文件和服務(wù)腳本的哦!
#ls/etc/named/ 主配置文件 #ls/var/named/ 區(qū)域解析庫文件 #ls/etc/rc.d/init.d 啟動腳本我們自己來編寫配置文件和服務(wù)腳本哦!
[root@dns1 ~]#mkdir /var/named [root@dns1 ~]#cd /var/named訪問一個能訪問的DNS獲取根區(qū)域文件:
[root@dns1named]# dig -t NS . @172.16.0.1 >/var/named/named.ca [root@dns1named]# ls named.ca編輯好本地解析庫文件:
[root@dns1 named]# vim named.localhost $TTL 1D @ IN SOA @ rname.invalid. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H) ; minimum NS @ A 127.0.0.1[root@dns1 named]#vi named.loopback $TTL 1D @ IN SOA @ rname.invalid. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H) ; minimum NS @ A 127.0.0.1 PTR localhost.權(quán)限設(shè)置和設(shè)置屬組為named:
[root@dns1 named]# chmod 640 * [root@dns1 named]# chown :named * [root@dns1 named]# ll total 12 -rw-r----- 1 root named 2100 Dec 11 11:56named.ca -rw-r----- 1 root named 374 Dec 11 11:57 named.localhost -rw-r----- 1 root named 401 Dec 11 11:58 named.loopback提供主配置文件:named.conf
先設(shè)置好rndc密鑰配置文件:
[root@dns1 named]# rndc-confgen -r /dev/urandom> /etc/named/rndc.conf需要將rndc密鑰文件配置在named.conf文件中:
[root@dns1 named]# cat /etc/named/named.conf options { directory "/var/named"; }; zone "." IN { type hint; file "named.ca"; }; zone "localhost" IN { type master; file "named.localhost"; allow-update { none; }; }; zone "0.0.127.in-addr.arpa" IN { type master; file "named.loopback"; allow-update { none; }; }; # Use with the following in named.conf,adjusting the allow list as needed: key"rndc-key" { algorithm hmac-md5; secret "4a8/AsRRQ5OH5a0oRaBeAg=="; }; # controls{ inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "rndc-key"; }; }; #End of named.conf設(shè)置好文件的權(quán)限和屬組:
[root@dns1 named]# chmod 640 /etc/named/* [root@dns1 named]# chown :named /etc/named/* [root@dns1 named]# ll /etc/named/ total 12 -rw-r----- 1 root named 2389 Dec 11 11:29bind.keys -rw-r----- 1 root named 545 Dec 11 12:09 named.conf -rw-r----- 1 root named 479 Dec 11 12:01 rndc.conf7.到這里我們其實可以啟動named服務(wù)了!
但是有些復(fù)雜,只說一些命令哦!
查看幫助文件
#ls /usr/local/bind9/share/man #man -M /usr/local/bind9/share/man named前臺啟動,日志也在前臺記錄
[root@dns1 named]# named -u named –g
使其在后臺運行:
[root@dns1 named]# named -u named查看啟動狀態(tài):
[root@dns1 named]# ss -tunl |grep :53 udp UNCONN 0 0 172.16.31.100:53 *:* udp UNCONN 0 0 127.0.0.1:53 *:* tcp LISTEN 0 10 172.16.31.100:53 *:* tcp LISTEN 0 10 127.0.0.1:53 *:* tcp LISTEN 0 128 :::53887 :::* [root@dns1 named]# ps aux |grep named named 18870 0.0 1.1 13××× 11848 ? Ssl 12:23 0:00 named -u named root 18883 0.0 0.0 103252 824 pts/1 S+ 12:24 0:00 grep named關(guān)閉named服務(wù):
[root@dns1 named]# killall named [root@dns1 named]# ps aux |grep named root 18887 0.0 0.0 103252 824 pts/1 S+ 12:24 0:00 grep named8.我們現(xiàn)在來實現(xiàn)加入?yún)^(qū)域:
[root@dns1 named]# vim /etc/named/named.conf zone "oracle.com" IN { type master; file "oracle.com.zone"; };設(shè)置區(qū)域正向區(qū)域解析庫文件:
[root@dns1 named]#vim /var/named/oracle.com.zone $ORIGIN oracle.com. @ IN SOA ns.oracle.com. root.oracle.com. ( 2014121101 ;serial 1D ;refresh 5M ;retry 1W ;expiry 1H) ;minimum @ IN NS ns.oracle.com. IN MX 5 mail.oracle.com. ns IN A 172.16.31.100 www IN A 172.16.31.100 www IN A 172.16.31.101 mail IN A 172.16.31.100 pop3 IN CNAME mail iamp4 IN CNAME mail設(shè)置好權(quán)限和屬組:
[root@dns1 named]# chmod 640 oracle.com.zone [root@dns1 named]# chown :named oracle.com.zone啟動named服務(wù):
[root@dns1 named]# named -u named查看日志:
[root@dns1 named]# tail /var/log/messages Dec 11 12:33:41 dns1 named[18945]: automaticempty zone: 8.B.D.0.1.0.0.2.IP6.ARPA Dec 11 12:33:41 dns1 named[18945]: commandchannel listening on 127.0.0.1#953 Dec 11 12:33:41 dns1 named[18945]: the workingdirectory is not writable Dec 11 12:33:41 dns1 named[18945]:managed-keys-zone: loaded serial 0 Dec 11 12:33:41 dns1 named[18945]: zonelocalhost/IN: loaded serial 0 Dec 11 12:33:41 dns1 named[18945]:oracle.com.zone:2: no TTL specified; using SOA MINTTL instead Dec 11 12:33:41 dns1 named[18945]: zoneoracle.com/IN: loaded serial 2014121101 Dec 11 12:33:41 dns1 named[18945]: zone0.0.127.in-addr.arpa/IN: loaded serial 0 Dec 11 12:33:41 dns1 named[18945]: all zonesloaded Dec 11 12:33:41 dns1 named[18945]: running可以查詢了:
[root@dns1 named]# dig -t A www.oracle.com@172.16.31.100 ; <<>> DiG9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6 <<>> -t A www.oracle.com@172.16.31.100 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY,status: NOERROR, id: 15903 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2,AUTHORITY: 1, ADDITIONAL: 1 ;; QUESTION SECTION: ;www.oracle.com. IN A ;; ANSWER SECTION: www.oracle.com. 3600 IN A 172.16.31.101 www.oracle.com. 3600 IN A 172.16.31.100 ;; AUTHORITY SECTION: oracle.com. 3600 IN NS ns.oracle.com. ;; ADDITIONAL SECTION: ns.oracle.com. 3600 IN A 172.16.31.100 ;; Query time: 0 msec ;; SERVER: 172.16.31.100#53(172.16.31.100) ;; WHEN: Thu Dec 11 12:37:19 2014 ;; MSG SIZE rcvd: 97成功了哦!
9.下面就可以進行服務(wù)啟動腳本的書寫了:
我們先將bind的幫助文件寫進/etc/man.config進行調(diào)用:
方便named服務(wù)啟動后生成pid文件:
[root@dns1 named]# chown named:named/usr/local/bind/var/run/ [root@dns1 named]# touch /var/lock/subsys/named [root@dns1 named]# touch /etc/rc.d/init.d/named [root@dns1 named]# chmod 755/etc/rc.d/init.d/named[root@dns1 named]# vim /etc/rc.d/init.d/named #!/bin/bash # named a network name service. # chkconfig: 345 35 75 # description: a name server pidfile=/usr/local/bind/var/run/named/named.pid lockfile=/var/lock/subsys/named conffile=/etc/named/named.conf named=/usr/local/bind/sbin/named prog=named [ -r /etc/rc.d/init.d/functions ] && ./etc/rc.d/init.d/functions start() { if [ -e $lockfile ] ; then echo -n -e "$prog is already running.\n" warning echo -n -e \n exit 0 fi echo -n "Starting $prog:" daemon --pidfile $pidfile $named -u named -c $conffile tetval=$? echo if [[ $retval -eq 0 ]] ; then touch $lockfile return $retval else rm -f $lockfile $pidfile return 1 fi } stop() { if [ ! -e $lockfile ] ; then echo -n "$prog is stopped." warning echo exit 0 fi echo -n "Stopping $prog:" killproc $prog retval=$? echo if [[ $retval -eq 0 ]] ; then rm -f $lockfile $pidfile return 0 else echo "Can't stop $prog" return 1 fi } restart() { stop start } reload() { echo -n "Reload the $prog:" killproc -HUP $prog retval=$? echo return $retval } status() { if pidof $prog &>/dev/null; then echo -n "$prog is running." success echo else echo -n "$prog is stopped." success echo fi } usage() { echo "Usage:named {start|stop|status|reload|restart}" } case $1 in start) start;; stop) stop;; restart) restart;; status) status;; reload) reload;; *) usage exit 1 ;; esac有個bug,warning函數(shù)會覆蓋前面的輸出
我懷疑是warning函數(shù)的問題!
就不管了o(∩_∩)o哈哈
10.最后介紹一下DNS下面的壓力測試工具:queryperf
實際測試要考慮帶寬哦!
[root@dns1bind-9.10.1-P1]# ls contrib dane idn perftcpdns queryperf scripts zkt-1.1.2 dlz nslint-3.0a2 query-loc-0.4.0 README sdb [root@dns1bind-9.10.1-P1]# cd contrib/queryperf/ [root@dns1queryperf]# ls config.h.in configure.in Makefile.in queryperf.c utils configure input missing README簡單編譯安裝:
[root@dns1 queryperf]# make root@dns1 queryperf]# ./configure復(fù)制命令到bin下:
[root@dns1 queryperf]# cp queryperf /bin/開始壓力測試:
queryperf [-d datafile] [-s server_addr] [-p port] [-qnum_queries] [-b bufsize] [-t timeout] [-n] [-l limit] [-f family] [-1] [-i interval] [-r arraysize] [-u unit] [-H histfile] [-T qps] [-e] [-D] [-R] [-c] [-v] [-h] 常用選項: -d datefile:選擇要解析域名集合的文件,對哪些區(qū)域進行測試 -s server_addr:指定壓力測試的服務(wù)器我們需要建立一個解析域名集合的文件:
例如:
[root@dns1 ~]#vi test.txt www.oracle.com A mail.oarcle.com A oracle.com NS oracle.com MX pop3.oracle.com A iamp4.oracle.com A www.oracle.com A mail.oarcle.com A oracle.com NS oracle.com MX pop3.oracle.com A iamp4.oracle.com A簡單測試一下哦!
[root@dns1 ~]# queryperf -d test.txt -s172.16.31.100 DNS Query Performance Testing Tool Version: $Id: queryperf.c,v 1.12 2007/09/0507:36:04 marka Exp $ [Status] Processing input data [Status] Sending queries (beginning with272.16.31.100) [Timeout] Query timed out: msg id 2 [Timeout] Query timed out: msg id 8 [Status] Testing complete Statistics: Parseinput file: once Endeddue to: reaching end of file Queriessent: 12 queries Queriescompleted: 12 queries Querieslost: 0 queries Queriesdelayed(?): 0 queries RTTmax: 0.004873 sec RTTmin: 0.000074 sec RTTaverage: 0.001751 sec RTT stddeviation: 0.001375 sec RTT outof range: 0 queries Percentage completed: 100.00% Percentage lost: 0.00% Startedat: Thu Dec 11 14:05:39 2014 Finished at: Thu Dec 1114:05:44 2014 Ranfor: 5.004047 seconds Queriesper second: 2.398059 qps機器不咋的,處理的慢。
到這里源碼安裝Bind的介紹就結(jié)束了,shell腳本構(gòu)建服務(wù)還是不熟練!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
網(wǎng)頁標題:CentOS6服務(wù)管理之DNS-源碼安裝Bind-9.10-創(chuàng)新互聯(lián)
標題鏈接:http://jinyejixie.com/article28/dehdcp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動態(tài)網(wǎng)站、企業(yè)網(wǎng)站制作、服務(wù)器托管、響應(yīng)式網(wǎng)站、網(wǎng)站設(shè)計、網(wǎng)站收錄
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容