开源mydns配置手册

作者: seamus 分类: 一般应用 发布时间: 2018-05-07 00:54

环境准备

纯净centos6.5操作系统。Basic server安装方式。

主机名:example.com

selinux ?防火墙已关闭。

二、软件包准备

 

Mydns: dns程序包

Mydnsconfig:dns ??web端管理程序

Zlib: mydns依赖库。

三、安装配置mydns

1、添加epel源

[root@example ~]#yum install yum-priorities

[root@example ~]#rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

[root@example ~]#rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

修改/etc/yum.repos.d/epel.repo文件

在[epel]最后添加一条属性 priority=11

[root@example ~]#yum makecache

2、配置LAMP环境

[root@example ~]#yum ?install ??httpd ?mysql* ??mysql-server ?php php-mysql ?php-mbstring

 

 

验证php

 

3、编译安装zlib

解压

 

Yum install gcc –y

./configure ?make ?make install

 

4、安装mydns

解压mydns

编译:

[root@example mydns-1.2.8]# ./configure –with-mysql-lib=/usr/lib64/mysql –with-zlib=/usr/lib64

安装

[root@example mydns-1.2.8]# make && make install

成功后,生成配置文件。

5、创建mydns数据库

修改数据库密码,默认安装mysql5.1版本

启动数据库:

[root@example mydns-1.2.8]# service mysqld start

成功后,默认root密码为空,现修改密码为123456

[root@example mydns-1.2.8]# mysqladmin -uroot -p password “123456”

验证:

 

创建数据库并赋权限

mysql> create database mydns;

Query OK, 1 row affected (0.00 sec)

 

mysql> grant all privileges on mydns.* to ‘mydns’@’localhost’ identified by ‘123456’;

Query OK, 0 rows affected (0.00 sec)

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

mysql>exit

6、纯后台控制mydns

若是不想用web端管理mydns,纯后台控制。则生成mydns的数据库表文件。

[root@example mydns-1.2.8]# mydns –create-tables >mydns.sql

修改mydns.sql文件,删除Engine=MyISAM

保存后导入数据库

导入命令:

[root@example mydns-1.2.8]# mysql -uroot -p123456 mydns < mydns.sql

登入验证:

[root@example mydns-1.2.8]# mysql -uroot -p123456 mydns

 

修改mydns配置文件,修改用户名跟密码以及数据库名。

数据库插入测试dns记录

将其他mydns记录备份下,分别导入到soa??rr表中。备份文件查看文章底部。

登入数据库

[root@example ~]# mysql -uroot -p123456 mydns
mysql> source /root/soa.sql;

Query OK, 0 rows affected (0.00 sec)

 

Query OK, 0 rows affected (0.00 sec)

 

Query OK, 0 rows affected (0.00 sec)

 

Query OK, 0 rows affected (0.00 sec)

mysql> source /root/rr.sql;

Query OK, 0 rows affected (0.00 sec)

 

Query OK, 0 rows affected (0.00 sec)

 

Query OK, 0 rows affected (0.00 sec)

 

Query OK, 0 rows affected (0.00 sec)

 

Query OK, 0 rows affected (0.00 sec)

 

 

启动mydns

[root@example ~]# /usr/local/sbin/mydns &

测试解析

若以后添加新的记录,不必重启mydns服务,另外若想通过service系统服务控制mydns服务,则自己手动写脚本。纯命令行控制mydns配置成功。

配置mydnsconfig

Web端管理dns控制的安装部署

1、解压:

[root@example ~]# tar -zxvf MyDNSConfig-3.0.1.tar.gz

2、修改mydnsconfig配置文件

[root@example ~]# cat /etc/centos-release

CentOS release 6.5 (Final)

[root@example ~]# cd mydnsconfig/install/

[root@example install]# vi lib/install.lib.php

3、安装mydnsconfig

[root@example install]# php -q install.php

若遇到请修改主机名,本例为example.com

[root@example install]# cat /etc/hosts

增加如下记录

192.168.0.68 example.com

 

 

4、修改httpd.conf文件

[root@example install]# vi /etc/httpd/conf/httpd.conf

翻到最下面,注释配置虚拟主机部分。

重启httpd服务

启动mydns服务。若mydns服务没有起来。则执行

[root@example install]# /usr/local/sbin/mydns &

5、创建web路径

[root@example ~]# cd mydnsconfig/

[root@example mydnsconfig]# mkdir /usr/share/mydnsconfig

[root@example mydnsconfig]# cp -rf interface/* /usr/share/mydnsconfig/

[root@example mydnsconfig]# ln -s /usr/share/mydnsconfig/web/ /var/www/html/mydnsconfig

6、修改mydnsconfig 相关数据库连接参数

[root@example mydnsconfig]# vi /usr/share/mydnsconfig/lib/config.inc.php

7、登入web查看

Http://192.168.0.68/mydnsconfig?本机IP

默认登入用户名密码均为admin

 

本例soa记录填写如下信息:

8、添加记录做相关测试

 

9、相关监控信息查询

 

Web端有显示相关主机信息的监控。但是都没法用。

五、附件sao.sql ?rr.sql

rr.sql

[root@example ~]# cat rr.sql

— MySQL dump 10.13 ?Distrib 5.1.73, for redhat-linux-gnu (x86_64)

— Host: localhost ???Database: mydns

— ——————————————————

— Server version 5.1.73

 

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;

/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8 */;

/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;

/*!40103 SET TIME_ZONE=’+00:00′ */;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;

/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;

/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=’NO_AUTO_VALUE_ON_ZERO’ */;

/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

 

— Table structure for table `rr`

 

DROP TABLE IF EXISTS `rr`;

/*!40101 SET @saved_cs_client ????= @@character_set_client */;

/*!40101 SET character_set_client = utf8 */;

CREATE TABLE `rr` (

`id` int(11) unsigned NOT NULL AUTO_INCREMENT,

`sys_userid` int(11) unsigned NOT NULL,

`sys_groupid` int(11) unsigned NOT NULL,

`sys_perm_user` varchar(5) NOT NULL,

`sys_perm_group` varchar(5) NOT NULL,

`sys_perm_other` varchar(5) NOT NULL,

`server_id` int(11) NOT NULL DEFAULT ‘1’,

`zone` int(11) unsigned NOT NULL,

`name` varchar(64) NOT NULL,

`type` enum(‘A’,’AAAA’,’ALIAS’,’CNAME’,’HINFO’,’MX’,’NAPTR’,’NS’,’PTR’,’RP’,’SRV’,’TXT’) DEFAULT NULL,

`data` varchar(255) NOT NULL,

`aux` int(11) unsigned NOT NULL DEFAULT ‘0’,

`ttl` int(11) unsigned NOT NULL DEFAULT ‘86400’,

`active` enum(‘N’,’Y’) NOT NULL DEFAULT ‘Y’,

`stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,

`serial` int(10) unsigned DEFAULT NULL,

PRIMARY KEY (`id`),

UNIQUE KEY `rr` (`zone`,`name`,`type`,`data`)

) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;

/*!40101 SET character_set_client = @saved_cs_client */;

 

— Dumping data for table `rr`

 

LOCK TABLES `rr` WRITE;

/*!40000 ALTER TABLE `rr` DISABLE KEYS */;

INSERT INTO `rr` VALUES (5,1,0,’riud’,’riud’,”,1,1,’b’,’A’,’2.2.2.2′,0,86400,’Y’,’2016-09-06 06:33:21′,2016090601),(4,1,0,’riud’,’riud’,”,1,1,’a’,’A’,’1.2.3.4′,0,86400,’Y’,’2016-09-06 06:33:32′,2016090602),(6,1,0,’riud’,’riud’,”,1,1,’vcfs’,’A’,’192.168.0.11′,0,86400,’Y’,’2016-09-07 01:31:11′,2016090701),(7,1,0,’riud’,’riud’,”,1,1,’vcfs’,’A’,’192.168.0.15′,0,86400,’Y’,’2016-09-07 01:31:20′,2016090702),(8,1,0,’riud’,’riud’,”,1,1,’vcfs’,’A’,’192.168.0.13′,0,86400,’Y’,’2016-09-07 01:31:17′,2016090702);

/*!40000 ALTER TABLE `rr` ENABLE KEYS */;

UNLOCK TABLES;

/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

 

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;

/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;

/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

 

— Dump completed on 2016-09-07 17:18:54

soa.sql

[root@example ~]# cat soa.sql

— MySQL dump 10.13 ?Distrib 5.1.73, for redhat-linux-gnu (x86_64)

— Host: localhost ???Database: mydns

— ——————————————————

— Server version 5.1.73

 

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;

/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8 */;

/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;

/*!40103 SET TIME_ZONE=’+00:00′ */;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;

/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;

/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=’NO_AUTO_VALUE_ON_ZERO’ */;

/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

 

— Table structure for table `soa`

 

DROP TABLE IF EXISTS `soa`;

/*!40101 SET @saved_cs_client ????= @@character_set_client */;

/*!40101 SET character_set_client = utf8 */;

CREATE TABLE `soa` (

`id` int(10) unsigned NOT NULL AUTO_INCREMENT,

`sys_userid` int(11) unsigned NOT NULL,

`sys_groupid` int(11) unsigned NOT NULL,

`sys_perm_user` varchar(5) NOT NULL,

`sys_perm_group` varchar(5) NOT NULL,

`sys_perm_other` varchar(5) NOT NULL,

`server_id` int(11) NOT NULL DEFAULT ‘1’,

`origin` varchar(255) NOT NULL,

`ns` varchar(255) NOT NULL,

`mbox` varchar(255) NOT NULL,

`serial` int(11) unsigned NOT NULL DEFAULT ‘1’,

`refresh` int(11) unsigned NOT NULL DEFAULT ‘28800’,

`retry` int(11) unsigned NOT NULL DEFAULT ‘7200’,

`expire` int(11) unsigned NOT NULL DEFAULT ‘604800’,

`minimum` int(11) unsigned NOT NULL DEFAULT ‘86400’,

`ttl` int(11) unsigned NOT NULL DEFAULT ‘86400’,

`active` enum(‘N’,’Y’) NOT NULL,

`xfer` varchar(255) NOT NULL,

PRIMARY KEY (`id`),

UNIQUE KEY `origin` (`origin`),

KEY `active` (`active`)

) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

/*!40101 SET character_set_client = @saved_cs_client */;

 

— Dumping data for table `soa`

 

LOCK TABLES `soa` WRITE;

/*!40000 ALTER TABLE `soa` DISABLE KEYS */;

INSERT INTO `soa` VALUES (1,1,0,’riud’,’riud’,”,1,’example.com.’,’ns1.example.com.’,’root.example.com.’,2016090709,28800,7200,604800,86400,86400,’Y’,’192.168.0.1′);

/*!40000 ALTER TABLE `soa` ENABLE KEYS */;

UNLOCK TABLES;

/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

 

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;

/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;

/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

 

— Dump completed on 2016-09-07 17:18:12