免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2587 | 回复: 4
打印 上一主题 下一主题

[FreeBSD] FreeBSD 7.0 自带BIND配置DNS服务器 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-05 15:25 |只看该作者 |倒序浏览
cd /etc/named
rm -rf *

rndc-confgen > rndc.conf
tail -10 rndc.conf | head -9 | sed s/#\ //g > named.conf
fetch ftp://ftp.internic.org/domain/named.root

vi localhost.zone
  1. $TTL    86400
  2. $ORIGIN localhost.
  3. @        1D        IN        SOA        @        root (
  4.                         42        ; serial (d. adams)
  5.                         3H        ; refresh
  6.                         15M        ; retry
  7.                         1W        ; expiry
  8.                         1D )        ; minimum

  9.         1D        IN        NS        @
  10.         1D        IN        A        127.0.0.1
复制代码


vi named.local
  1. $TTL        86400
  2. @        IN        SOA        localhost.        root.localhost. (
  3.                         1997022700        ; Serial
  4.                         28800                ; Refresh
  5.                         14400                ; Retry
  6.                         3600000                ; Expire
  7.                         86400 )                ; Minimum
  8.         IN        NS        localhost.
  9. 1        IN        PTR        localhost.
复制代码


vi named.conf
  1. options {
  2.         directory "/etc/namedb/";
  3.         pid-file "/var/run/named/pid";
  4.         allow-query { any; };
  5. #        statistics-file "/var/log/stats.log";
  6.         version "Windows 2003 Dns Server v6.0";       
  7. #        listen-on port 53 { 192.168.23.133; };
  8.         recursion yes;
  9.         datasize 50M;
  10.         rrset-order { order random; };
  11. };

  12. logging {
  13.         channel warning {
  14.                 file "/var/log/dns_warnings.log" versions 5 size 1024K;
  15.                 severity warning;
  16.                 print-category yes;
  17.                 print-severity yes;
  18.                 print-time yes;
  19.         };
  20.         channel security_log {
  21.                 file "/var/log/dns_security.log" versions 5 size 1024K;
  22.                 severity info;
  23.                 print-category yes;
  24.                 print-severity yes;
  25.                 print-time yes;
  26.         };
  27.         channel query_log {
  28.                 file "/var/log/dns_query.log" versions 10 size 1024K;
  29.                 severity info;
  30.                 print-category yes;
  31.                 print-severity yes;
  32.                 print-time yes;
  33.         };
  34.         category default { warning; };
  35.         category security { security_log; };
  36.         category queries { query_log; };
  37. };

  38. zone "." IN {
  39.         type hint;
  40.         file "named.root";
  41. };

  42. zone "localhost" IN {
  43.         type master;
  44.         file "localhost.zone";
  45.         allow-update { none; };  
  46. };

  47. zone "0.0.127.in-addr.arpa" IN {
  48.         type master;
  49.         file "named.local";
  50.         allow-update { none; };
  51. };

  52. 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.23.133

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
  1. zone "thismail.org" {
  2.     type master;
  3.     file "master/thismail.org.zone";
  4. };
复制代码



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

vi /etc/rc.conf
  1. named_enable="YES"
复制代码

/etc/rc.d/named start



Xshell:\> nslookup
> server 192.168.23.133
Default Server:  [192.168.23.133]
Address:  192.168.23.133

> www.qq.com
Non-authoritative answer:
Server:  [192.168.23.133]
Address:  192.168.23.133

Name:    www-cdn.qq.com
Address:  60.28.232.119
Aliases:  www.qq.com

> www.freebsdchina.org
Non-authoritative answer:
Server:  [192.168.23.133]
Address:  192.168.23.133

Name:    www.freebsdchina.org
Address:  61.129.66.78

测试thismail.org

> www.thismail.org
Server:  [192.168.23.133]
Address:  192.168.23.133

Name:    www.thismail.org
Address:  192.168.0.9

> set type=mx
> thismail.org
Server:  [192.168.23.133]
Address:  192.168.23.133

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.23.133
> set type=txt
> thismail.org
Server:  [192.168.23.133]
Address:  192.168.23.133

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.23.133

论坛徽章:
1
金牛座
日期:2014-05-29 15:55:47
2 [报告]
发表于 2008-12-06 09:40 |只看该作者
jacky,你搞这么复杂做什么啊?
cd /etc/named
rm -rf *

rndc-confgen > rndc.conf

???
这些不用删除的,rndc.conf也不用重做。

论坛徽章:
0
3 [报告]
发表于 2008-12-06 15:13 |只看该作者
原帖由 iceblood 于 2008-12-6 09:40 发表
jacky,你搞这么复杂做什么啊?
cd /etc/named
rm -rf *

rndc-confgen > rndc.conf

???
这些不用删除的,rndc.conf也不用重做。


我感觉重做,比较适合我个人的习惯。反正就两个命令。呵呵

论坛徽章:
54
2017金鸡报晓
日期:2017-02-08 10:39:42操作系统版块每日发帖之星
日期:2016-03-08 06:20:00操作系统版块每日发帖之星
日期:2016-03-07 06:20:00操作系统版块每日发帖之星
日期:2016-02-22 06:20:00操作系统版块每日发帖之星
日期:2016-01-29 06:20:00操作系统版块每日发帖之星
日期:2016-01-27 06:20:00操作系统版块每日发帖之星
日期:2016-01-20 06:20:00操作系统版块每日发帖之星
日期:2016-01-06 06:20:0015-16赛季CBA联赛之江苏
日期:2015-12-21 20:00:24操作系统版块每日发帖之星
日期:2015-12-21 06:20:00IT运维版块每日发帖之星
日期:2015-11-17 06:20:002015亚冠之广州恒大
日期:2015-11-12 10:58:02
4 [报告]
发表于 2008-12-07 20:07 |只看该作者
的确有点复杂,我都是直接修改named.conf。

BTW:这句话好像不对,应该是forcestart,直接start好像不行。
/etc/rc.d/named start


再提个建议:对每一步都说明一下干什么用的。

论坛徽章:
0
5 [报告]
发表于 2008-12-07 22:20 |只看该作者
原帖由 lsstarboy 于 2008-12-7 20:07 发表
的确有点复杂,我都是直接修改named.conf。

BTW:这句话好像不对,应该是forcestart,直接start好像不行。


再提个建议:对每一步都说明一下干什么用的。

/etc/rc.d/named start是可以的。我这里测试了的
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP