Chinaunix首页 | 论坛 | 博客
  • 博客访问: 518964
  • 博文数量: 106
  • 博客积分: 1707
  • 博客等级: 上尉
  • 技术积分: 1109
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-16 11:24
个人简介

从事互联网开发、运营、设计、运维等工作。偏爱底层开发,服务器运维

文章分类

全部博文(106)

文章存档

2016年(3)

2015年(6)

2014年(5)

2013年(11)

2012年(8)

2011年(8)

2010年(34)

2009年(31)

分类: LINUX

2009-12-01 15:06:04

1、安装openssl
tar -zxvf openssl-0.9.8d.tar.gz
cd openssl-0.9.8d
./config --prefix=/usr/local/openssl
make;make install
2、安装bind
tar -zxvf bind-9.5.1-P2.tar.gz
cd bind-9.5.1-P2
./configure --prefix=/usr/local/named/ --mandir=/usr/local/share/man/ --enable-threads --with-openssl=/usr/local/openssl/
make;make install
groupadd -g 25 named
useradd -u 25 -g 25 -d /usr/local/named -s /sbin/nologin named
mkdir /usr/local/named/namedb
开始配置bind
创建 rndc.conf文件,用bind自带程序生成
cd /usr/local/named/
sbin/rndc-confgen > etc/rndc.conf
把rndc.conf 中的key信息输出到 named.conf 中
cd etc/
tail -n 10 rndc.conf | head -n9 | sed -e s/#\ //g > ../named.conf
编辑named.conf
vi named.conf
写入以下内容:#下面的acl是允许内网的客户端使用DNS转发功能
acl "trusted-lan" {
   127.0.0.1/8;
   192.168.0.0/24;
   10.10.1.0/24;
   10.31.255.0/24;
};
options {
   directory "/usr/local/named";
   dump-file "/usr/local/named/data/cache_dump.db";
   statistics-file "/usr/local/named/data/named_stats.txt";
   version "";
   datasize 40M;
   allow-transfer {
    "trusted-lan";
   };
   recursion yes;
   allow-notify {
       "trusted-lan";
   };
   allow-recursion {
       "trusted-lan";
   };
   auth-nxdomain no;
   forwarders {
       202.96.209.133;
       202.96.209.6;
   };
};
logging {
   channel warning {
    file "/usr/local/named/var/dns_warning" versions 3 size 1240k;
    severity warning;
    print-category yes;
    print-severity yes;
    print-time yes;
   };
   channel general_dns {
       file "/usr/local/named/var/dns_log" versions 3 size 1240k;
       severity info;
       print-category yes;
       print-severity yes;
       print-time yes;
   };
   category default {
       warning;
   };
   category queries {
       general_dns;
   };
};
include "cnc_acl.conf";
include "telecom_acl.conf";
view "view_cnc" {
   match-clients {
         CNC;
   };
   zone "." {
         type hint;
         file "named.ca";
   };
   include "master/cnc.def";
};
view "view_telecom" {
   match-clients {
         TELECOM;
   };
   zone "." {
         type hint;
         file "named.ca";
   };
   include "master/telecom.def";
};
view "view_any" {
   match-clients {
         any;
   };
   zone "." {
         type hint;
         file "named.ca";
   };
   include "master/any.def";
};
保存,退出。
3、安装IP地址段查询工具Ripe-dbase-client-v3:
下载软件包:
wget
tar zxvf ripe-dbase-client-v3.tar.gz
cd whois-3.1
./configure --prefix=/usr
make;make install
4、设置配置文件
mkdir /usr/local/named/data
mkdir /usr/local/named/master
wget -O /usr/local/named/named.ca
配置ACL文件
/usr/bin/whois3 -h whois.apnic.net -l -i mb MAINT-CNCGROUP | grep "descr" | grep "Reverse" | awk -F "for" '{if ($2!="") print $2}'| sort -n | awk 'BEGIN{print "acl \"CNC\" '{'"}{print $1";"}END{print "'}';"}' > /usr/local/named/cnc_acl.conf
/usr/bin/whois3 -h whois.apnic.net -l -i mb MAINT-CHINANET | grep "descr" | grep "Reverse" | awk -F "for" '{if ($2!="") print $2}'| sort -n | awk 'BEGIN{print "acl \"TELECOM\" '{'"}{print $1";"}END{print "'}';"}' > /usr/local/named/telecom_acl.conf
增加域名解析配置文件
设置网通解析配置文件:
vi /usr/local/named/master/cnc.def
==========cnc.def begin==========
zone "king.com"{
    type master;
    file "master/cnc/king.com";
    allow-transfer { 192.168.1.100 ; };
    notify yes;
    also-notify { 192.168.1.100 ; };
};
==========cnc.def end===========   
设置电信解析配置文件:
vi /usr/local/named/master/telecom.def
==========telecom.def begin==========
zone "king.com"{
    type master;
    file "master/telecom/king.com";
    allow-transfer { 192.168.1.100 ; };
    notify yes;
    also-notify { 192.168.1.100 ; };
};
==========telecom.def end===========
设置网通电信以外解析配置文件:
vi /usr/local/named/master/any.def
==========any.def begin==========
zone "king.com"{
    type master;
    file "master/any/king.com";
    allow-transfer { 192.168.1.100 ; };
    notify yes;
    also-notify { 192.168.1.100 ; };
};
==========any.def end===========
增加域名定义文件
设置网通域名定义文件#网通客户访问就让返回给他网通段的DNS 218.108.238.221和222
vi /usr/local/named/master/cnc/king.com
==========cnc/king.com begin==========
$TTL 3600
$ORIGIN king.com.
@ IN SOA ns.king.com. root.king.com. (
                      2009041701  ;Serial
                      3600    ;Refresh ( seconds )
                      900    ;Retry ( seconds )
                      68400       ;Expire ( seconds )
                      15          ;Minimum TTL for Zone ( seconds )
                      )
@       IN      NS     ns.king.com.
@       IN      A      218.108.238.221
ns      IN      A      218.108.238.221
www     IN      A      218.108.238.221
www     IN      A      218.108.238.222
;
;end
==========cnc/king.com end===========
设置电信域名定义文件#电信客户就返回给他电信的IP 61.152.241.197
vi /usr/local/named/master/telecom/king.com
==========telecom/king.com begin==========
$TTL 3600
$ORIGIN king.com.
@ IN SOA ns.king.com. root.king.com. (
                       2009041701  ;Serial
                       3600   ;Refresh ( seconds )
                       900   ;Retry ( seconds )
                       68400   ;Expire ( seconds )
                       15   ;Minimum TTL for Zone ( seconds )
                       )
@      IN       NS      ns.king.com.
@      IN       A       61.152.241.97
ns     IN       A       61.152.241.97
www    IN       A       61.152.241.97
;
;end
==========telecom/king.com end===========
设置其它区域域名定义文件: 其他网段客户
vi /usr/local/named/master/any/king.com
==========any/king.com begin==========
$TTL 3600
$ORIGIN king.com.
@ IN SOA ns.king.com. root.king.com. (
                       2009041701  ;Serial
                       3600   ;Refresh ( seconds )
                       900   ;Retry ( seconds )
                       68400   ;Expire ( seconds )
                       15   ;Minimum TTL for Zone ( seconds )
                       )
@      IN       NS      ns.king.com.
@      IN       A       61.152.241.97
ns     IN       A       61.152.241.97
www    IN       A       61.152.241.97
;
;end
==========any/king.com end===========
启动bind
/usr/local/named/sbin/named –gc /usr/local/named/named.conf &
设为开机启动:
echo "/usr/local/named/sbin/named –gc /usr/local/named/named.conf &" >> /etc/rc.local
全部安装结束,就可以开展应用的配置和测试了。
阅读(894) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~