前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Debian 环境下简单配置 Bind9 服务

Debian 环境下简单配置 Bind9 服务

作者头像
Debian中国
发布2018-12-20 10:40:34
2.8K0
发布2018-12-20 10:40:34
举报
文章被收录于专栏:Debian中国Debian中国

Bind是使用最广泛的DomainName Server,它是Berkeley Internet Name Domain Service的简写,伯克里大学编写的。在Debian Stretch 9.3中,它的最新版本是Bind 9.10.5。

安装 Bind 比较简单,使用如下命令即可,

代码语言:javascript
复制
apt-get install bind9
apt-get install bind9-host dnsutils
apt-get install bind9-doc

配置 Bind,有以下步骤,

1,域名解析 这里以将 debian.cn 解析到192.168.10.2为例:

代码语言:javascript
复制
cd /etc/bind
vim named.conf.local

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

代码语言:javascript
复制
zone "debian.cn" {
    type master;
    file "/etc/bind/db.debian.cn";
};

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

1.1 正向解析:db.debian.cn内容如下:

(adsbygoogle = window.adsbygoogle || []).push({});

代码语言:javascript
复制
$TTL    604800
@   IN  SOA debian.cn. admin.debian.cn. (
                  2     ; Serial
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
             604800 )   ; Negative Cache TTL
;
@   IN  NS  ns.debian.cn.
@   IN  A   192.168.10.2
ns  IN  A   192.168.10.2
www IN  CNAME @ 
ftp IN  CNAME @
proxy IN CNAME @
blog IN CNAME @
mysql IN CNAME @
* IN A 192.168.10.2

这里指定了域 debian.cn 的授权 DNS服务器为 ns.debian.cn. 即为本机,因为随后的正向解析记录(即A记录),将 ns 指向到了本地的IP地址 192.168.10.2。 同时我们也添加了几个 CNAME 别名记录,都指向 debian.cn。 最后添加泛解析支持,所有对 *.debian.cn 的請求都会被解析到192.168.10.2 。 1.2 反向解析:db.192.168内容如下:

代码语言:javascript
复制
$TTL    604800
@   IN  SOA debian.cn. admin.debian.cn. (
                  1     ; Serial
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
             604800 )   ; Negative Cache TTL
;
@   IN  NS  ns.debian.cn.
2.1 IN  PTR debian.cn.

这里的反向解析很简单,就是将 192.168.10.2 指向 debian.cn

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

代码语言:javascript
复制
vim named.conf.options

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

代码语言:javascript
复制
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 {
    114.114.114.114;
    61.139.2.69;
    };

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

3. 重启BIND服务

使用命令 sudo systemctl restart bind9 或者 sudo rndc reload

4. 测试BIND解析是否正常

使用测试命令,确认百度主站是否能正确解析,

代码语言:javascript
复制
 dig www.baidu.com @192.168.10.2

注意 @192.168.10.2 目的是指定我们使用的域名服务器。由于上面我们在 resolv.conf 中指定了本机使用的DNS服务器为 192.168.10.2, 所以在这里 @192.168.10.2 不是必须的。

至此,配置结束,更信息的说明请仔细阅读Debian官网的Bind9页面

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-12-18 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档