bind 9.10编译安装

---1.环境配置

--1.1SELinux
/usr/sbin/sestatus -v | grep "SELinux status"

vi /etc/selinux/config

SELINUX=disabled




---1.2.配置yum源

cd /etc/yum.repos.d

mv CentOS-Base.repo CentOS-Base.repo.old

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo


yum makecache


检查可更新的rpm包
#yum check-update
    
更新所有的rpm包
#yum update

--1.3 安装上传软件

yum install lrzsz -y 


二、 所需软件 

https://www.isc.org/downloadables/下载bind软件.


编译安装之前将系统默认安装的卸载!

--2.1 解压、安装

#mkdir -p /soft
# tar xvzf bind-9.10.3-P2.tar.gz && cd bind-9.10.3-P2/

# ./configure --prefix=/usr/local/bind  --enable-threads --enable-largefile --disable-ipv6
# make  && make install




安装好以后查看其版本:
# /usr/local/bind/sbin/named -v
BIND 9.10.3-P2 <id:f9be8b2>


--2.2 主配置文件



#cd /usr/local/bind/etc/

#/usr/local/bind/sbin/rndc-confgen > rndc.conf

#cat rndc.conf > rndc.key

#chmod 777 /usr/local/bind/var

#tail -10 rndc.conf | head -9 | sed s/#\ //g > named.conf


#vi /usr/local/bind/etc/named.conf

options {
        directory "/usr/local/bind/var";
	 pid-file "named.pid"; 
};

zone "." {
        type hint;
        file "named.ca";
};




*****************备注
options {
directory "/usr/local/bind/var";          //域名文件存放的绝对路径
pid-file "named.pid";              //如果bind启动,自动会在/usr/local/bind/var/目录生成一个named.pid文件,打开文件就是named进程的ID
};
zone "." IN {
        type hint;          //根域名服务器
        file "named.ca"; //存放在/usr/local/bind/var/目录,文件名为named.ca
};



*****************备注



--2.3 挖掘DNS工具,查看根(这里要到官方网站上更新DNS文件,
服务器IP地址需要能够上网)

# dig -t NS .

产生named.ca文件
# dig -t NS . >/usr/local/bind/var/named.ca



--2.4 运行DNS服务
#/usr/local/bind/sbin/named

#tail /var/log/messages




--2.5 检查状态

# /usr/local/bind/sbin/rndc status
WARNING: key file (/usr/local/bind/etc/rndc.key) exists, but using default configuration file (/usr/local/bind/etc/rndc.conf)
version: BIND 9.10.3-P2 <id:f9be8b2>
boot time: Tue, 12 Jan 2016 03:14:10 GMT
last configured: Tue, 12 Jan 2016 03:14:10 GMT
CPUs found: 1
worker threads: 1
UDP listeners per interface: 1
number of zones: 99
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
recursive clients: 0/0/1000
tcp clients: 0/100
server is up and running


/*******************




查看日志文件

#cat /var/log/messages  | grep named


配置DNS(通过自己的计算机解析DNS)---可选
# echo "nameserver 127.0.0.1" >/etc/resolv.conf




三、添加本地DNS服务器解析文件

# ln -s /usr/local/bind/etc/named.conf /etc/

--3.1正向解析

# vi /etc/named.conf

#正向解析
zone "localhost"{
        type master;
        file "localhost.zone";
};

zone "jinri.com"{
        type master;
        file "jinri.com.zone";
};


# vi /usr/local/bind/var/localhost.zone

$TTL  38400
@ IN    SOA     localhost.      root (
                2009040701      ;serial
                1H              ;refresh
                15M             ;retry
                1W              ;expire
                1D )            ;TTL
  IN    NS      @
  IN    A       127.0.0.1


#chmod 640 /usr/local/bind/var/localhost.zone

# vi /usr/local/bind/var/jinri.com.zone

$TTL  38400
@ IN    SOA     bind.jinri.com.  root (
                2009040701      ;serial
                1H              ;refresh
                15M             ;retry
                1W              ;expire
                1D )            ;TTL
@	IN    NS      bind
@       IN    MX 10   mail
bind     IN    A           192.168.1.140
mail     IN    A           192.168.1.140
storage     IN    A        192.168.50.88
node01      IN    A        192.168.50.100
node02      IN    A        192.168.50.200

#chmod 640 /usr/local/bind/var/jinri.com.zone




链接bind命令

ln -s /usr/local/bind/sbin/* /usr/bin/

重新加载
# rndc reload


---3.2 反向解析文件
# vi /etc/named.conf

#反向解析

zone"0.0.127.in-addr.arpa" in {
	type master;
	file "named.local";
	allow-update { none; };
};


zone "50.168.192.in-addr.arpa" in {
	type master;
	file "jinri.local";
	allow-update { none; };
};


# vi /usr/local/bind/var/named.local
------------------------------------------
$TTL  38400
0.0.127.in-addr.arpa. IN SOA  bind.china.com. root(
	2009040701 ;serial
	3H ; refresh
	15M ;retry
	1W  ;expiry
	1D) ;minimum
	IN NS 	 bind.jinri.com.
1	IN PTR   bind.jinri.com.
	




# vi /usr/local/bind/var/jinri.local
------------------------------------------
$TTL  38400
50.168.192.in-addr.arpa. IN SOA bind.jinri.com. root(
	2009040701;serial
	3H ; refresh
	15M ;retry
	1W  ;expiry
	1D) ;minimum
	IN NS 	   bind.jinri.com.
88	IN PTR     storage.jinri.com.
100	IN PTR     node01.jinri.com.
200	IN PTR     node02.jinri.com.




#named-checkconf

测试配置:
正向解析:成功!
反向解析:成功!没有50的记录!所以不能成功!




------4.验证DNS

--4.1 修改服务器的nameserver

echo "nameserver 223.5.5.5" >/etc/resolv.conf

--4.2 测试

# dig -t A node01.jinri.com @192.168.1.140

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 <<>> -t A node01.jinri.com @192.168.1.140
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 59819
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;node01.jinri.com.		IN	A

;; Query time: 0 msec
;; SERVER: 192.168.1.140#53(192.168.1.140)
;; WHEN: Tue Jan 12 11:46:11 2016
;; MSG SIZE  rcvd: 34



# nslookup
> set q=A
> node01.jinri.com
Server:		127.0.0.1
Address:	127.0.0.1#53

Name:	node01.jinri.com
Address: 192.168.50.100
> node02.jinri.com
Server:		127.0.0.1
Address:	127.0.0.1#53

Name:	node02.jinri.com
Address: 192.168.50.200
> storage.jinri.com
Server:		127.0.0.1
Address:	127.0.0.1#53

Name:	storage.jinri.com
Address: 192.168.50.88


你可能感兴趣的:(bind,bind源码,bind编译安装,bind编译)