您好,登錄后才能下訂單哦!
源碼安裝bind
1.準(zhǔn)備源碼包:
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.gz
2.編譯環(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)了錯(cuò)誤,依賴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 install
4.盡量加入系統(tǒng)用戶named來(lái)管理bind
[root@dns1 ~]#groupadd -r -g 53 named [root@dns1 ~]# useradd-r -g named -u 53 named
5.下面即將進(jìn)行的步驟:
導(dǎo)出程序路徑至PATH中
導(dǎo)出幫助文件
導(dǎo)出庫(kù)文件和頭文件:
如果開(kāi)發(fā)沒(méi)用使用其中的庫(kù)就不用導(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_profile
6.源碼安裝是沒(méi)有任何配置文件和服務(wù)腳本的哦!
#ls/etc/named/ 主配置文件 #ls/var/named/ 區(qū)域解析庫(kù)文件 #ls/etc/rc.d/init.d 啟動(dòng)腳本
我們自己來(lái)編寫(xiě)配置文件和服務(wù)腳本哦!
[root@dns1 ~]#mkdir /var/named [root@dns1 ~]#cd /var/named
訪問(wèn)一個(gè)能訪問(wèn)的DNS獲取根區(qū)域文件:
[root@dns1named]# dig -t NS . @172.16.0.1 >/var/named/named.ca [root@dns1named]# ls named.ca
編輯好本地解析庫(kù)文件:
[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.conf
7.到這里我們其實(shí)可以啟動(dòng)named服務(wù)了!
但是有些復(fù)雜,只說(shuō)一些命令哦!
查看幫助文件
#ls /usr/local/bind9/share/man #man -M /usr/local/bind9/share/man named
前臺(tái)啟動(dòng),日志也在前臺(tái)記錄
[root@dns1 named]# named -u named –g
使其在后臺(tái)運(yùn)行:
[root@dns1 named]# named -u named
查看啟動(dòng)狀態(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 named
8.我們現(xiàn)在來(lái)實(shí)現(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ū)域解析庫(kù)文件:
[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
啟動(dòng)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.下面就可以進(jìn)行服務(wù)啟動(dòng)腳本的書(shū)寫(xiě)了:
我們先將bind的幫助文件寫(xiě)進(jìn)/etc/man.config進(jìn)行調(diào)用:
方便named服務(wù)啟動(dòng)后生成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
有個(gè)bug,warning函數(shù)會(huì)覆蓋前面的輸出
我懷疑是warning函數(shù)的問(wèn)題!
就不管了o(∩_∩)o 哈哈
10.最后介紹一下DNS下面的壓力測(cè)試工具:queryperf
實(shí)際測(cè)試要考慮帶寬哦!
[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
簡(jiǎn)單編譯安裝:
[root@dns1 queryperf]# make root@dns1 queryperf]# ./configure
復(fù)制命令到bin下:
[root@dns1 queryperf]# cp queryperf /bin/
開(kāi)始?jí)毫y(cè)試:
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] 常用選項(xiàng): -d datefile:選擇要解析域名集合的文件,對(duì)哪些區(qū)域進(jìn)行測(cè)試 -s server_addr:指定壓力測(cè)試的服務(wù)器
我們需要建立一個(gè)解析域名集合的文件:
例如:
[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
簡(jiǎn)單測(cè)試一下哦!
[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
機(jī)器不咋的,處理的慢。
到這里源碼安裝Bind的介紹就結(jié)束了,shell腳本構(gòu)建服務(wù)還是不熟練!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。