5.0-Nano: DtDNS: Difference between revisions
mNo edit summary |
m (Reverted edits by Upazixorys (Talk); changed back to last version by Ric) |
(One intermediate revision by one other user not shown) | |
(No difference)
|
Latest revision as of 17:37, 24 November 2010
5-Nano: Introduction | Install and Run | Control | DtDNS | Cron| Security features | Enable SSL | Multi-Servers | Perl | UniTray | Security and passwords | Known Issues | Support
|
|
Uniform Server and DtDNS
Majority of domestic Internet connections are via a dynamic IP address, one that changes every time you connect to the Internet. This means you cannot run a web server unless you purchase a, static IP address from your ISP (Internet service provider). Even with a static IP you require and entry in a DNS server that converts your domain name into this IP address allowing other users to access your server.
An alternative is to use a free service such as DtDNS they provide accounts that allow you to obtain a domain name and tracking software to automatically update your IP address as it changes. A big advantage of their free service they automatically enable Wild cards by default.
Uniform Server supports the DtDNS service by integrating a, simple PHP scrip to automatically update hostname IP address at DtDNS. Script is configurable allowing you to update all five free hostnames. The script can optionally be run by cron making the whole task transparent.
Note: The script is portable hence popping the servers on a USB memory stick means you can have them on-line and accessible within ten minutes (DNS propergation time) if new PC host has been configured to allow Internet server traffic.
Note: This script has been rewritten now includes a configuration file refer to supplementary section (5.2-Nano and 5.3-Nano) for details.
DtDNS account
Creating an account at DtDNS is extremely easy.
- Go to DtDNS home page.
- To the right of log in click Create an Account
There are two pages to fill in, enter the following details:
Page 1: | ||
1) | Desired Username | This name is used for logging into your account |
2) | Your Name | Your real name (Internal use) |
3) | Desired Password | A password for logging into your account |
4) | Confirm Password | As above |
5) | E-mail Address | A real active e-mail is required, activation code sent to this e-mail address |
6) | Confirm E-mail | As above |
7) | Optional | Skip the Optional Information section if you wish fill it in. |
8) | Two CAPCHA words | Enter the two CAPCHA words (if these are difficult to read click the new challenge button) |
Page 2: | ||
9) | Username | Enter your Username as entered in 1). |
10) | Enter code | Enter code sent to your email. (Note: The email contains a link to page 2 hence you can close the page and wait for the e-mail.) |
Login - Create Hostname
General information:
Will look like this: http://books.effers.com |
|
|
Wild Cards:
After creating a hostname wild cards are enabled by default. This allows you to use a URL such as
http://www.books.effers.com - Note www. is the wild card part this can be anything you like for example:
- http://www.books.effers.com
- http://www-internation.books.effers.com
- http://local.books.effers.com
- http://www.home.books.effers.com
books.effers.com resolves to your IP address you can use the wild card on your server to resolve to different sites.
Create Hostname
To create a new hostname at DtDNS
Login
- Go to | Login page
- Enter Username: as set in step 1)
- Enter Password: as set in step 3)
- My Services page displayed
- Click on Hostnames this opens the Hostname Manager
Create hostname
- Enter a desired Hostname
- From the drop down menu select a Domain
- Click Add Hostname
- Enter the two CAPCHA words (if these are difficult to read click the new challenge button)
- Click Add Hostname button
- This is added to your list of host names
Manage existing hostnames
To manage existing hostnames, simply click the entry in the list for example see below.
Hostname | Domain | IP Address | Type |
uni23 | dtdns.net | 89.119.35.45 | Active Dynamic |
books | effers.com | 87.129.30.174 | Active Dynamic |
Click a hostname link opens its corresponding configuration page. Here you can change various settings, including the IP address.
Note: After adding a new host the IP address is set to your current IP address. You can manually change it on the configuration page or request an IP update see later.
Script Configuration
You need to configure the script, which can be found in folder:
UniServer\plugins\dtdns_updater\dtdns_updater.php
In the user configuration section locate these lines:
- $id_pw[] = "books.effers.com,fred123"; // Change
- $id_pw[] = "books.effers.com,fred123"; // Change or delete
- $id_pw[] = "books.effers.com,fred123"; // Change or delete
Substitute books.effers.com with your real host and domain names, replace the password fred123 with the one you set in step 1)
If you have only a single host delete the other two lines. Otherwise modify them for each additional host as above. Add additional lines as required.
<?php /* ############################################################################### # Name: The Uniform Server DtDNS Updater v 1.0 # Developed By: The Uniform Server Development Team # Modified Last By: Mike Gleaves (Ric) # Web: http://www.uniformserver.com ############################################################################### */ //error_reporting(0); // Disable PHP errors and warnings // Comment to Enable for testing chdir(dirname(__FILE__)); // Change wd to this files location include_once "../../unicon/main/includes/config.inc.php"; include_once "../../unicon/main/includes/functions.php"; run_location_tracker(); // Have servers moved if moved update configuration print"\n"; //######################## User Configuration ################################# // Add as many lines as required with the following format: // $id_pw[] = "hostname,password"; // For example: // $id_pw[] = "books.effers.com,fred123"; // $id_pw[] = "power.dtdns.net,gun22powder"; //----------------------------------------------------------------------------- $id_pw[] = "books.effers.com,fred123"; // Change $id_pw[] = "books.effers.com,fred123"; // Change or delete $id_pw[] = "books.effers.com,fred123"; // Change or delete //###################### END User Configuration ############################### $test = false; // Test true = display IP address and host names // false = no display foreach ($id_pw as $value) { // Iteratate through array $idpw_array = explode(",",$value); // Split id pw pairs if(get_ip_dns($idpw_array[0])){ // Was IP from DNS returned if(get_ip_current()){ // Yes: Current IP returned if($test){ // Test code print "DNS IP = $ip_dns CURRENT IP = $ip_current $idpw_array[0]<br/>\n"; } if($ip_dns != $ip_current){ // Are IP's different dtdns_update($idpw_array[0],$idpw_array[1]);// yes: Update required } } } }// End foreach //=== Get IP from DNS server ================================================== // Input: ID = Hostname: // Output: Return value true = IP was obtained // Output: Return value false = IP not obtained or error // Output: $ip_dns either IP address or host name function get_ip_dns($hostname){ global $ip_dns; // IP address saved from DNS server $ip_dns = gethostbyname($hostname); // Get IP address of hostname if($ip_dns == $hostname){ // Is hostname returned (not IP address) return false; // yes: failed to get IP address } else{ // no: IP obtained return true; // set success } } //============================================== END Get IP from DNS server === //=== DtDNS Host Update Page ================================================== // Input: $id = Hostname: // Input: $pw = User password // Output: Return value true = sucess false = failed function dtdns_update($id,$pw){ $id_val = urlencode($id); // User Host on DtDNS $pw_val = urlencode($pw); // User password $client_val = urlencode('UniServerV1'); // Optional - But added it $url = 'https://www.dtdns.com/api/autodns.cfm'; // DtDNS update page // Build complete URL $str= $url."?id=".$id_val."&pw=".$pw_val."&client=".$client_val; // Access page using Curl SSL $ch=curl_init(); // Initialize Curl get handle curl_setopt($ch,CURLOPT_URL,$str); // Set Curl URL option curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // no verify curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10); // timeout set to 10 sceonds curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); // curl_exec ouputs a string $buffer = curl_exec($ch); // run above, save to buffer curl_close($ch); // Close Curl frees memory // Test returned page if(preg_match("/now\spoints\sto/",$buffer)){// Is returne value "now points to" return true; // yes: update OK } else{ // no: Failed return false; } } //============================================== END DtDNS Host Update Page === ?> |
Manual Update
You can run the following batch file to manually force an update, remember to leave around ten minuets before performing another manual update.
It takes around ten minutes for the DNS to propagate, additional updates within this period are regarded as an abuse and you may find your IP banned.
Batch file: UniServer\plugins\dtdns_updater\Run_dtdns_updater.bat
Contains:
COLOR B0 @echo off cls rem ### working directory current folder pushd %~dp0 ..\..\usr\local\php\php.exe dtdns_updater.php rem ### restore original working directory pause popd EXIT
Cron - Automatic update
Cron provides a periodic tick Uniform Server's default is every ten minutes.
DtDNS automatic updater has been pre-configured however it is disabled by default.
To enable Cron edit file UniServer\unicon\main\run_cron.php
Locate these two line in section List of scripts to be run
// $cmd = 'start ..\..\usr\local\php\php-win.exe ..\..\plugins\dtdns_updater\dtdns_updater.php'; // pclose(popen($cmd,'r')); // Start detatched process
and uncomment as shown below
$cmd = 'start ..\..\usr\local\php\php-win.exe ..\..\plugins\dtdns_updater\dtdns_updater.php'; pclose(popen($cmd,'r')); // Start detatched process
Notes:
- When the server is first started Cron is run and the IP addreess updated if different
- Every ten minuets Cron is run and the IP address are checked if different are updated.
- Cron only runs when the servers are running however you can force an update using the batch file mentioned above.
- Cron can be manually or automatically started see next page for details.
Summary
For a home web server the free account at DtDNS is ideal at least it gives you an opportunity to test their service. Perhaps it will encourage you to purchase a real domain and use some of their paid services.
The next page looks at Cron in more detail.