Snap DynDNS Server enables you to set up your own easy and simple Dynamic DNS service.
Go to file
Max Mehl a1c55f4574
use command -v instead of which. The latter is an alias on some envs
2020-10-27 11:48:50 +01:00
.gitignore add gitignore 2016-04-27 22:47:20 +02:00
.htaccess initial commit 2016-04-27 22:48:27 +02:00
LICENSE initial commit 2016-04-27 22:48:27 +02:00
README.md Add information about usage with a FritzBox 2017-11-02 13:45:17 +01:00
config.cfg.sample initial commit 2016-04-27 22:48:27 +02:00
index.html initial commit 2016-04-27 22:48:27 +02:00
screen-inwx-id.png initial commit 2016-04-27 22:48:27 +02:00
update.api initial commit 2016-04-27 22:48:27 +02:00
update.php initial commit 2016-04-27 22:48:27 +02:00
update.sh use command -v instead of which. The latter is an alias on some envs 2020-10-27 11:48:50 +01:00
users.db.sample initial commit 2016-04-27 22:48:27 +02:00

README.md

Snap DynDNS Server using INWX domains

Snap DynDNS Server enables you to set up your own simple Dynamic DNS service. It requires you to use domains managed by the registrar InterNetworX (inwx.de) and their API. This server may be simply customised to be able to work with other domain sellers and their specific APIs.

It can set the IP of any existing domain entry, may it be IPv4 or IPv6 (and theoretically all kinds INWX supports). All domains of the clients have to be part of the same INWX account.

The idea of the service is to enable compatibility with as many client devices as possible. So clients only would need to send a GET or POST request to your service which contains their individual user data (which you can create freely) and their desired IP address for their domain.

This server has a client application as counterpart, named Snap DynDNS client. Using the latter, you will be able to retrieve the IP of your computer and send it to this service which in return updates the domain for you.

Requirements

The installation requires the possibility to execute PHP and Bash files. It also requires curl to be installed. There's no need for a database to be installed as everything is handled by flat text files.

The code has been tested with PHP 5.5, CentOS 7, and Apache 2.2.15. Please be aware to migrate the .htaccess file if you use other webservers so the sensitive files like config.cfg and users.db are safe.

Installation

Clone the git repository to your server and move them to a public web-accessible folder of your choice. Now rename/copy the files config.cfg.sample and users.db.sample to config.cfg and users.db respectively. Open them in an editor and modify the settings so they match your data.

config.cfg

In this file you have to put your inwx.de username and password. It is needed to login to the API and update the IP of your domain entry.

users.db

In this file you can create users which can use your service. Unauthorized requests which do not match any of the content here will not work. Each line matches one existing single domain entry in your INWX account. It is not necessary the DynDNS domain names to be part of the same domain (example.com), they can also be different ones they just have to be part of the same INWX account (please tell me if you need this to be improved, it shouldn't be a big deal).

Gather INWX domain ID

Given you own the domain example.com which you can administrate in your INWX account. For each client, you can create a subdomain, in this example user1.example.com and user2.example.com. For INWX, each domain has a unique ID. To find out this ID, you will have to use a tool like Firebug or the in-built web inspector tools by Firefox or Chromium. Use the inspect element feature, hover over the subdomain line in your nameserver/DNS settings (where you can define the IPs, currently on https://www.inwx.de/de/nameserver2), and in the id attribute of the <div>-element you should find a string with around 9 numbers. This number is the domain entry's ID. Please see the screenshot for how it should look like.

That's how you get the ID of your single domain

Back in users.db, type in the domain name (user1.example.com) and its INWX ID. For username and password, you can freely create one and give to your users. Each request to your service requires the correct domain name, a username and a password. Only if all three match, the IP change request will be executed.

Usage

Please feel free to use Snap DynDNS client which is the perfect combination for this server application.

Please note: You cannot define whether it shall be an A, AAAA or whatever record. You would have to do that in the INWX webpanel once, the ID should stay the same.

curl

You can use curl with a POST request:

curl -X POST -d "domain=user1.example.com&user=myuser&pass=mypassword&ip=1.2.3.4" "https://yourdyndnsservice.net/update.php"

You can also use GET requests which is not recommended. The advantage of POST requests is that the request is encrypted via SSL if you use a HTTPS domain. GET requests can be intercepted quite easily which is bad because you send sensitive data. A GET request would look like this

curl -d "domain=user1.example.com&user=myuser&pass=mypassword&ip=1.2.3.4" "https://yourdyndnsservice.net/update.php"

This will send following data to your Snap DynDNS server which is running under the domain https://yourdyndnsservice.net in this example:

  • domain=user1.example.com: This is the client's personal DynDNS domain
  • user=myuser: This is the client's username which you can define freely
  • pass=mypassword: This is the client's personal password which you can define freely.
  • ip=1.2.3.4: This is the IP which shall be set to this single domain

AVM FritzBox

In the AVM Fritz!Boxes you can choose a custom DynDNS provider. In order to connect it with your Snap DynDNS server, use following data:

Update-URL: yourdyndnsservice.net/update.php?domain=<domain>&user=<username>&pass=<pass>&ip=<ipaddr>
Domainname: user1.example.com
Username: myuser
Password: mypassword

Be sure to not add an URI scheme like https://, the device will throw an error. The IP address is set automatically by the device. Note that you can also set your IPv6 address by using <ip6addr> in the URL.