d-type said:
However, in the Router help page, it says it'll only do it if the IP address changes, which it doesn't very often, so surely the dyndns account will timeout after a couple of months no?
Seems that it does time out after 30 days as I got the reminder from No-IP (and dyndns) a few days ago that my account will expire if I don't go to their site and sign in.
I can't be hassled with setting up paid service accounts and all that, so I started fiddling around with some VBScript and cobbled together something to get my external IP address, stick it in a http redirect file and FTP it to an ISP's web space.
An hour later I had this code below dumped in my c: and a scheduled task to run it on a daily basis - not pretty but seems to work.
'
' Get the external IP address of this internet connection, add it to an index.htm redirect file and upload it to my ISP web server
'
' V1.0 -- 2012-01-21
'
SetupRedirect "http://automation.whatismyip.com/n09230945.asp", "C:index.htm"
Sub SetupRedirect( myURL, myPath )
' Standard housekeeping
Dim i, objFile, objFSO, objHTTP, objShell
Const ForReading = 1, ForWriting = 2, ForAppending = 8
' Create a File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Create or open the target file
Set objFile = objFSO.OpenTextFile(MyPath, ForWriting, True)
' Write part 1 of the target file
objFile.WriteLine "<HTML><HEAD><META HTTP-EQUIV=" & Chr(34) & "refresh" & Chr(34) & " CONTENT=" & Chr(34) & "1;URL=http://"
' Create an HTTP object
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
' Download the specified URL
objHTTP.Open "GET", myURL, False
objHTTP.Send
' Write the downloaded byte stream to the target file
For i = 1 To LenB(objHTTP.ResponseBody)
objFile.Write Chr(AscB(MidB(objHTTP.ResponseBody, i, 1)))
Next
' Write part 3 of the target file
objFile.WriteLine "/pinball" & Chr(34) & "></HEAD><BODY></BODY></HTML>"
' Close the file
objFile.Close
Set objFile = Nothing
' FTP the file to the web
Set objShell = CreateObject("WScript.Shell")
objShell.Run "c:windowssystem32ftp.exe -s:ftpscript.txt", , True
' Delete the temp file
objFSO.DeleteFile "c:index.htm"
End Sub
http://automation.whatismyip.com/n09230945.asp is handy, it gives back a plain text file page with your ip address in it, much easier than having to grep and pipe a page from whatsmyip.org.
Output file looks like this:
<HTML><HEAD><META HTTP-EQUIV="refresh" CONTENT="1;URL=http://
123.456.789.123/pinball"></HEAD><BODY></BODY></HTML>
Now, going to that place on my ISP's web space automatically points it to my home PC web server. Blimey, I just replicated dyndns and no-ip's technical product in 1 hour - I'm gonna be rich!!!
Here's the ftpscript.txt file referred to in the file above:
open ftp.plus.net
bkeaton
PASSWORD_GOES_HERE
cd htdocs/pje/pinball/
put index.htm
quit
First time I've ever used VBScript, it's a piece of cake if you've done VBA before, although it's being superseded by Powershell for .net. That said, I only upgraded to WinXP about a year ago, so I'm fine with it
. Coding's fun, maybe I'll get a job doing that again someday...
D-T
d-type2012-01-22 13:46:05