A homeserver or any other device with a dynamic IP that should be accessable from the internet needs to be registered to a dynamic DNS service
Dynamic DNS (DDNS or DynDNS) is a method of automatically updating a name server in the Domain Name System (DNS), often in real time, with the active DDNS configuration of its configured hostnames, addresses or other information. Read more.
Setup your own
An easy and secure way to setup your own DDNS like service requires just a webspace with PHP enabled. You will not get a real DNS record but an ever working forward.
Put a script like this on your webspace as whatever.php. You should place it within a cryptic path to secure it eg.
"https://yourwebspace.eu/c6S74a9f0dGD6bc34bb/whatever.php" because every access will update the stored IP!
If you now download that file it will:
- Store your IP at "ip.php"
- Your download will be a log file containing a timestamp of your sync
To update it every 5 Minutes from your Linux server add this to your crontab (crontab -e) as root:
*/5 * * * * rm whatever.php*; wget https://yourwebspace.eu/c6S74a9f0dGD6bc34bb/whatever.php
Usage on your webspace
You have now a plain-text-file containing the current IP of your homeserver to use within your website and scripts. You can include it in your site with the html-tag:
If you want to host a website on that server you could build a link with:
<a href="http://<?php include "ip.php"; ?>">Linktext</a>
Usage on a Linux system