MENU

bind9的主从配置示例

@(抠鼻)下午刚配好PTR服务器,现在闲着无事配一下主从服务器,刚刚配置成功了,贴一下配置方法.

服务器和工具

  • 主服务器(10.10.0.1)

  • 从服务器(10.10.0.2)

  • ubuntu16.04

  • bind9

  • 一个大脑

主服务器配置

修改/etc/bind/named.conf和上一篇文章一样,就是多了几个字段

// 主设置

options {

        // 指定一个根目录用于存放下面的文件(绝对路径)

        directory "/etc/bind/conf";

        // pid存放的路径(绝对路径)

        pid-file "/etc/bind/named.pid";

};



// 此处不需要修改

zone "." {

        type hint;

        file "named.root";

};



// 本地ip block设置

zone "0.0.127.IN-ADDR.ARPA" {

        type master;

	// 从dns服务器

	allow-transfer {10.10.0.2;};

	// 允许任意ip获取解析 

	allow-query {any;};

        file "localhost.rev";

};



//需要设置ptr的ip block的地址(遵循Standard标准)

zone "8.8.8.in-addr.arpa" {

    // 当前服务器是主服务器还是从服务器

    type master; 

	// 从dns服务器

	allow-transfer {10.10.0.2;};

	// 允许任意ip获取解析 

	allow-query {any;};

    // 存放解析信息的文件

    file "8.8.8.in-addr.arpa.rev";

};



//需要设置ptr的ip block的地址(遵循Standard标准)

zone "4.4.8.in-addr.arpa" {

    // 当前服务器是主服务器还是从服务器

    type master; 

	// 从dns服务器

	allow-transfer {10.10.0.2;};

	// 允许任意ip获取解析 

	allow-query {any;};

    // 存放解析信息的文件

    file "4.4.8.in-addr.arpa.rev";

};



// 正向解析设置(普通的域名解析)

zone "conoha.app" {

    type master;

	// 从dns服务器

	allow-transfer {10.10.0.2;};

	// 允许任意ip获取解析 

	allow-query {any;};

    file "conoha.app.zone";

};

从服务器配置

直接copy主服务器内的所有配置文件,然后修改/etc/bind/named.conf

// 主设置

options {

        // 指定一个根目录用于存放下面的文件(绝对路径)

        directory "/etc/bind/conf";

        // pid存放的路径(绝对路径)

        pid-file "/etc/bind/named.pid";

};



// 此处不需要修改

zone "." {

        type hint;

        file "named.root";

};



// 本地ip block设置

zone "0.0.127.IN-ADDR.ARPA" {

    type slave; 

	// 主dns服务器

	masters {10.10.0.1;};

	// 允许任意ip获取解析 

	allow-query {any;};

        file "localhost.rev";

};



//需要设置ptr的ip block的地址(遵循Standard标准)

zone "8.8.8.in-addr.arpa" {

    // 当前服务器是主服务器还是从服务器

    type slave; 

	// 主dns服务器

	masters {10.10.0.1;};

	// 允许任意ip获取解析 

	allow-query {any;};

    // 存放解析信息的文件

    file "8.8.8.in-addr.arpa.rev";

};



//需要设置ptr的ip block的地址(遵循Standard标准)

zone "4.4.8.in-addr.arpa" {

    type slave; 

	// 主dns服务器

	masters {10.10.0.1;};

	// 允许任意ip获取解析 

	allow-query {any;};

    file "4.4.8.in-addr.arpa.rev";

};



// 正向解析设置(普通的域名解析)

zone "conoha.app" {

    type slave; 

	// 主dns服务器

	masters {10.10.0.1;};

	// 允许任意ip获取解析 

	allow-query {any;};

    file "conoha.app.zone";

};

记录更新方法

首先看上一个文章里的8.8.8.in-addr.arpa.rev

$TTL    86400



@   IN  SOA ns1.conoha.app. root.ns1.conoha.app. (

                01070101  ; Serial

                3600    ; Refresh

                900     ; Retry

                3600000 ; Expire

                86400 )  ; Minimum



    IN  NS  ns1.conoha.app.

    IN  NS  ns2.conoha.app.

*   IN  PTR ni-co.moe.

每次修改记录之后修改01070101 ; Serial这里,每次前面的数字+1,当主服务器修改reload后(#(内伤)刚刚确定bind从服务业需要重载,更新方法正在找...),则解析记录会同步到从服务器.

后记

主机配置

options {

		// 指定一个根目录用于存放下面的文件(绝对路径)

        directory "/etc/bind/conf";

		// pid存放的路径(绝对路径)

        pid-file "/etc/bind/named.pid";

		notify yes;

		allow-notify {10.10.0.1;10.10.0.2;};

		// 从dns服务器

		allow-transfer {10.10.0.2;};

		// 允许任意ip获取解析 

		allow-query {any;};

		

};

从机配置

options {

		// 指定一个根目录用于存放下面的文件(绝对路径)

        directory "/etc/bind/conf";

		// pid存放的路径(绝对路径)

        pid-file "/etc/bind/named.pid";

		// 允许任意ip获取解析 

		allow-query {any;};

		allow-notify {10.10.0.1;10.10.0.2;};

};

#(吐血倒地)这样终于实现了同步(主机改完还得restart才能同步到从机),这配置非常神奇,理解不能.

添加新评论

已有 5 条评论
  1. 阿珏
    来逛逛@(哈哈)
  2. rubber
    大佬,在SSL上面申请证书,在选择邮箱的时候,退出了。现在再申请的时候提示已经申请过了。请问这个要怎么处理,谢谢
    1. shirakun
      请通过邮箱联系,将你的域名发送给我
  3. 小樱
    大佬,,QQ邮箱被你禁止了还是对方禁的← 话说读不出域名管理员吗
    1. shirakun
      QQ邮箱是我禁止的,因为提交到alpha也有很大几率被拒绝,这样还会浪费一个额度,不如主动禁止,域名验证邮箱是alpha返回的不是我探测的