For Dynamic DNS, I use No-IP, but there are a lot of free and paid options:
Whatever you choose, you’ll need to sign up for an account, and create a hostname.
sudo DEBIAN_FRONTEND=noninteractive apt install -yq ddclient
Note: this installs
ddclient
without the interactive configuration, since it’s not terribly helpul.
There is a template ddclient.conf, which should have sample configs for all supported dynamic DNS hosting. Find the block that applies to your domain hosting, and
sudo nano /etc/ddclient.conf
Paste in your edited config. For example, this works with no-ip:
# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf
protocol=noip
use=web
login={your email address}
password={your noip password}
{your hostname}
Test your config:
sudo ddclient -daemon=0 -debug; echo $?
A good result will look something like this:
DEBUG: proxy =
DEBUG: url = http://checkip.dyndns.org/
DEBUG: server = checkip.dyndns.org
DEBUG: get_ip: using web, http://checkip.dyndns.org/ reports 123.45.67.89
DEBUG:
DEBUG: nic_noip_update -------------------
DEBUG: proxy =
DEBUG: url = http://dynupdate.no-ip.com/nic/update?system=noip&hostname=myhost.ddns.net&myip=123.45.67.89
DEBUG: server = dynupdate.no-ip.com
0
Next, you’ll have to set up a cron job to periodically update your IP:
sudo nano /etc/cron.d/ddclient
Paste in the following:
######################################################################
## ddclient is an IP address updater
######################################################################
## minute 0-59
## hour 0-23
## day of month 1-31
## month 1-12 (or names, see below)
## day of week 0-7 (0 or 7 is Sun, or use names)
######################################################################
## request an update daily
30 23 * * * root /usr/sbin/ddclient -daemon=0 -syslog -quiet
######################################################################
## retry failed updates every hour
0 * * * * root /usr/sbin/ddclient -daemon=0 -syslog -quiet retry
At this point, you should be good to move on to PiVPN.