Dynamic DNS instructions and an update “client” VBScript for freedns.afraid.orgPosted: 17/07/2013
Please note that this article is written in a light hearted way in order to appeal to IT novices and/or first time server runners!
Whenever you run a server for your favourite PC games like Minecraft or voip like Ventrilo or TeamSpeak you sooner or later realize that sharing your IP-address just isn’t reliable enough. This is because your internet service provider (ISP) eventually changes your supplied address every now and then. This is due to the system of distributing a limited amount of IP-addresses and reallocate those that are not in use.
As you may know most websites have a registered domain name representing their company name or subject of interest. These domains are rented in a “first in, first served” manner to anyone by a company called ICANN which was founded in the beginning of the internet. While ICANN itself maintains the root zone it does not directly manage all the connections whenever someone presses enter after typing in an address, these are responded by intermediate service providers via a protocol named the domain name system protocol (DNS).
Now lets get back to the main point of this post; the solution for you trying to run your server!
Registering a subdomain
Instead of renting a complete domain by yourself you may instead look at alternative subdomain services that are free to use. One of these is the popular freedns.afraid.org
This free service has a very large selection of subdomains to choose from. For example your could register the following, (sorry if they’re already taken :D)
The destination IP-address intentionally points too Google, I won’t be sharing mine!
Keeping your DNS updated
But here’s the thing, in order to keep myawesomeminecraftserver.anydns.com pointing to your IP-address you need to keep it updated and pointing to your current IP-address. In order to do this you need to configure some kind of script or client to check if your IP address has changed at regular intervals.
Instead of using a client or third party program for updating your Dynamic DNS you may prefer to be in total control of the code and actions and use a script similar to the following.
Fortunately freedns.afraid.org supplies an easy way to do this however you wish by supplying a link that you only need to click once in order to redirect the subdomain to your current IP-address. It works like a treat!
To find the link for your domain go here and click the Direct URL link to update your DNS to the current computer.
In order to automate this URL in the script below, make sure to copy the full link.
The full link should look something like the following:
Please note that I have intentionally removed the random letters.
Scheduling the script
The easiest and most configurable way to make sure that this script runs regularly and in the right intervals according to your needs is to use windows task scheduler.
If you keep the computer that’s acting server constantly online I suggest that you add the condition to Run every day at a certain time.
Please don’t run it too often. Running every hour is too much I think. In regard to the subdomain provider, remember that we want to keep their traffic minimized as much as possible. We want to make sure they can keep delivering their services for free!
If you only keep the computer that’s acting server online when you’re using it (i.e. a travel laptop) I suggest that you also add the condition to Run at system startup and Run when a user logs in
Copy and paste the following code into your favourite text editor or notepad (not MS Word!) and save as DNSUpdateURL.vbs or whichever name you prefer. Or download the script directly. Depending on your browser settings you may have to right click and select “save link as”.
You have to replace the updateURL = “” in settings to your Direct URL link (see above).
Keep the link inside the quotation marks and make sure that there are no accidental spaces at the beginning or the end.
' DNS URL Updater ' By Nirklars '=================================================================================== 'SETTINGS '=================================================================================== 'Change this file name to whichever you prever logFileName = "DNSUpdateLog.txt" 'Change the path to whereever you prefer logFileDirectory = "D:" 'This is where you copy and paste your own update url updateURL = "http://freedns.afraid.org/dynamic/update.php?herebemanyrandomletters" '=================================================================================== 'DECLARATIONS '=================================================================================== dim localPath, logFilePath 'Find local path where the script run from localPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".") 'Declare Log function variables Dim logFile, oFSO logFilePath = logFileDirectory & "\" & logFileName 'Declare File System object in order to write to log file Set oFSO = CreateObject("Scripting.FileSystemObject") 'Declare http object Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0") '=================================================================================== 'PROGRAM '=================================================================================== Log(httpGET(updateURL)) '=================================================================================== 'FUNCTIONS '=================================================================================== 'Retrieve a webpage function httpGET(strURL) On Error Resume Next oXMLHTTP.Open "GET", strURL, False oXMLHTTP.Send If oXMLHTTP.Status = 200 Then httpGET = oXMLHTTP.responseText ' function return else httpGET = "http GET failed" ' function return end if oXMLHTTP.Close end function 'Write to a logfile sub Log (msg) if oFSO.FileExists(logFilePath) then Set oTextFileCheck = oFSO.GetFile(logFilePath) 'Check if the log file has become larger than 1 mb if oTextFileCheck.Size > 1048576 Then 'If its too large, delete it oTextFileCheck.Delete end if end if Set oTextFile = oFSO.OpenTextFile(logFilePath, 8, True) oTextFile.writeline date & " " & time & ": " & msg oTextFile.close end sub