Skip to content

bind9架設域名服务器及配置

2009 十一月 4
by 荒野无灯

已经折腾了三天了,呵呵,由于课还是要上的,所以很多东西不能连续搞定。
最郁闷的是在用gparted 、pq 等工具调整分区后,我的备份分区居然无故丢失了:(
所有备份,包括网站的和电脑的,全部丢失。
所以,
以前做好了的东东现在都要重新弄了。
一、 安装

1
2
3
apt-get install bind9
apt-get install bind9-host dnsutils
apt-get install bind9-doc

二、配置
1,域名解析
这里以将 ihacklog.com解析到192.168.1.2为例:

1
2
cd /etc/bind
vim named.conf.local

增加正向解析和反向解析区域(zone):

1
2
3
4
5
6
7
8
9
zone "ihacklog.com" {
    type master;
    file "/etc/bind/db.ihacklog.com";
};

zone "168.192.in-addr.arpa"  {
    type master;
    file "/etc/bind/db.192.168";
};

db.ihacklog.com内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$TTL    604800
@   IN  SOA ihacklog.com. admin.ihacklog.com. (
                  2     ; Serial
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
             604800 )   ; Negative Cache TTL
;
@   IN  NS  ns.ihacklog.com.
@   IN  A   192.168.1.2
ns  IN  A   192.168.1.2
www IN  CNAME @
ftp IN  CNAME @
proxy IN CNAME @
blog IN CNAME @
test IN CNAME @
mysql IN CNAME @
* IN A 192.168.1.2

这里指定了域ihacklog.com的dns服务器为ns.ihacklog.com. 即为本机。因为下面的正向解析记录的A记录将它解析到了本机了。
并且添加了好几个CNAME(别名)记录,都指向192.168.1.2 。
最后添加泛解析支持,所有对*.ihacklog.com的請求都会被解析到192.168.1.2 。
db.192.168内容如下:

1
2
3
4
5
6
7
8
9
10
$TTL    604800
@   IN  SOA ihacklog.com. admin.ihacklog.com. (
                  1     ; Serial
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
             604800 )   ; Negative Cache TTL
;
@   IN  NS  ns.ihacklog.com.
2.1 IN  PTR ihacklog.com.

这里的反向解析很简单,就是将192.168.1.2指向ihacklog.com

2.配置cache(缓存)dns服务器

1
vim named.conf.options

去掉其中几个注释符号(//) ,添加你所在网络的ISP (internet 信息服务提供商)的DNS 。最后内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
options {
    directory "/var/cache/bind";

    // If there is a firewall between you and nameservers you want
    // to talk to, you may need to fix the firewall to allow multiple
    // ports to talk.  See http://www.kb.cert.org/vuls/id/800113

    // If your ISP provided one or more IP addresses for stable
    // nameservers, you probably want to use them as forwarders.  
    // Uncomment the following block, and insert the addresses replacing
    // the all-0's placeholder.

    forwarders {
    202.109.129.2;
    202.101.224.68;
    202.101.240.36;
    };

    auth-nxdomain no;    # conform to RFC1035
    listen-on-v6 { any; };
};

最后说下,由于bind9中的root zone 记录并不是最新的,所以最好到ftp.rs.internic.net下载最新版的。

1
ftp ftp.rs.internic.net

用户名: anonymous
密码:(你的email )

1
2
3
cd domain
get root.zone.gz
get root.zone.gz.md5

ftp_internic

喜欢这篇文章吗?

请订阅本站 RSS feed填写您的邮件地址,订阅我们的精彩内容:,欢迎点击这里捐赠以支持荒野无灯转播到腾讯微博 转播到腾讯微博

作者:荒野无灯
出处:Hacklog【Hacklog】

声明: 本站遵循 署名-非商业性使用-相同方式共享 3.0 共享协议. 转载请注明转自Hacklog【荒野无灯weblog】

本文链接: http://ihacklog.com/?p=2931

2 Responses Post a comment
  1. 十一月 4, 2009

    分区应该可以找回来的吧。我记得一次我把同学的电脑弄的只有一个160G左右(实际小于160G的,那是个160G的硬盘而已)的C盘了,后来用DGen这个分区工具找回来了。不知道你这个问题和我的雷同不?

Leave a Reply

Allowed Tags - You may use these HTML tags and attributes in your comment.

<a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <q cite=""> <strong>

 :wink:  :-|  :-x  :twisted:  :)  8-O  :(  :roll:  :-P  :oops:  :-o  :mrgreen:  :lol:  :idea:  :-D  :evil:  :cry:  8)  :arrow:  :-?  :?:  :!:

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS