Himself DynDNS or implementation of Managed DNS via PowerShell

On the street now a beautiful Sunny day, so most of the time I was spending out of your home with wide channel and somewhere in the Park with a netbook and a 4g modem. It is certainly better for my health, but, nevertheless, large files to download still want, so I had to look for alternatives ways to access my home network from the outside. Will notice right away that my ISP gives its users a dynamic white IPv4 addresses (fortunately, with the commissioning of IPv6 need of such perversions will automatically disappear).

The task standing before me:

/ >
    the
  1. Access to all computers in a network
  2. the
  3. Support for all protocols
  4. the
  5. 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.

In order to arrange access of this kind there are several options available:

    the
  1. VPN type LogMeIn Hamachi
  2. the
  3. Services dynamic DNS + port forwarding on the router
  4. the
  5. Bike: transfer outside external IP + port forwarding on the router


In considering the first option was dropped almost immediately because it is not free and only allows access to devices in General to all, added to the network that the facilities are not exactly add.

The second option has disappeared after long consideration, during which he revealed some drawbacks:

the
    the
  • Access to only one computer
  • the
  • Access is not ensured by message for the IP, and through the frame, which greatly reduces the possibility of use
  • the
  • it is Possible to forward only HTTP, which is not good

Remains only the third option, so we'll get to the city their solution for their needs.

For their implementation need: first, to know the current external IP, second to transfer it somewhere outside, and finally is to pass the packets through a home NAT. If the latter problem can be overcome means that each router, but with the first two to understand is a little more complicated.

So, after a short deliberation, to generate the script, it was decided to use PowerShell, which is built into Windows 7/8 tool in XP or Vista it can be retrofitted.

To obtain the external address to be used myip.ru, the output of which was analyzed by regexpal:

$ipsite = (new-object net.webclient).DownloadString("http://myip.ru")
e
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 outside. For this, after some hesitation, I decided to use Dropbox. But with its use there is one problem: I wanted to create an html file soderjaschii links to the right resources on your home network, but Dropbox is not showing the html created from Russia (Russian IP). After some search, it turned out that it is quite a gives the xhtml files, so could only pereverstyvat template and add it to the script.

The final version of the script presented at the the link.

To automatically run the script, use the standard task scheduler that runs a script every 10 minutes. Saved file should be in the Public folder or its subfolders.

In order to simplify the access to this file, and not to memorize a long link on it, I have used bit.ly and built there bitmark with a memorable address.
Article based on information from habrahabr.ru

Comments

Popular posts from this blog

Powershell and Cyrillic in the console (updated)

Active/Passive PostgreSQL Cluster, using Pacemaker, Corosync

Automatic deployment ElasticBeanstalk using Bitbucket Pipelines