Biny

Centos7 Bind 9.9.7 利用RPM源码 编译 安装 测试

Biny 2015-07-08 12:26:21    81 次浏览


Centos7 Bind 9.9.7 利用RPM源码 编译 安装 测试

bind下载地址 http://www.isc.org/downloads/
系统:CentOs7.0
(bind编译安装需要gcc,请确保你的机器上已经安装gcc)

1.执行命令 tar -xvzf Bind-9.10.1.tar.gz
2.进入到解压后的文件夹
执行命令 ./configure --prefix=/usr/local/named (指定安装目录)
如果提示需要 openssl。 执行命令 yum install openssl。
安装完成,继续执行./configure --prefix=/usr/local/named

发现还是失败 执行命令 yum install openssl-devel
安装完成,继续执行./configure --prefix=/usr/local/named
发现还是失败,根据提示需要安装perl
执行命令 yum install perl

安装完成,继续执行./configure --prefix=/usr/local/named

发现已经没有错误
继续执行命令 make

然后执行命令 make install
安装完成
3.配置Bind;
进入到Bind安装目录 /usr/local/named/ 可以看到如下目录结构


1.执行命令 /usr/local/named/sbin/rndc-confgen > /usr/local/named/etc/rndc.conf
2.执行命令 tail -10 rndc.conf | head -9 | sed s/# //g > /usr/local/namde/etc/named.conf

3.执行命令 vi named.conf 加入以下内容


    [*]options {
    [*]directory "/usr/local/named/var";
    [*]pid-file "named.pid";
    [*]};
    [*]
    [*]zone "." IN {
    [*] type hint;
    [*] file "named.root";
    [*]};
    [*]
    [*]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; };
    [*]};
    [*]
    [*]zone "test.com" IN {
    [*] type master;
    [*] file "test.zone";
    [*] allow-update { none; };
    [*]};
    [*]
    [*]
    [*]zone "1.168.192.in-addr.arpa" in {
    [*] type master;
    [*] file "test.local";
    [*] allow-update { none; };
    [*]};


4.进入到 /usr/var/local/named/var 目录下

执行命令 vi 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.


执行命令 vi 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


执行命令 dig > named.root (如果你的系统没有dig命令,你需要安装 bind-utils包)执行命令 vi test.local 加入如下内容



    [*]$TTL 86400
    [*]@ IN SOA ns1.test.com. root.test.com.(
    [*]20031001;
    [*]7200;
    [*]3600;
    [*]43200;
    [*]86400);
    [*]@ IN NS ns1.test.com.
    [*]168 IN PTR ns1.test.com.


执行命令 vi test.zone 加入如下内容


    [*]$TTL 86400 ; 1 day
    [*]@ IN SOA ns1.test.com. root.test.com. (
    [*] 2008050122 ; serial
    [*] 28800 ; refresh (8 hours)
    [*] 7200 ; retry (2 hours)
    [*] 604800 ; expire (1 week)
    [*] 86400 ; minimum (1 day)
    [*] )
    [*] NS ns1.test.com.
    [*] A 192.168.1.168
    [*] MX 10 mail.test.com.
    [*]www A 192.168.1.168
    [*]mail A 192.168.1.168
    [*]ns1 A 192.168.1.168


4 执行命令 vi /etc/resolv.conf 修改nameserver 为本机ip (因为我是在一台机器上测试,本机即用来做DNS服务器,也用来做测试机) 启动Bind 执行命令 /usr/local/named/sbin/named


5 测试,执行命令 nslookup test.com

执行命令 nslookup www.test.com


6 dig测试 ,执行命令 dig @192.168.108.180 test.com (192.168.108.180是我本机ip)

PS:安装过程中可能出现的错误


提示没有安装gcc [root@bind9 bind-9.9.0]# yum install gcc
[root@bind9 bind-9.9.0]# ./configure --prefix=/usr/local/named
checking for OpenSSL library... configure: error: OpenSSL was not found in any of /usr
/usr/local /usr/local/ssl /usr/pkg /usr/sfw; use --with-openssl=/path
If you don't want OpenSSL, use --without-openssl
[root@bind9 bind-9.9.0]#
提示没有OpenSSL
[root@bind9 bind-9.9.0]# yum install openssl
[root@bind9 bind-9.9.0]# ./configure --prefix=/usr/local/named
checking for OpenSSL library... configure: error: OpenSSL was not found in any of /usr
/usr/local /usr/local/ssl /usr/pkg /usr/sfw; use --with-openssl=/path
If you don't want OpenSSL, use --without-openssl
[root@bind9 bind-9.9.0]#
安装完还是提示Openssl,还的安装如下包
[root@bind9 bind-9.9.0]# yum install openssl-devel
[root@bind9 bind-9.9.0]# ./configure --prefix=/usr/local/named
checking whether to use purify... no
configure: error: Internal symbol table requires perl but no perl is found.
Install perl or explicitly disable the feature by --disable-symtable.
[root@bind9 bind-9.9.0]#
又提示perl没装,没办法 ,继续安装吧
[root@bind9 bind-9.9.0]# yum install perl
[root@bind9 bind-9.9.0]# ./configure --prefix=/usr/local/named
config.status: creating lib/tests/include/Makefile
config.status: creating lib/tests/include/tests/Makefile
config.status: creating unit/Makefile
config.status: creating unit/unittest.sh
config.status: creating config.h
config.status: executing chmod commands
./configure: line 29289: make: command not found
[root@bind9 bind-9.9.0]#
哎呦还是没成功,接着往下看
[root@bind9 bind-9.9.0]# yum groupinstall "Development Tools"
[root@bind9 bind-9.9.0]# yum groupinstall "Development Libraries"


内容加载中