Installing External DNS For Your Interworx Server(s)
If you are like us and have several Interworx servers that house clients, and
want those clients to be able to change their DNS settings through the Interworx cp you are pretty much out of luck without some serious hacking.
Well, we had the same problem and decided to solve it. Here is a short HOWTO on syncing all of your Interworx servers with an external tinydns server(s).
Here is what is needed:
- A server, or servers with the Interworx CP installed. Steps will be color coded green
- A server, or server with an Interworx compatible OS installed. Steps will be color coded blue
- About an hour
- A brain with a mass of at-least 525 grams. For more information on calculating brain mass, please visit: http://www.roadtoreading.org/personal/brain_power.html
- Some sense of humor
For everyoneâs clarification here are the terms that we will be using in this HOWTO:
- CPServer = Refers to one of your Interworx servers that you would like to sync with a "DNS Server"(see next item).
- DNS Server = Refers to one of your external DNS servers that will actually be publishing the data from your CPServer(s).
- Tinydns = The actual DNS program that runs on your "DNS Servers" (see item above).
- *word* = The inclusion of "*" marks around a word means that the word is emphasized.
- // = When a line starts with these symbols: "//" it is a comment...Don't type this on the command line...It is just me trying to help you understand a specifc command.
- patience = The capacity, quality, or fact of being patient
- hosed = [i]"(Slang.) To attack and kill (a computer entity), typically by use of a poorly executed user input, example: Peter hosed the computer by typing: (rm -rf /)."[/i] [b]THIS IS ALWAYS BAD[/b]
Warning: This HOWTO and related scripts are provided with absolutely positively no warranty. Any damage they do to your system we are indeed sorry for, however we cannot be help liable. Proceed at your own riskâŚ(it really isnât that bad).
Ok, throw on your brain protectors, grab a Mountain Dew, and perhaps say a small prayerâŚlets begin.
Step #1 - Install tinydns(and related apps) on your DNS Server(s)
Since this HOWTO is relatively platform inspecific (you can make it work on a FreeBSD box), we will use the standard install(compile).
[b]Hose Potential Warning: These steps must NOT be executed on your CPServers![/b]
Visit: http://cr.yp.to/djbdns/run-server.html for the exact step by step instructions on installing tinydns.
Step #2 - Install PHP On Your DNS Server(s)
Yeah yeah, I knowâŚa simple SH would have been easierâŚbut I like PHP, support itâs use in shell scriptingâŚand Interworx uses it as well. It was just a natural selection.
The script for syncing the CPServer(s) to the DNS Server(s) does not need any special modules installed. We just need to do a standard install.
mkdir /var/src
mkdir /var/src/tar
cd /var/src/tar
wget http://techdev.gethosted.net/php/php-current.tar.gz
cd /var/src
tar zxf tar/php-current.tar.gz
cd php*
./configure
make
make install
You should see quite a few lines run by, and hopefully no errorsâŚIf there were errors take a look here: http://www.php.net/manual/en/install.php
Step #3 - Grant Access To Your DNS Server(s) On Your CPServer(s)
Interworx comes with a pretty nifty XML access system that lets other computers access the DNS records it currently publishes via a PHP file. This option is disabled by default, however we can selectively add in the authorized IPs by editing a simple text file. Lets begin:
// This assumes you are on your CPServer and at a command line
cd /home/interworx/etc/
vi remote-access.ini
Great, you should now have a file that looks a little like this:
[dns]
exportdns.allow=""
We want it to look like:
[dns]
exportdns.allow="xxx.xxx.xxx.xxx"
Please replace the âxxx.xxx.xxx.xxxâ with the IP of your DNS Server(s). If you have multiple DNS Servers that will be accessing this CP Server seperate the IP addresses with the â|â symbol.
Go ahead and save that fileâŚWe are all done with the CP Server
Step #4 - Download The DNS_SYNC Script On Each DNS Server
Ok, we donât have much leftâŚNow we just need to download the DNS_SYNC script and configure it.
mkdir /usr/local/dns_sync
cd /usr/local/dns_sync
wget http://techdev.gethosted.net/dns_sync/dns_sync
chmod 770 dns_sync
Ok, greatâŚif everything went ok we just downloaded DNS_SYNC and made it executable.
Now we need to configure it for your specific installation:
vi dns_sync
You should now see the actual syncing script, and there should be quite a few comments. Read each of those comments, the defaults usually are ok for most installations, but if you have errors while syncing make sure they are correct.
After you have read through the comments, and made the corresponding changes save the file and return back to the prompt.
IMPORTANT: The last variable in the variable section is a variable called: $TEST_MODE . This variable defaults to: true (Test Mode is one). Test mode will just download the DNS data from your CP servers, however it will not overwrite your default tinydns datafile, nor will it create a .cdb file.
Once this variable is set to: false , the tinydns datafile will be overwritten with the dns_sync created one and dns_sync will create a new cdb file.
Ok, now that we have the configuration stuff taken care of we need to test the script to see if everything is running. Go ahead and type the following from a command prompt:
/usr/local/dns_sync/dns_sync
You should see some status messages outputted to the shell screen while dns_sync is working.
Here are some crucial lines:
##### XML Data File Successfully Downloaded For: yourserver.domain.com #####
That one is very goodâŚJump up and down 10 times if that one is displayed!
####### - {insert number here} records added for server: yourserver.domain.com
That is also goodâŚ10 more jumps for you!
##### Writing yourserver.domain.com data to new tinydns datafile.....Done
That is the best oneâŚThat means all of the tinydns data has been successfully parsed and added to a temporary datafile.
You can feel free to take a look at that datafile if you would like to make sure all of the configuration is correct. You can take a look at it by doing:
cd /usr/local/dns_sync/data
cat data
Once you are happy that everything is correct, go ahead and set the $TEST_MODE variable in the dns_sync script to false, and run the command again:
/usr/local/dns_sync/dns_sync
There should be two additional lines outputted by the scriptâŚthey are:
##### Copying new data to tinydns production file
##### Running the tinydns makefile.......Done
##### dns_sync completed successfully
Now everything should be syncâd correctly!
We have the script sync with all of our Interworx server(s) every 5 minutes. The bandwidth transferred is really negligible, and the ability for users to create/edit subdomains from within Interworx is a huge plus!
If you received any errors during the process feel free to post them to this thread or to e-mail me: techdev@gethosted.net
This is a beta release, so feedback/bug reports would be much appreciated! Enjoy!
Peter