Flask  Bind-DLZ + Mysql  DNS管理平台

系统环境:CentOS 6.5 X64

软件版本:

  bind-9.9.5.tar.gz  

mysql-5.6.16.tar.gz

描述:

    数据库安装就不在絮叨,了解运维的同学都应该知道

    bind 相关配置文件,详见 https://github.com/1032231418/Bind-Web.git

一.源码安装配置Bind:

1.源码编译安装



点击(此处)折叠或打开

  1. # tar -zxvf bind-9.9.5.tar.gz #解压压缩包
  2. # cd bind-9.9.5
  3. #./configure --prefix=/usr/local/bind/ --enable-rrl --enable-threads --enable-newstats --with-dlz-mysql
  4. # make
  5. # make install #源码编译安装完成




2.环境变量配置



点击(此处)折叠或打开

  1. cat>>/etc/profile<
  2. PATH=$PATH:/usr/local/bind/bin:/usr/local/bind/sbin
  3. export PATH
  4. EOF



# source  /etc/profile  #重新加载一下环境变量

# named -v           #如下图,说明环境变量正常

Flask  Bind-DLZ + Mysql  DNS管理平台-LMLPHP


3.用户添加授权目录


点击(此处)折叠或打开

  1. # useradd -s /sbin/nologin named
  2. # chown -R named:named /usr/local/bind/



4. 配置Bind

# vi /usr/local/bind/etc/named.conf


点击(此处)折叠或打开

  1. options{
  2.         directory"/usr/local/bind/";
  3.         version"bind-9.9.9";
  4.         listen-onport53 { any; };
  5.         allow-query-cache { any; };
  6.         listen-on-v6port53 {::1; };
  7.         allow-query { any; };
  8.         recursion yes;
  9.         dnssec-enable yes;
  10.         dnssec-validation yes;
  11.         dnssec-lookaside auto;
  12.  
  13. };
  14.  
  15.  
  16. key"rndc-key"{
  17.         algorithm hmac-md5;
  18.         secret"C4Fg6OGjJipHKfgUWcAh+g==";
  19.  
  20. };
  21.  
  22. controls {
  23.         inet 127.0.0.1port953
  24.                 allow{ 127.0.0.1; } keys {"rndc-key";};
  25. };
  26.  
  27.  
  28. view"ours_domain"{
  29.         match-clients {any; };
  30.         allow-query-cache {any; };
  31.         allow-recursion {any; };
  32.         allow-transfer {any; };
  33.  
  34.         dlz"Mysql zone"{
  35.                 database"mysql
  36.                 {host=127.0.0.1 dbname=named ssl=false port=3306 user=root pass=123456}
  37.                 {select zone from dns_records where zone='$zone$'}
  38.                 {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$'}";
  39.         };
  40.         zone"."IN {
  41.             type hint;
  42.             file"/usr/local/bind/etc/named.ca";
  43.         };
  44.  
  45. };



保存退出


生成name.ca文件


点击(此处)折叠或打开

  1. (demo) -bash-4.1# cd /usr/local/bind/etc/
  2. (demo) -bash-4.1# dig -t NS .>named.ca



5. 配置数据库,导入sql文件



点击(此处)折叠或打开

  1. # mysql -p #登录数据库
  2. mysql>CREATE DATABASE named CHARACTER SET utf8 COLLATE utf8_general_ci;
  3. mysql>source named.sql; #注意路径,这里我放在当前目录


就两张表,一个dns用到的表,一个用户管理表

Flask  Bind-DLZ + Mysql  DNS管理平台-LMLPHP


6. 启动 Bind服务并设置开机启动脚本


(demo) -bash-4.1# /usr/local/bind/sbin/named

监控系统日志:

# tail -f /var/log/messages

如下,说明服务启动正常

Flask  Bind-DLZ + Mysql  DNS管理平台-LMLPHP

测试bind连接数据库是否正常:


Flask  Bind-DLZ + Mysql  DNS管理平台-LMLPHP

设置Bind  开机启动脚本


点击(此处)折叠或打开

  1. bind 相关配置文件,详见https://github.com/1032231418/Bind-Web.git,传到服务器 /etc/init.d/ 目录
  2. (demo) -bash-4.1# chmod 755 /etc/init.d/bind
  3. (demo) -bash-4.1# #mkdir /var/run/named/ && chown named:named -R /var/run/named
  4. 杀掉 named 服务,改用脚本启动

  5. (demo) -bash-4.1# pkill named
  6. (demo) -bash-4.1# /etc/init.d/bind start #监控日志,查看启动状态
  7. (demo) -bash-4.1# chkconfig --add bind #加入开机启动
  8. (demo) -bash-4.1# chkconfig   bind on



# tail -f /var/log/messages

Flask  Bind-DLZ + Mysql  DNS管理平台-LMLPHP


二.配置Bind-Web管理平台


克隆管理平台

(demo) -bash-4.1# git  clone   https://github.com/1032231418/Bind-Web.git  #git  克隆下来  
(demo) -bash-4.1# cd Bind-Web
(demo) -bash-4.1# python  run.py


#运行软件程序使用flask框架写的,要用pip安装该框架    
# pip install 

http://ip/5000   访问WEB界面 登录账户eagle密码123456

Flask  Bind-DLZ + Mysql  DNS管理平台-LMLPHP

功能有,用户管理,域名管理

Flask  Bind-DLZ + Mysql  DNS管理平台-LMLPHP

Flask  Bind-DLZ + Mysql  DNS管理平台-LMLPHP

解析测试:
Flask  Bind-DLZ + Mysql  DNS管理平台-LMLPHP

12-09 19:39