Debian 环境下简单配置 Bind9 服务

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

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

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

apt-get install bind9
apt-get install bind9-host dnsutils
apt-get install bind9-doc

配置 Bind,有以下步骤,

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

cd /etc/bind
vim named.conf.local
增加正向解析和反向解析区域(zone):
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内容如下:

$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内容如下:

$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服务器

vim named.conf.options

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

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解析是否正常

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

 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
本文来自云栖社区合作伙伴“ Debian社区”,了解相关信息可以关注“ Debian社区”。
相关文章
|
4月前
百度搜索:蓝易云【在Debian上安装配置Klipper教程】
通过按照以上步骤,你应该能够在Debian上成功安装和配置Klipper。请根据你的具体打印机型号和配置需求进行相应的调整。如果遇到任何问题,可以参考Klipper官方文档或社区寻求更多帮助。
113 0
|
6月前
|
网络安全
如何在 Debian 系统上配置 NTP,来确保计算机时间的准确同步
如何在 Debian 系统上配置 NTP,来确保计算机时间的准确同步
601 0
如何在 Debian 系统上配置 NTP,来确保计算机时间的准确同步
|
Linux 容器 Docker
Debian配置系统中文语言及环境
Debian配置系统中文语言及环境
4696 1
|
6月前
|
安全 Linux 网络安全
百度搜索:蓝易云 ,Linux Debian11服务器安装SSH,创建新用户并允许SSH远程登录,及SSH安全登录配置!
这些步骤提供了在Debian 11服务器上安装SSH,创建新用户并允许SSH远程登录以及进行SSH安全登录配置的指南。请确保按照步骤操作,并根据您的需求进行必要的修改。
100 0
|
Ubuntu 安全 Linux
Debian系Linux软件源配置详解与常用的国内软件源汇总
Debian系Linux软件源配置详解与常用的国内软件源汇总
10672 2
Debian系Linux软件源配置详解与常用的国内软件源汇总
|
安全 数据库
【Debian】配置aide入侵检测服务
基于debian系统。aide主要功能检测系统文件,当系统文件发生变化,如/etc/passwd文件出现差异,那么aide将会认为系统遭受入侵被增添用户
2180 0
|
Linux 开发工具
Debian配置cscope
cscope是linux下查看源码的利器,记录下安装和配置的过程
141 0
Debian配置cscope
|
数据安全/隐私保护
随笔 - debian8 配置 WIFI
/etc/network/interfaces # Include files from /etc/network/interfaces.
909 0
|
3月前
|
消息中间件 Kubernetes NoSQL
Debian11系统boost库安装
Debian11系统boost库安装