bind-9.9.5编译安装

bind-9.9.5编译安装

§·bind-9.9.5编译安装大概步骤

步骤一 :下载源码包bind-9.9.5

步骤二 :按需求选择模块或功能 ./configure  

# ./configure  –prefix=/usr/local/bind9  –sysconfdir=/etc/named/ –disable-ipv6

–disable-chroot –enable-threads

步骤三 make & make install

步骤四 :配置PATH的环境变量,使得bind9的命令可以生效 ;

环境变量:
•vim  /etc/profile.d/named.sh
export PATH=/usr/local/bind9/bin:/usr/local/bind9/sbin/:$PATH

步骤五 :配置头文件路径,设置库文件路径,设置man帮助文件路径;

库文件设置
•vim /etc/ld.so.conf.d/named.conf
/usr/local/bind9/lib
•ldconfig -v
头文件设置
•ln  -sv /usr/local/bind9/include   /usr/include/named

步骤六 :添加系统组和系统账户;

# groupadd  -r  -g  53  named
# useradd  -r  -u  53   -g  53  named

步骤 创建系统文件 named.conf   ;  mkdir   /var/named/ /var/named/named.ca ;

步骤 创建boss区域,创建区域文件 //var/named/boss.com.zone ;

步骤 :启动服务和测试

•named -u named -f -g -d 3 前端级别3方式运行  #前台方式运行
•named -u named         #后台方式运行
•killall  named        #关闭named服务
•ss  -uln          #查看端口号
•tail  /var/log/message       #查看消息

步骤十 :配置rndc管理dns服务器

rndc  reload 看报错提示

rndc  -confgen  -r /dev/urandom  >  /etc/named/rndc.conf 生成key #生成对称密钥文件

tail /etc/named/rndc.conf  >> /etc/named/named.conf #查看说明的文件,把相应的数据拷贝到对应的文件

killall  -SIGHUP  named       #重启named服务

rndc  status          #测试named的状态

小结:
以上的编译完成后,许多的DNS服务器上的文件不会自动生成,都需要自己手动的创建:
比如:主配置文件 named.conf ,named.ca等等文件;
手动的修改配置文件或新建配置文件一定要记得文件权限问题,named用户需要有读权限的。

 

§·bind-9.9.5编译详细安装步骤

※·步骤一 :下载源码包bind-9.9.5

下载源码包到 /usr/src/bind/目录中,并解压

[root@root-server bind]# pwd
/usr/src/bind
[root@root-server bind]# ll
total 7556
drwxr-xr-x. 12 10292 9901    4096 Sep 27 08:55 bind-9.9.5
-rw-r--r--.  1 root  root 7729695 Mar 11  2014 bind-9.9.5.tar.gz
[root@root-server bind]#

※·步骤二 :按需求选择模块或功能 ./configure 

进入bind-9.9.5目录,查看下 ./configure的主要选项参数

[root@root-server bind-9.9.5]#  ./configure  --help
...................................................................
Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX  #工作目录的指定参数
                          [/usr/local]
 
Fine tuning of the installation directories:
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]    #配置文件主目录
 
 
Optional Features:            #配置工作特性
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-shared[=PKGS]  build shared libraries [default=yes]
                          [default=no]
  --enable-ipv6           use IPv6 default=autodetect    #启用ipv6的支持
  --enable-getifaddrs     Enable the use of getifaddrs() [yes|no].
  --disable-isc-spnego    use SPNEGO from GSSAPI library
  --disable-chroot        disable chroot       #禁用切根的功能
  --with-python=PATH      Specify path to python interpreter  #python 应用程序工作目录
  --with-openssl=PATH     Build with OpenSSL yes|no|path.   # openssl 应用程序工作目录
  (Required for DNSSEC)
  --with-ecdsa            OpenSSL ECDSA
  --with-gost             OpenSSL GOST

 

configure 配置参数:

./configure –prefix=/usr/local/bind9 –sysconfdir=/etc/named9 –disable-ipv6 –disable-chroot –enable-threads

#--prefix=/usr/local/bind9   #bind的工作主目录设置
#--sysconfdir=/etc/named9   #bind的配置文件目录
#--disable-ipv6     #禁用ipv6的功能
#--disable-chroot     #禁用chroot功能 
#--enable-threads     #开启

 

bind对于.configure参数的说明:

--prefix=/usr/local/bind       指定bind9的安装目录,默认是/usr/local
--enable-threads            开启多线程的支持;如果你的系统有多个CPU,那么可以使用这个选项
--disable-openssl-version-check  关闭openssl的检查
--with-openssl=/usr/local/openssl 指定openssl的安装路径
--sysconfdir=/etc            设置named.conf配置文件放置的目录,默认是--prefix选项指定的目录下的/etc下
--localstatdir=/var           设置 run/named.pid 放置的目录,默认是--prefix选项指定的目录下的/var下
--with-libtool              将BIND的库文件编译为动态共享库文件,这个选项默认是未选择的。
                        如果不选这个选项,那么编译后的named命令会比较大,lib目录中的库文件都是.a后缀的
                        如果选上这个选项,那么编译后的named命令会很小,lib目录中的库文件则是.so后缀

※·步骤三 make & make install

./configure 没有问题,make make install后即可

※·步骤四 :配置PATH的环境变量

# –prefix=/usr/local/bind9  #bind的工作主目录设置

# –sysconfdir=/etc/named9  #bind的配置文件目录

 

[root@root-server bind9]# pwd    #进入编译安装bind的工作目录中
/usr/local/bind9
[root@root-server bind9]# ls
bin   #bind的用户应用程序存放路径
include   #bind的头文件存放路径
lib   #bind的库文件存放路径
sbin   #bind的管理员应用程序存放路径
share  
var

需要让系统PATH环境变量添加 bin  与  sbin添加到PATH中:

[root@root-server bind9]# cat  /etc/profile.d/named.sh   #在该目录下编辑文件文件内容如下
export PATH=/usr/local/bind9/bin:/usr/local/bind9/sbin/:$PATH  #申明环境变量
 
[root@root-server bind9]# source   /etc/profile.d/named.sh   #立即生效PATH
 
[root@root-server bind9]# echo $PATH #查看PATH的环境变量
/usr/local/bind9/bin:/usr/local/bind9/sbin/:/usr/lib64/qt-3.3/bin:/usr/local/bind9/bin:/usr/local/bind9/sbin/:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/http2/bin:/root/bin

 

※·步骤五 :配置头文件路径,设置库文件路径,设置man文件路径

系统头文件默认加载的文件为:vim /etc/ld.so.conf.d/目录。只需要在该目录下写一个文件文件内容如下:

 

vim /etc/ld.so.conf.d/named.conf

/usr/local/bind9/lib

]#ldconfig  #重新加载所有的动态库文件

 

系统库文件默认路径为:/usr/include/

ln  -sv  /usr/local/bind9/include  /usr/include/named

 

安装bindman帮助文件

vim /etc/man_db.conf

MANDATORY_MANPATH   /usr/local/bind9/share/man

※·步骤六 :添加系统组和系统账户

添加的账户是用来启动named服务进程的。

# groupadd-r -g 53 named
# useradd-r -u 53 -g 53 named
[root@root-server ld.so.conf.d]# getent passwd | grep named
named:x:53:53::/home/named:/bin/bash
[root@root-server ld.so.conf.d]# getent group | grep named
named:x:53:
[root@root-server ld.so.conf.d]#

※·步骤 创建系统文件 

touch   /etc/named/named.conf  #创建主配置文件。

mkdir /var/named #创建区域文件存放目录。

touch /var/named/named.ca #存放根服务器地址

配置named.conf文件内容:

  1 options {
  2         directory "/var/named/";
  3         };
  4  zone "." IN {
  5         type hint;
  6         file "named.ca";
  7         };

#一定注意文件的权限,named用户对文件具有独权限。

※·步骤 创建boss.com区域

主配置文件中配置的区域名称

 19  zone "boss.com" IN {
 20          type master;
 21          file "boss.com.zone";
 22   };

区域文件内容

[root@root-server ld.so.conf.d]# cat /var/named/boss.com.zone 
$TTL 3600
@ IN SOA ns1.boss.com.  admin.boss.com.  (  1  1D  1M  7D 1D   )
 
IN NS ns1
ns1 IN A 10.1.16.10
www IN A 10.1.16.10
ftp IN CNAME www
bbs IN CNAME www
pop3 IN CNAME www
 
[root@root-server ld.so.conf.d]#

※·步骤 :启动服务和测试

named -u named -f -g -d 3  #前端级别3方式运行

#named服务在前提执行,通过ctrl + c 来关闭named程序

named -u named  #后台运行

[root@root-server ld.so.conf.d]# named -u named
[root@root-server ld.so.conf.d]# ps aux | grep named
named     34128  0.1  1.4 185956 14564 ?        Ssl  15:16   0:00 named -u named
root      34134  0.0  0.0 112644   952 pts/1    S+   15:16   0:00 grep --color=auto named
[root@root-server ld.so.conf.d]#

killall  named

#named在后台运行时, killall  named 结束进程

ss -uln

[root@root-server ld.so.conf.d]# ss -uln
State       Recv-Q Send-Q            Local Address:Port                           Peer Address:Port              
UNCONN      0      0                             *:47755                                     *:*                  
UNCONN      0      0                             *:59063                                     *:*                  
UNCONN      0      0                             *:5353                                      *:*                  
UNCONN      0      0                 192.168.122.1:53                                        *:*                  
UNCONN      0      0                  10.1.249.124:53                                        *:*                  
UNCONN      0      0                   122.122.0.1:53                                        *:*                  
UNCONN      0      0                    10.1.16.10:53                                        *:*                  
UNCONN      0      0                     127.0.0.1:53                                        *:*                  
UNCONN      0      0                 192.168.122.1:53                                        *:*                  
UNCONN      0      0                      *%virbr0:67                                        *:*                  
UNCONN      0      0                             *:68                                        *:*                  
UNCONN      0      0                            :::17332                                    :::*                  
[root@root-server ld.so.conf.d]#

 

※·步骤十 :配置rndc管理dns服务器

编译安装bind默认情况下 rndc程序不能管理dns服务器,会报以下的错误:

[root@root-server named9]# rndc status
rndc: neither /etc/named9/rndc.conf nor /etc/named9/rndc.key was found
[root@root-server named9]#

需要使用以下命令生成key才可以是rndcdns服务器通过对称密钥加密通信:

 

rndc-confgen  -r  /dev/urandom  >  /etc/named/rndc.conf 生成key (生成的文件保存为 rndc.conf

#   -r  /dev/urandom : 随机数不够,从设备中取随机数

[root@root-server named9]# rndc-confgen -r /dev/urandom > /etc/named9/rndc.conf
[root@root-server named9]# ll
total 12
-rw-r-----. 1 named named 2389 Sep 27 08:58 bind.keys
-rw-r-----. 1 named named  511 Sep 27 10:18 named.conf
-rw-r--r--. 1 root  root   479 Sep 27 15:21 rndc.conf
[root@root-server named9]# cat  rndc.conf 
# Start of rndc.conf ##放在rndc.conf文件中的开始
key "rndc-key" {
algorithm hmac-md5;
secret "tbAdp4Kp1L8YDo+aGY4Ajw==";
};
 
options {
default-key "rndc-key";
default-server 127.0.0.1;
default-port 953;
};
# End of rndc.conf ##放在rndc.conf文件中的结束
 
# Use with the following in named.conf, adjusting the allow list as needed:
# key "rndc-key" { ##放在named.conf文件中的开始
#  algorithm hmac-md5;
#  secret "tbAdp4Kp1L8YDo+aGY4Ajw==";
# };
# 
# controls {
#  inet 127.0.0.1 port 953
#   allow { 127.0.0.1; } keys { "rndc-key"; };
# };
# End of named.conf ##放在named.conf文件中的结束
[root@root-server named9]#

 

tail /etc/named/rndc.conf >> /etc/named/named.conf

把刚刚生成的rndc.conf信息追加到 named.conf文件中

[root@root-server named9]# tail rndc.conf >> named.conf

killall -SIGHUP named

重新加载named的配置文件

 

rndc status

[root@root-server named9]# rndc status
version: 9.9.5 <id:f9b8a50e>
CPUs found: 2
worker threads: 2
UDP listeners per interface: 2
number of zones: 101
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
[root@root-server named9]#

 

 

原创文章,作者:linux_root,如若转载,请注明出处:http://www.178linux.com/49504

(0)
上一篇 2016-10-09 09:02
下一篇 2016-10-09 09:05

相关推荐

  • 推荐-Nginx Proxy模块的应用之负载均衡

    Ngnix Proxy模块的应用之负载均衡 Ngnix Proxy模块的应用之负载均衡 Proxy 模块介绍 实验环境 配置Proxy Proxy 模块介绍   在我之前的文章提到过,Nginx可以提供反向代理加速、基于应用层的负载均衡并能对后端服务器做健康状态检测。下面我们就动手操作一下,看如何实现上述功能。 实验环境 主机名称 主要功能 外网地址 内网地…

    Linux干货 2016-03-27
  • find可以这么用

    在工作中不可或缺的工具find:查找系统中的各种文件,对查找的文件进行操作,这就是find的作用。进入正题: 1、查找下系统中有一下系统中有几个文件叫issue的     [root@localhost private]#find / -name issue      …

    Linux干货 2017-03-05
  • Shell脚本编程初步

        shell是指一种应用程序,这个应用程序提供了一个界面,用户通过这个界面访问操作系统内核的服务。shell脚本(shell script),是一种为shell编写的脚本程序。业界所说的shell通常都是指shell脚本,但shell和shell script是两个不同的概念。shell编程跟java、php编程…

    Linux干货 2016-08-24
  • 玩转Nginx之一:基础概念

    Nginx web服务器:http协议 http协议:html,MIME(多用途互联网邮件拓展) major/minor text/html,text/plain,image/jpeg web资源:URL(scheme://server:port/path/to/source) 方法:GET,HEAD(相应首部)读取资源 POST提交表单 PUT上传数据 D…

    Linux干货 2016-10-29
  • 10.脚本练习2

    1、请详细描述CentOS系统的启动流程(详细到每个过程系统做了哪些事情) POST –> Boot Sequence(BIOS) –> Boot Loader(MBR)   –> Kernel+ramdisk(initrd) –> rootfs –> /sbin/init   –> (/etc/inittab…

    2017-09-20
  • AWK小记

    gawk – pattern scanning and processing language 基本用法:gawk [options] ‘program’ FILE … program: PATTERN{ACTION STATEMENTS} 语句之间用分号分隔 print, printf 选项: -F:指明输入…

    2018-01-16