Bind-Web 手册

简介

web方式管理dns

架构

web+mysql+bind

安装部署

Python3安装

pip安装

Django 安装

 * asgiref-3.2.4
 * sqlparse-0.3.0
 * pytz-2020.1

bind 安装

 (如果没有此文件,可以执行 sh autogen.sh生成)

修改后配置文件

options {
            directory       "/usr/local/bind/";
            version         "bind-9.16.2";
            listen-on port 53 { any; };
            allow-query-cache { any; };
            listen-on-v6 port 53 { ::1; };
            allow-query     { any; };
            recursion yes;    
            dnssec-enable yes;
            dnssec-validation yes;
            dnssec-lookaside auto;
};


key "rndc-key" {
        algorithm hmac-sha256;
        secret "evPRvxv1HYcoX5AXSyrB0jNeq5nP3GhAqwlzj4aIN/U=";
};

controls {
    inet 0.0.0.0 port 953 allow { 0.0.0.0; } keys { "rndc-key"; };
    };


view "ours_domain" {
    match-clients           {any; };
    allow-query-cache           {any; };
    allow-recursion          {any; };
    allow-transfer          {any; };

    dlz "Mysql zone" {
        database        "mysql
        {host=10.243.178.1 dbname=bind ssl=false port=13306 user=snb pass=Snb@cloud123}
        {select zone from dns_records where zone='$zone$'}
        {select ttl, type, mx_priority, case when lower(type)='txt' then concat('\"', data, '\"') when lower(type) = 'soa' then concat_ws(' ', data, resp_person, serial, refresh, retry, expire, minimum) else data end from dns_records where zone = '$zone$' and host = '$record$'}"; 
            };

};
上配置文件中的说明:
   key "rndc-key"段:来自tail语句生成,不用修改
   view "ours_domain":需要修改(host 修改为mysql所在虚机,如果为1m1s,修改为vip,dbname和后面bind-web的数据库是同一个;port为数据库连接端口号;user为连接数据库用户名;pass为数据库连接密码;其它信息无需修改

启动named

 直接启动named会报段错误
 -4:ipv4
 -n: 单线程
 -S:最大连接数

bind-web安装

 在安装时会依赖如下包(提前下载):
 certifi-2017.7.27.1.tar.gz
 chardet-3.0.4.tar.gz
 idna-2.9.tar.gz
 libuv-1.37.0.tar.gz
 mysqlclient-1.4.6.tar.gz
 MySQL-python-1.2.5.zip
 requests-2.23.0.tar.gz
 urllib3-1.25.9.tar.gz

 libuv的安装方式:sh autogen.sh && ./configure &&  make && make install
 其它包的安装:解压后进入目录:python3 setup.py install
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME':'bind',
        'USER': 'root',
        'PASSWORD': '123456',
        'HOST': '10.0.3.8',
        'PORT':'3306',
        'OPTIONS': {
             'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",

        },
    }
}
 python3 manage.py makemigrations
 python3 manage.py migrate
 python3 manage.py createsuperuser
 (根据提示信息输入,用户名超过5个字符,密码里建议不要有@符号)

 python3 manage.py runserver 0.0.0.0:8001

登录web

FAQ

在 Python 3.x 版本后,ConfigParser.py 已经更名为 configparser.py 所以出错!
 cp /usr/local/Python34/lib/python3.4/configparser.py /usr/local/Python34/lib/python3.4/ConfigParser.py 
 yum install mysql-devel gcc gcc-devel python-devel

结语

-Bind 参考手册 - Bind-web 下载地址 * 在访问页面是会比较慢,会联网查找一个js库,在base.html内,去注释掉无影响, * 在安装时可能还有一些异常,直接根据提示进行修改 * 转载说明出处