MyDNS与MyDNSConfig控制面板和DNSMasq在Ubuntu 6.10

MyDNS与MyDNSConfig控制面板和DNSMasq在Ubuntu 6.10上

版本1.0
作者:Till Brehm <t.brehm [at] projektfarm [dot] com>

在本教程中,我将介绍如何安装和配置MyDNS和MyDNSConfig。 MyDNS是使用MySQL数据库作为后端而不是配置文件的DNS服务器,例如Bind或djbdns。 优点是MyDNS只是从数据库中读取记录,当DNS记录更改或区域被创建/编辑/删除时,不必重新启动/重新加载。 可以通过安装访问同一数据库的MyDNS的第二个实例来轻松设置辅助Nameservers,或者更多冗余,使用MySQL主/从复制功能将数据复制到辅助Nameservers。

MyDNSConfig是一个易于使用的基于Web的MyDNS界面。 MyDNSConfig可以创建MyDNS中可用的所有类型的DNS记录,并添加用户管理和访问权限等功能。

此设置使用Ubuntu 6.10,但它也适用于Debain Etch。

安装先决条件

MyDNSConfig是以PHP编写的MyDNS的基于Web的界面。 这需要一个启用了PHP的Web服务器和MySQL数据库服务器。 如果您已经安装了Apache,PHP和MySQL,则可以跳过此步骤。

安装MySQL和Apache网络服务器:

apt-get install libdbd-mysql-perl libdbi-perl libmysqlclient15off libnet-daemon-perl libplrpc-perl mysql-client mysql-client-5.0 mysql-server mysql-common apache2 phpmyadmin libapache2-mod-php5

设置MySQL root密码:

mysqladmin -u root password yourrootsqlpassword

yourrootsqlpassword替换为您选择的密码。

安装MyDNSConfig

我将使用Ubuntu Universe存储库中的MyDNS软件包。 Befor你去下一步,请确保在/etc/apt/sources.list中启用了Universe存储

登录到MySQL并创建数据库:

mysql -u root -p
CREATE DATABASE mydns;
GRANT SELECT, INSERT, UPDATE, DELETE ON mydns.* TO 'mydns'@'localhost' IDENTIFIED BY 'mydnspassword';
GRANT SELECT, INSERT, UPDATE, DELETE ON mydns.* TO 'mydns'@'localhost.localdomain' IDENTIFIED BY 'mydnspassword';
FLUSH PRIVILEGES;
quit;

使用您选择的密码替换上述命令中的mydnspassword一词。

下载MyDNSConfig:

cd /tmp
wget http://mesh.dl.sourceforge.net/sourceforge/mydnsconfig/MyDNSConfig-1.1.0.tar.gz
tar xvfz MyDNSConfig-1.1.0.tar.gz
cd MyDNSConfig-1.1.0

安装MyDNSConfig:

mkdir /usr/share/mydnsconfig
cp -rf interface/* /usr/share/mydnsconfig/
ln -s /usr/share/mydnsconfig/web/ /var/www/mydnsconfig

安装MyDNSConfig SQL数据库:

mysql -u root -p mydns < install/mydnsconfig.sql

上述命令要求输入密码,请输入MySQL root用户的密码。

编辑MyDNSConfig配置:

vi /usr/share/mydnsconfig/lib/config.inc.php

该文件应如下所示:

<?php
/*
Copyright (c) 2005, Till Brehm, Falko Timme, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
ini_set('register_globals',0);
$conf["app_title"] = "MyDNSConfig";
$conf["app_version"] = "1.1.0";

$conf["rootpath"]            = "/usr/share/mydnsconfig";
$conf["fs_div"]                = "/"; // File system divider, \\ on windows and / on linux and unix
$conf["classpath"]            = $conf["rootpath"].$conf["fs_div"]."lib".$conf["fs_div"]."classes";
$conf["temppath"]            = $conf["rootpath"].$conf["fs_div"]."temp";

/*
        Database Settings
*/

$conf["db_type"]        = 'mysql';
$conf["db_host"]        = 'localhost';
$conf["db_database"]        = 'mydns';
$conf["db_user"]        = 'mydns';
$conf["db_password"]        = 'mydnspassword';

/*
        External programs
*/
$conf["programs"]["wput"]    = $conf["rootpath"]."/tools/wput/wput";

/*
        Themes
*/
$conf["theme"]            = 'grey';
$conf["html_content_encoding"]    = 'text/html; charset=iso-8859-1';
$conf["logo"]             = 'themes/default/images/mydnsconfig_logo.gif';
/*
        Default Language
*/
$conf["language"]                = 'en';

/*
        Auto Load Modules
*/
$conf["start_db"]                = true;
$conf["start_session"]    = true;
/*
        DNS Settings
*/
$conf["auto_create_ptr"] = 1; // Automatically create PTR records?
$conf["default_ns"] = 'ns1.example.com.'; // must be set if $conf['auto_create_ptr'] is 1. Don't forget the trailing dot!
$conf["default_mbox"] = 'admin.example.com.'; // Admin email address. Must be set if $conf['auto_create_ptr'] is 1. Replace "@" with ".". Don't forget the trailing dot!
$conf["default_ttl"] = 86400;
$conf["default_refresh"] = 28800;
$conf["default_retry"] = 7200;
$conf["default_expire"] = 604800;
$conf["default_minimum_ttl"] = 86400;
?>

之后,从/ tmp directoy中删除MyDNSConfig安装程序:

cd /tmp
rm -rf MyDNSConfig-1.1.0/
rm -f MyDNSConfig-1.1.0.tar.gz

安装MyDNS

现在从Ubuntu安装MyDNS软件包。 当我们创建了一个名为mydns的数据库,其中包含MyDNS所需的所有表,我们可以选择在以下设置中不创建数据库。

apt-get install mydns-mysql
-> localhost
-> mydns
-> no
-> mydns
-> mydnspassword

修改MyDNS配置文件,以便MyDNS也可以在TCP上监听并允许区域传输:

vi /etc/mydns.conf
allow-tcp = yes
allow-axfr = yes

MyDNS和MyDNSConfig的基本安装现已完成。 要登录MyDNSConfig界面,请打开Web浏览器并输入输入以下URL:

http://<your_ip_address>/mydnsconfig/

<your_ip_address>替换为服务器的IP地址。

MyDNSConfig的默认用户名和密码是:

用户名: admin
密码: admin

系统>用户登录后,不要忘记更改密码。

安装DNSMasq

MyDNS不包含能够解析MyDNS不具有竞争力的DNS记录的DNS解析器。 在下一步中,我将安装和配置DNS解析器并缓存DNSMasq作为本地DNS解析器,并配置MyDNS以使用DNSMasq来解析外部域。 如果您不希望服务器解析外部域,则可以跳过此部分。

在IP 127.0.0.1上创建DNS解析器:

apt-get install dnsmasq

这将安装dnsmasq Ubuntu软件包。 现在我们必须编辑DNSMasq和MyDNS配置文件,以确保两个pacakge都不会在所有IP地址的同一端口上监听。

vi /etc/dnsmasq.conf
listen-address=127.0.0.1
no-dhcp-interface=
bind-interfaces

现在编辑mydns.conf文件以配置MyDNS在127.0.0.1监听:

vi /etc/mydns.conf
no-listen = 127.0.0.1
recursive = 127.0.0.1

然后编辑/etc/resolv.conf

vi /etc/resolv.conf

并添加以下行作为第一行,以便DNSMasq DNS缓存也用于所有本地DNS查询:

nameserver 127.0.0.1

链接

赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏