源码安装bind9

从源代码包安装BIND9

Posted on 2004年10月3日 16:56

ISC BIND 是 DNS 在 Unix 和 Linux 下的具体实现,BIND 9 更是重新编写大部分 BIND 结构代码的新一代版本,BIND 9 的主要特点有:

  • DNS安全
        DNSSEC (signed zones)
        TSIG (signed DNS requests)
  • IPv6
        Answers DNS queries on IPv6 sockets
        IPv6 resource records (DNAME, etc.)
        Experimental IPv6 Resolver Library
  • 实现了 DNS 协议新扩展的功能
        IXFR, DDNS, Notify, EDNS0
        Improved standards conformance
  • 视图功能(Views)
        一台服务器可以提供DNS名字空间的多个视图
  • 支持多处理器
  • 增强了代码的可移植性

BIND 9的当前最新版本是 BIND 9.3.0,下面我们介绍如何从源代码安装 BIND 9。

1、从源代码安装BIND要求你的Unix或Linux系统上装有支持ANSI C的编译器,如果没有,你可以使用GNU提供的gcc

2、到
www.isc.org 网站下载你需要的版本的BIND源代码包

3、下载到你的系统后,将源代码安装包放到 /usr/src 目录中(你也可以放到别的目录,我习惯用这个目录放置源代码包)准备安装

4、解压源代码包:
   $ cd /usr/src
   $ tar xvfz bind-9.3.0.tar.gz (9.3.0是bind的版本号)

   如果你的 tar 命令不支持z选项(用于解压gz后缀的压缩包),你可以分两步做:
   $ gunzip bind-9.3.0.tar.gz
   $ tar xvf bind-9.3.0.tar
   这样源代码就解压到 bind-9.3.0目录中了。

5、开始编译:
   $ cd bind-9.3.0
   $ ./configure
    
   正像单词的意思一样,configure 是编译前对源代码进行针对具体操作系统的编译参数配置,有很多选项可以选择,大家可以用 --help 选项来查看所有可用的选项,这里介绍几个最常用的选项:
      --prefix=/usr/local/bind       设置bind的安装目录,默认是/usr/local。
                                             有的人喜欢将bind安装在单独的目录就可以如此设置
      --sysconfdir=/etc/bind         设置named.conf配置文件放置的目录,默认是"$prefix/etc"
      --localstatdir=/var               设置 run/named.pid 放置的目录,默认是"$prefix/var"
      --with-libtool                      将BIND的库文件编译为动态共享库文件,这个选项默认是未选择的。
                                              如果不选这个选项,那么编译后的named命令会比较大,lib目录中的库文件都是.a后缀的
                                              如果选上这个选项,那么编译后的named命令会很小,lib目录中的库文件则是.so后缀
      --enable-threads                 如果你的系统有多个CPU,那么可以使用这个选项

   如果 ./configure 没有报错的话,那么就可以开始编译源代码了。
   $ make

   编译需要一小会时间,编译完成后则开始安装BIND,安装需要 root 用户权限,所以要先转换成root用户。
   $ su -
   # make install

   这样BIND9就已经安装完成了,但要让BIND能正常工作,还需要做一些配置。下面介绍配置最简单的 bind cache server。由于本文是希望让 DNS 的初学者能尽快的配置出服务器,因此未详细解释一些细节。推荐初学者详读《dns and bind》。

   named.conf 文件是 BIND 的配置文件,配置如下:

=============
named.conf
=============
options {
   directory "/var/bind";
   listen-on-v6 { none };                      // 禁止IPv6的功能
   listen-on { 127.0.0.1; };                    // 如果你有多个网卡,而你只想监听特定的一个网卡,就可以使用这个选项
   pid-file "/var/run/named.pid";       // 设置 named 进程运行时记录PID号的文件
};

zone "." IN {
   type hint;
   file "named.cache";
};

zone "localhost" IN {
   type master;                                  // 区的类型设置为 master
   file "localhost.zone";                  // 区数据文件的位置
   allow-update { none; };             // 不允许动态更新本区的数据
   notify no;                                     // 由于不允许动态更新,那么就不需要更新通知的功能
};

zone "127.in-addr.arpa" IN {
   type master;
   file "127.zone";
   allow-update { none; };
   notify no;
};

下面是三个 zone 所需要的区配置文件:

=============
named.cache
=============
这个文件记录了所有根 dns 服务器的信息,是由 www.internic.net 维护的,一般好几年才变动一次。你可以到 ftp://ftp.rs.internic.net/domain/named.cache 去下载,这里就不列出来了。

=============
localhost.zone
=============
$TTL 1W
@         IN         SOA         ns.localhost. root.localhost. (
                                            2004100501 ; Serial
                                            28800    ; Refresh
                                            14400      ; Retry
                                            604800     ; Expire - 1 week
                                            86400 )    ; Minimum

                          IN           NS           ns
localhost.         IN          A              127.0.0.1

=============
127.zone
=============
$ORIGIN 127.in-addr.arpa.
$TTL 1W
@            1D  IN  SOA               localhost. root.localhost. (
                                                     2004100501 ; Serial
                                                     3H    ; Refresh
                                                     15M    ; Retry
                                                     1W    ; Expire
                                                     1D )    ; Minimum

                1D  IN  NS                  localhost.
*              1D  IN  PTR               localhost.

这样所有的配置文件就搞定了。不过如果你希望你的 named 进程能够更安全一些,那么你可以将 named 进程用专门的一个用户(比如:named 用户)来运行,而不是用权限最大的 root 用户来运行。操作步骤如下:

1、创建 named 用户,记得将用户的 shell 设置为无法登陆的类型。
2、chown root /etc/bind/named.conf
      chmod 644  /etc/bind/named.conf
3、chown named /var/bind/*
      chmod 644 /var/bind/*
5、启动 named 进程时使用 -u named 选项。

这样子一个最简单的 cache server 就配置好了。记得启动 named 进程后,查看一下 syslog 看看是否有出错信息,然后用 nslookup 或 dig 命令测试看看。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
DNS解析BIND 9(适用于WINDOWS桌面系统) 完全改进: Security Fixes Treat an all zero netmask as invalid when generating the localnets acl to workaround bug on Windows platform. [CVE-2013-6230] [RT #34687] Fix crashes when serving some NSEC3 signed zones. memcpy was incorrectly called with overlapping ranges, resulting in malformed names being generated on some platforms. This could cause INSIST failures. (CVE 2014-0591) [RT #35120] Features Changes Add the ability to specify ndots to "nslookup". [RT #34711] Introduce a new tool "dnssec-importkey" to allow externally-generated DNSKEY to be imported into the DNSKEY management framework. [RT #34698] Check that EDNS subnet client options are well formed. [RT #34718] "named" now preserves the capitalization of names when responding to queries. [RT #34737] Include a comment in .nzf files (used for adding new zones via "rndc"), giving the name of the associated view. [RT #34765] Use separate rate limiting queues for refresh and notify requests. [RT #30589] Adjust when a master server is deemed unreachable to be less aggressive. [RT #27075] Create delegations for all "children" of empty zones except "forward first". [RT #34826] Changed the name of "isc-config.sh" developers script (for outputting compiler and linker flags) to "bind9-config". [RT #23825] Add "dig" option to keep the TCP socket open between successive queries (+[no]keepopen). [RT #34918] Add dns_client_createx2() function to DNS Client API to provide a way to specify the local address for use when sending update packets. [RT #34811] "named-checkconf -z" now checks zones of type hint as well as master. [RT #35046] Update config.guess and config.sub to add support for ppc64le (powerpc 64-bit Little Endian). [RT #35060] Update the Windows build system to support feature selection and WIN64 builds. This is a work in progress. [RT #34160] Add "dnssec-signzone -Q" switch to drop signatures from keys that are still published but no longer active. [RT #34990] Add a more detailed "not found" message to "rndc" commands which specify a zone name. [RT #35059] named will now warn when a zone's configured "key-directory" does not exist or is not a directory. [RT #35108] Added improvements to statistics channel XSL stylesheet: the stylesheet can now be cached by the browser; section headers are omitted from the stats display when there is no data in those sections to be displayed; counters are now right-justified for easier readability. (Only available with ./configure --enable-newstats.) [RT #35117] "named-checkconf" can now obscure shared secrets when printing by specifying '-x'. [RT #34465] "named" can now accept integer timestamps in RRSIG records. [RT #35185] The export-library API call for loading "resolv.conf", irs_resconf_load(), has been modified to return ISC_R_FILENOTFOUND when the file does not exist and initializes the resconf structure as if the file had existed and configured with nameservers at the localhost addresses (127.0.0.1 and ::1). [RT #35194] Bug Fixes Treat type 65533 (KEYDATA) as opaque except when used in a key zone. [RT #34238] Fix "host" and "nslookup" so don't need dot after the domain by checking ndots when searching. Only continue searching on NXDOMAIN responses. [RT #34711] Handle changes to sig-validity-interval settings better. [RT #34625] Fix bug where journal filename string could be set incorrectly, causing garbage in log messages. [RT #34738] Address a race condition when shutting down a zone. [RT #34750] Address race condition with manual notify requests. [RT #34806] Fix nslookup crash where some readline clones don't accept NULL pointers when calling add_history. [RT #34842] Fix Linux compilation issue when libcap-devel is installed. [RT #34838] Fix installation on Solaris -- don't add explicit make dependencies/rules for python programs as make won't use the implicit rules. [RT #34835] Fix hanging server with inline-signed zones by addressing lock order reversal deadlock with inline zones. [RT #34856] Fix "host" failure if a UDP query timed out. [RT #34870] Address bugs in dns_rdata_fromstruct and dns_rdata_tostruct for WKS and ISDN types. [RT #34910] Updated OpenSSL PKCS#11 patches to fix active list locking and other bugs. [RT #34855] Fix a potential hang with failure to release lock on error in receive_secure_db. #34944] Fix cast in lex.c which could see 0xff treated as EOF. This fixes issue with potential bad data in a database used by DLZ or SDB. [RT #34993] Fix build issue on newer FreeBSD needing -lhx509 for GSSAPI build. [RT #35001] Address read after free in server side of lwres_getrrsetbyname. [RT #29075] Fix "nsupdate" memory leak if "realm" was used multiple times. [RT #35073] Fix "dig" for cleaning up TCP sockets still waiting on connect(). [RT #35074] Fix "dnssec-importkey" so imported key won't overwrite an existing non-imported private key. Fix issue where queries covered by a disabled Response Policy Zone (query type was '*') are answered with TTL of 0. [RT #35026] Fix "nsupdate" memory leak if "realm" was used multiple times. [RT #35073] Fix "dig" for cleaning up TCP sockets still waiting on connect(). [RT #35074] Fix issue with "rndc retransfer" with inline-signing replacing NSEC3 with NSEC records. [RT #34745] Fix issue with "rndc refresh" failing to sign slave zones using inline-signing. [RT #35105] Fix potential hang (detected by our inline-signing system test) with null pointer dereference in libdns zone_xfrdone. [RT #35042] Address bug in libdns loadnode function that could return a freed node on out of memory. [RT #35106] Fixed a bug causing an insecure delegation from one "static-stub" zone to another to fail with a broken trust chain. [RT #35081] Fixed problem where iterative responses could be discarded when the "query-source" port for an upstream query was the same as the listener port (53). [RT #34925] Fix crashes in RBTDB implementation. Two calls to dns_db_getoriginnode were fatal if there was no data at the node. [RT #35080] Fix a possible race and crash in the socket_search() function in dispatch.c. [RT #35107] Fix "dig" so it can handle AXFR style IXFR responses which span multiple messages. [RT #35137] Fix a "host" tool problem with converting UTF-8 textname to IDN encoding by handling "." as a search list element when IDN support is enabled. [RT #35133] Fix "queryperf" to prevent a possible integer overflow when printing results. [RT #35182] Prevent a theoretically possible race and crash when obtaining a socket in dispatch.c [RT #35128] Use built-in versions of strptime() and timegm() on all platforms to avoid portability issues. [RT #35183] Fix a bug which could cause a crash when running "rndc reconfig" or "rndc reload" after configuration is changed from regular zones to automatic empty zones. [RT #35177]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值