VnLamp

Go Back   VnLamp > Khu vực Training > LPI > DNS

Trả lời
 
LinkBack Ðiều Chỉnh Xếp Bài
Installing MyDNS And The MyDNSConfig Control Panel On CentOS 5.1
Old
  (#1 (permalink))
 
Status: Offline
Posts: 78
Tham gia: Dec 2007
Open mind Open lives
 
petern's Avatar
Default Installing MyDNS And The MyDNSConfig Control Panel On CentOS 5.1 - 23-01-2008, 09:23 23-01-2008

Author: Falko Timme

1 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100. These settings might differ for you, so you have to replace them where appropriate.

2 Installing The Prerequisites

First we enable the RPMforge repository on our CentOS system as some of the packages that we are going to install in the course of this tutorial are not available in the official CentOS 5.1 repositories:

rpm -Uhv http://apt.sw.be/packages/rpmforge-r...l5.rf.i386.rpm

MyDNSConfig is a web-based interface to MyDNS written in PHP. This requires a webserver with PHP enabled and the MySQL database server. If you have already Apache, PHP and MySQL installed, you may skip this step. We also install phpMyAdmin here so that you have a web interface to the MySQL database in case you need it:

yum install httpd mysql-server php php-mysql php-mbstring phpmyadmin

Start MySQL:

chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

Then set passwords for the MySQL root account:

mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpassword

Now we configure phpMyAdmin. We change the Apache configuration so that phpMyAdmin allows connections not just from localhost (by commenting out the <Directory "/usr/share/phpmyadmin"> stanza):

vi /etc/httpd/conf.d/phpmyadmin.conf
HTML Code:
#
#  Web application to manage MySQL
#

#<Directory "/usr/share/phpmyadmin">
#  Order Deny,Allow
#  Deny from all
#  Allow from 127.0.0.1
#</Directory>

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin
Next we change the authentication in phpMyAdmin from cookie to http:

vi /usr/share/phpmyadmin/config.inc.php
HTML Code:
[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
[...]
Then we create the system startup links for Apache and start it:

chkconfig --levels 235 httpd on
/etc/init.d/httpd start

Now you can direct your browser to http://server1.example.com/phpmyadmin/ or http://192.168.0.100/phpmyadmin/ and log in with the user name root and your new root MySQL password.


3 Installing MyDNSConfig

Log in to MySQL and create the database:

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;

Replace the word mydnspassword in the above commands with a password of your choice.

Download MyDNSConfig:

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

Install MyDNSConfig:

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

Install the MyDNSConfig MySQL Database:

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

The command above asks for a password, please enter the password of the MySQL root user.

Edit the MyDNSConfig configuration; please make sure you fill in the correct database settings:

vi /usr/share/mydnsconfig/lib/config.inc.php
HTML Code:
<?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;
?>
Afterwards, remove the MyDNSConfig installer from the /tmp directory:

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

4 Installing MyDNS

Next we download the mydns-mysql rpm package from http://mydns.bboy.net/download/ and install it as follows:

wget http://mydns.bboy.net/download/mydns...1.0-1.i386.rpm
rpm -ivh mydns-mysql-1.1.0-1.i386.rpm

Open the MyDNS configuration file /etc/mydns.conf, fill in the correct database details, allow zone transfers by setting allow-axfr to yes, enable TCP (allow-tcp = yes), and specify a recursive resolver (i.e., a valid nameserver, e.g. from your ISP; e.g. recursive = 213.191.92.86) so that MyDNS can answer queries for domains that it isn't authoritative for:

vi /etc/mydns.conf
HTML Code:
##
##  /etc/mydns.conf
##  Wed Jan 18 17:18:48 2006
##  For more information, see mydns.conf(5).
##


                                # DATABASE INFORMATION

db-host = localhost             # SQL server hostname
db-user = mydns                 # SQL server username
db-password = mydnspassword        # SQL server password
database = mydns                # MyDNS database name


                                # GENERAL OPTIONS

user = nobody                   # Run with the permissions of this user
group = nobody                  # Run with the permissions of this group
listen = *                      # Listen on these addresses ('*' for all)
no-listen =                     # Do not listen on these addresses


                                # CACHE OPTIONS

zone-cache-size = 1024          # Maximum number of elements stored in the zone cache
zone-cache-expire = 60          # Number of seconds after which cached zones expires
reply-cache-size = 1024         # Maximum number of elements stored in the reply cache
reply-cache-expire = 30         # Number of seconds after which cached replies expire


                                # ESOTERICA

log = LOG_DAEMON                # Facility to use for program output (LOG_*/stdout/stderr)
pidfile = /var/run/mydns.pid    # Path to PID file
timeout = 120                   # Number of seconds after which queries time out
multicpu = 1                    # Number of CPUs installed on your system
recursive = 213.191.92.86                       # Location of recursive resolver
allow-axfr = yes                # Should AXFR be enabled?
allow-tcp = yes                 # Should TCP be enabled?
allow-update = no               # Should DNS UPDATE be enabled?
ignore-minimum = no             # Ignore minimum TTL for zone?
soa-table = soa                 # Name of table containing SOA records
rr-table = rr                   # Name of table containing RR data
soa-where =                     # Extra WHERE clause for SOA queries
rr-where =                      # Extra WHERE clause for RR queries
Next, create the system startup links for MyDNS and start MyDNS:
chkconfig --levels 235 mydns on
/etc/init.d/mydns start

Finally, we need to fix the system startup links for MyDNS. MyDNS depends on MySQL, so MyDNS must start after MySQL has started, otherwise it will fail. The default startup links for MyDNS make it start before MySQL which is wrong, so we fix this as follows:

cd /etc/rc.d/rc3.d
mv S52mydns S99mydns
cd /etc/rc.d/rc4.d
mv S52mydns S99mydns
cd /etc/rc.d/rc5.d
mv S52mydns S99mydns

MySQL uses the startup links S64mysql, so renaming the MyDNS startup links from S52mydns to S99mydns makes sure that MyDNS starts after MySQL.

The basic installation of MyDNS and MyDNSConfig is now finished. To log in to the MyDNSConfig interface, open a web browser and enter enter the following URL:

http://<your_ip_address>/mydnsconfig/

Replace <your_ip_address> with the IP address of your server.

The default username and password of MyDNSConfig are:

Username: admin
Password: admin

Don't forget to change the password after login under System > Users
   
Trả Lời Với Trích Dẫn
Old
  (#2 (permalink))
 
Status: Offline
Posts: 78
Tham gia: Dec 2007
Open mind Open lives
 
petern's Avatar
Default 23-01-2008, 10:23 23-01-2008

Using MyDNSConfig
In this chapter will demonstrate how to use MyDNSConfig by creating an example zone test.com and an A record www.test.com.
First log in:

http://images.howtoforge.com/images/...entos5.1/1.png

Click on the Add New Zone button:
http://images.howtoforge.com/images/...entos5.1/2.png

The form on the SOA tab is preseeded with default values. Fill in test.com. (please note the final dot!) in the Origin field and make changes to the other fields, if necessary. The Zone Transfers field can be left empty which means that any server can connect to our MyDNS server to initiate a zone transfer; if you fill in an IP address, only that system can connect:

http://images.howtoforge.com/images/...entos5.1/3.png

After you've clicked on Save, you will find your new zone listed on the Zones (SOA) page. Click on the test.com. link to go to the zone's properties:

http://images.howtoforge.com/images/...entos5.1/4.png

Next, click on the Records tab:

http://images.howtoforge.com/images/...s5.1/big/5.png

Then click on the Add New Record button to create a record (A/MX/CNAME/...):

http://images.howtoforge.com/images/...s5.1/big/6.png

To create the A record www.test.com, fill in www in the Name field, select A as the Type, type in www.test.com's IP address in the Data field (e.g. 1.2.3.4), and specify the TTL (in seconds). The Preference/Priority field can be left empty for A records; it's needed for MX records:

http://images.howtoforge.com/images/...s5.1/big/7.png

After you've clicked on Save, you will find www.test.com in the list of records for the zone test.com:

http://images.howtoforge.com/images/...s5.1/big/8.png

That's it already - no restarts are required. You can now test if MyDNS can resolve www.test.com:

dig @localhost www.test.com

If all goes well, the output should look something like this:

[root@server1 ~]# dig @localhost www.test.com

; <<>> DiG 9.5.0a6 <<>> @localhost www.test.com
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55393
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.test.com. IN A

;; ANSWER SECTION:
www.test.com. 86400 IN A 1.2.3.4

;; Query time: 24 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Dec 3 23:47:14 2007
;; MSG SIZE rcvd: 46

[root@server1 ~]#
   
Trả Lời Với Trích Dẫn
Trả lời


Ðiều Chỉnh
Xếp Bài

Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Tắt
HTML đang Tắt
Trackbacks are Mở
Pingbacks are Mở
Refbacks are Mở


Múi giờ GMT. Hiện tại là 02:21 21-05-2012.