开源中文网

您的位置: 首页 > FreeBSD > 正文

FreeBSD7.0编译安装bind9.4.2域名服务器

来源:  作者:

本文采用源代码自行编译,如果你用ports或者其它方法,请别骂我。
环境
系统:FreeBSD7.0
BIND:bind-9.4.2
声明:本人水平有限,如有不当之处,敬请指教,本文不包含反向解析。
一、下载bind源代码
代码:
cd /usr/ports/dns/bind94

make fetch
二、解压bind
代码:
cd /usr/ports/distfiles/

tar -zxf bind-9.4.2.tar.gz
三、编译安装
代码:
cd bind-9.4.2

./configure --prefix=/usr/local/named --enable-threads  --enable-largefile --enable-ipv6
make && make install
参数说明:
引用:
--prefix=/usr/local/named 指定程序安装目录

--enable-threads 多线程支持
--enable-largefile 启用大文件支持
--enable-ipv6 启用ipv6支持
四、配置
代码:
cd /usr/local/named

sbin/rndc-confgen > etc/rndc.conf
tail -10 etc/rndc.conf | head -9 | sed s/#\ //g > etc/named.conf
cd etc
fetch ftp://ftp.internic.org/domain/named.root
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

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 named.conf
代码:
options {

   directory "/usr/local/named/etc";
   pid-file "/tmp/named.pid";
   allow-query { any; };            #定义所有可查讯
#   statistics-file "/var/log/stats.log";
   version "Windows 2003 Dns Server v6.0";      #定义版本号
#   listen-on port 53 { 192.168.29.128; };      #监听端口和IP
   recursion yes;               #允许递规查讯
   datasize 50M;               #设置数据大小
   rrset-order { order random; };
};
logging {
   channel warning {
      file "/var/log/dns_warnings.log" versions 5 size 1024K;
      severity warning;
      print-category yes;
      print-severity yes;
      print-time yes;
   };
   channel security_log {
      file "/var/log/dns_security.log" versions 5 size 1024K;
      severity info;
      print-category yes;
      print-severity yes;
      print-time yes;
   };
   channel query_log {
      file "/var/log/dns_query.log" versions 10 size 1024K;
      severity info;
      print-category yes;
      print-severity yes;
      print-time yes;
   };
   category default { warning; };
   category security { security_log; };
   category queries { query_log; };
};
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; };
};
include "custom_dm.conf";         #包含域名定义文件
代码:
mkdir master


vi master/thismail.org.zone
代码:
$ORIGIN thismail.org.

$TTL 300
@   IN   SOA   ns1.thismail.org.   webmaster.thismail.org. (
         2008041001   ; serial number YYMMDDNN
         28800      ; Refresh
         7200      ; Retry
         864000      ; Expire
         300      ; Min TTL
         )
thismail.org.   IN   NS   ns1.thismail.org.
thismail.org.   IN   NS   ns2.thismail.org.
ns1   IN   A   192.168.29.128
thismail.org.   IN   MX   10 mail.thismail.org.
thismail.org.   IN   A   192.168.0.9
www   IN   A   192.168.0.9
mail   IN   A   192.168.0.25
pop   IN   CNAME   mail.thismail.org.
smtp   IN   CNAME   mail.thismail.org.
thismail.org.   IN   TXT   "v=spf1 ip4:192.168.0.25 ~all"  
;邮件SPF设置
vi custom_dm.conf
代码:
zone "thismail.org" {

    type master;
    file "master/thismail.org.zone";
};

代码:
touch /var/log/dns_warnings.log

touch /var/log/dns_security.log
touch /var/log/dns_query.log
chown bind /var/log/dns_warnings.log
chown bind /var/log/dns_security.log
chown bind /var/log/dns_query.log
五、启动
代码:
/usr/local/named/sbin/named -u bind -c /usr/local/named/etc/named.conf
六、测试
测试递规查讯
引用:
Xshell:\> nslookup

> server 192.168.29.128
Default Server: [192.168.29.128]
Address: 192.168.29.128
> www.qq.com
Non-authoritative answer:
Server: [192.168.29.128]
Address: 192.168.29.128
Name: www-cdn.qq.com
Address: 60.28.232.119
Aliases: www.qq.com
> www.freebsdchina.org
Non-authoritative answer:
Server: [192.168.29.128]
Address: 192.168.29.128
Name: www.freebsdchina.org
Address: 61.129.66.78
测试thismail.org
> www.thismail.org
Server: [192.168.29.128]
Address: 192.168.29.128
Name: www.thismail.org
Address: 192.168.0.9
> set type=mx
> thismail.org
Server: [192.168.29.128]
Address: 192.168.29.128
thismail.org MX preference = 10, mail exchanger = mail.thismail.org
thismail.org nameserver = ns1.thismail.org
thismail.org nameserver = ns2.thismail.org
mail.thismail.org internet address = 192.168.0.25
ns1.thismail.org internet address = 192.168.29.128
> set type=txt
> thismail.org
Server: [192.168.29.128]
Address: 192.168.29.128
thismail.org text =
"v=spf1 ip4:192.168.0.25 ~all"
thismail.org nameserver = ns2.thismail.org
thismail.org nameserver = ns1.thismail.org
ns1.thismail.org internet address = 192.168.29.128

Tags:服务器 域名 bind9
关于开源中文网 - 联系我们 - 广告服务 - 网站地图 - 版权声明