djbdnsrocks.org latest news
A major site renovation is under way. Please excuse the mess while this is in progress.
Home
About
The Installation
Extra Options
faq
Journal of Events
Links
The future
Contact Me

Single server DNS solution
- Deploying Vegadns -

In this next step, we're going to install a web based DNS management tool called Vegadns. This tool will make the day to day DNS management a bit easier for you and any assistants you may have.

In addition to having djbdns, daemontools and ucspi-tcp installed, you will also need:

php 4 or higher with mysql functionality
mysql 3.x or 4.x installed

You will want to install Vegadns directly into the public web directory of your server. This folder, for example, may be /var/www/html. If I'm confusing you at this point, you will need to familiarize yourself with Apache.

cd /path/to/your/server/web/directory

(Example: cd /var/www/html)

Now we unpack Vegadns into your server's public web directory...

tar zxvf /path/to/djbdnsrocks/vegadns-0.9.10.tgz

And let's rename it to something friendly...

mv vegadns-0.9.10 vegadns

Now it's time to create the vegadns database and database user. This database will store all of your DNS server's domain records as well as all vegadns user information.

First we create the vegadns database...

mysqladmin -u root create vegadns -p

Enter your mysql server's root password when prompted. Upon authentication, a new database called "vegadns" will be created.

Now we create a user which will have rights on the vegadns database...

mysql -u root -e "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER ON vegadns.* TO vegadns@localhost IDENTIFIED BY 'password'" mysql -p

Enter you mysql server's root password when prompted. Upon authentication, a new user called "vegadns" will be added to your mysql server and that user will be assigned all needed privileges on the "vegadns" database.

Alright. That's it for the database business. Now it's time to configure Vegadns itself. The first thing we will do is create series "private" directories. These directories will store template information, config information, caching information and session information. The location of the folder containing these "private" directories will be located just outside of your web server's public directory. This location will vary from system to system, so you will need to know how your particular server is configured in order to supply the correct information. On Redhat, for example, the public html directory is usually located at /var/www/html. So, in the case of Redhat, I would place the private folder just outside on the html directory, at /var/www/vegadns_private. So let's get to it...

cd /path/to/your/server/web/directory/

(Example: cd /var/www/html)

mkdir -p vegadns_private/templates_c
mkdir vegadns_private/configs
mkdir vegadns_private/cache
mkdir vegadns_private/sessions

Here's an example. Keep in mind that this path may vary. Don't be a dumbass here. Find out how your web server is configured and make whatever adjustments are needed...

mkdir -p /var/www/vegadns_private/templates_c
mkdir /var/www/vegadns_private/configs
mkdir /var/www/vegadns_private/cache
mkdir /var/www/vegadns_private/sessions

Now we will grant ownership of this new directory to whatever user your Apache server runs as. On Redhat, this is usually a user called "apache". On FreeBSD, it could be a user called "www" or "nobody". Again, check your Apache setup to be sure.

chown -R apache:apache vegadns_private

And now we set the correct permissions on the directory...

chmod -R 770 vegadns_private

OK, that's it for the private directory. Now it's time to edit the master Vegadns config file. Again, the path to this file will vary, but it will be in the public web directory that you unpacked Vegadns in to begin with. On Redhat, for example, this would be /var/www/html/vegadns/src/config.php.

vi vegadns/src/config.php

Make sure that each of the following variables are set accordingly. As always, I have highlighted in RED the areas where you will need to substitute in the correct information.

$private_dirs = '/path/to/web/server/root/vegadns_private';

// Mysql settings
$mysql_host = 'localhost';
$mysql_user = 'vegadns';
$mysql_pass = 'password';
$mysql_db = 'vegadns';

$vegadns_url = 'http://127.0.0.1/vegadns/';

$supportname = "Your Organization";
$supportemail = "postmaster@yourdomain.com";
$trusted_hosts = '127.0.0.1';

Note: If you plan to administer your DNS server from somewhere besides localhost, you will need to add that IP address to the $trusted_hosts variable above. Each IP is separated by a comma.

Save and exit the file.

Now it's time to test Vegadns. We'll log into the web interface, make some changes and create a zone entry or 2. After that we will make the zone entries active by writing the changes out the actual tinydns data file.

So let's do it...

Log into your Vegadns interface:

http://yourdomain.com/vegadns (screenshot)

For our first login, we will use the default login account that comes with Vegadns...

Email: test@test.com
Password: test

Once you are logged in, you'll want to start customizing your Vegadns setup and then create some domain entries. After that, you will then want to write your new domain entries out to the actual tinydns data file. Any and all changes made in the Vegadns interface are only live once those changes get written to the tinydns data file. We'll go over that further down the page. I've divided this work into 4 sections:

Configuring your user account

The first thing you will want to do is to change the login account information. This is done by clicking on "accounts" and then editing the account info for the "test@test.com" user (screenshot). You will want to do a couple things to that user:

1. Change the name to yours

2. Change the email address to your own.

3. Change the password to a more personal one.

4. Keep the privileges set to "senior_admin".

You can also create any other users you may desire in the "accounts" section.

Configuring the default domain settings

Next, you will want to configure the default template for all domains. A default domain template ensures that every time you create a new domain entry on your tinydns server, it gets created with certain basic settings and records. The domain gets created with pre-configured A records, MX records, nameservers, TTL settings and more. Then, all you have to do is make any customizations to the new domain and you're all set. In short, a domain template saves time and ensures that all domains get created in a standard fashion. So let's do it...

You can edit the default domain settings by clicking on the "Default Records" link in the Vegadns interface. Now it's simply a matter or setting whatever defaults you want each domain to have.

Here's a screenshot of an example default setting. Make sure you substitute in your own IP addresses and any custom records you may want.


click to enlarge

Creating a new domain entry (required)

NOTE: You must create a domain entry in this step. Failure to do so will prevent you from successfully testing the nameserver update script below.

Now that you've got a default domain template, you can create a new domain on your tinydns server. This is easily done by clicking on the "New Domain" link and following the instructions. You will notice that the new domain gets created with the default settings that you specified in the default domain area. Once the domain has been created, you can then go in and customize the record for that domain to your liking, if any customizations are needed at all. Pretty cool, huh?

Writing the changes out to tinydns

As I said above, all changes made with Vegadns are not live until you write them out to the actual tinydns data file and then run "make" on that file. The changes you make ARE instantly written to the vegadns database, but that database DOES NOT control tinydns. It is only when the database contents are written out to tinydns that your changes are made live.

Fortunately, Vegadns comes equipped with a handy script that writes all changes out to tinydns. This script is called update-data.sh.

So let's set up the update-data.sh script...

cd /path/to/vegadns

mv update-data.sh update-date.sh.old

And now we'll copy a customized version of the update-data.sh script that I've created over to the vegadns directory. The custom scripts simply writes the changes out to 2 nameservers instead of 1.

cp /downloads/djbdnsrocks/scripts/update_data_single.sh ./update-date.sh

chmod 750 update-data.sh

And now we will copy this script to a more handy location...

cp update-data.sh /usr/local/sbin/update-data.sh

OK, now it's time to test the update-data.sh script and make sure it's updating our nameservers correctly. Assuming you DID create a new domain entry up above, all we need to do is run the update scripts and then the data should be pushed out to the new nameservers.

So let's do it...

update-data.sh

Let's see if it worked. If it worked, the scripts should have taken the domain information you entered in Vegadns and written out to both of our nameservers. You will want to verify new content in the following files. This can be done by checking both the content of the files AND by checking the timestamp for each file.

/etc/tinydns/root/data (will contain the readable zone entries)

/etc/tinydns2/root/data (should be identical to the file above)

/etc/tinydns/root/data.cdb (will consist of a mess of illegible code)

/etc/tinydns2/root/data.cdb (should be identical to the file above)

Once you have verified that the above files have been written to, we'll make a final check to make sure that the files for each nameserver are EXACTLY IDENTICAL. We will do this by running "diff" on the data and data.cdb files for each nameserver. If the files are exactly identical, the following command should produce NO OUTPUT. If they are not identical, the following commands will state their differences.

diff /etc/tinydns/root/data /etc/tinydns2/root/data

diff /etc/tinydns/root/data.cdb /etc/tinydns2/root/data.cdb

If you find that the files are not identical, this is bad. For whatever reason, the update-data.sh script is NOT writing the same data out to both nameservers. You will need to go back over each step on this page and look for where you screwed up.

Once you've successfully verified that both nameserver are being written to by the update script, we will install a cronjob to run the update script every 10 minutes. In this way, anytime you update your Vegadns domain entries, you will only have to wait a maximum of 10 minutes before the changes are automatically written our to tinydns and put into effect. Not bad.

crontab -e

*/10 * * * * /usr/local/sbin/update-data.sh > /dev/null

Save and exit from the crontab editor.

Alright! You've done it. You now have a fully functioning DNS server and a user friendly interface for managing all of your domains. It doesn't get any easier than this! In the next few steps, we'll test out our new DNS server as well as take a look behind the scenes so that you will have at least a basic understanding of how things work. We will also go over a few tweaks, tips and tricks as well as discuss expansion plans, should you ever want to expand your DNS system to a more professional configuration.

 

Proceed to step 7

 

Modified
Site last modified: October 08, 2006 11:07:54 EDT
   
 
The Rocks Project