DynDNS itself or Managed DNS implementation through PowerShell

There are beautiful sunny days on the street, so most of my time I began to spend outside my house with a wide channel, and somewhere in the park with a netbook and 4g modem. This is undoubtedly better for my health, but, nevertheless, I still want to download large files, so I had to look for options for organizing access to my home network from the outside. I note right away that my provider gives its users dynamic white IPv4 addresses (fortunately, when IPv6 is put into operation, the need for such distortions will automatically disappear).

The tasks before me:

  1. Access to all computers on the network
  2. Support for all protocols
  3. Ease of use

A word about the structure of my home network:
Computers (Win 7 + Win XP) -> Router (ZyXEL Keenetic 4G (firmware v2.00)) -> L2TP VPN -> Internet.

To organize this kind of access, several options are available:

  1. VPN like LogMeIn Hamachi
  2. Dynamic DNS services + port forwarding on the router
  3. Bicycle: external IP transfer outside + port forwarding on the router


In the process of consideration, the first option fell away almost immediately, since it is not free, and also gives access only to devices in general to all added to the network, which certainly does not add convenience.

The second option fell away after a longer consideration, during which some shortcomings appeared:

  • Access to only one computer
  • Access is provided not by accessing IP, but through a frame, which greatly reduces the possibilities of use
  • Only HTTP redirection is possible, which is not good

Only the third option remains, which means that we will make our decision for our tasks.

To execute them, you need: firstly, to find out the current external IP, secondly, transfer it to somewhere outside, and finally, transfer packets through home NAT. If the last task can be handled by the means that each router has, then the first two are more difficult to deal with.

So, after a little thought, to create a script, it was decided to use PowerShell, which is a built-in tool in Windows 7/8, in XP or Vista it can be installed.

To get an external address, the site myip.ru was used , the output of which was understood by the regexp:

$ipsite = (new-object net.webclient).DownloadString("http://myip.ru")
е
if ($ipsite -cmatch '(?s)([0-9]{1,3}?\.[0-9]{1,3}?\.[0-9]{1,3}?\.[0-9]{1,3}?)') {
$ip = $matches[1]
} else {о
Write-Error "Cannot get ip!"; return
}


Now that we know our IP address, we need to pass it out. To do this, after some thought, I decided to use Dropbox. But there is one problem with its use: I wanted to create an html file containing links to the resources of the home network I need, but Dropbox does not show html created from Russia (from Russian IP). After some searching, it turned out that he completely gave away the xhtml files, so all that was left was to re-create the template and add it to the script.

The final version of the script is presented here .

To run the script automatically, a standard task scheduler is used that runs the script once every 10 minutes. The file must be saved in the Public folder or its subfolders.

In order to simplify access to this file, and not memorize a long link to it, I used bit.ly and created a bitmark there with a memorable address.

Also popular now: