My ISP provider allows an interface with their DNS via ddclient protocol. We will use the ddclient on the server to update DNS every time the external IP changes.
Install the ddclient
sudo apt-get install ddclient
At the installation questions choose
Other
Dynamic DNS server
www.ovh.com
Protocol
dyndns2
Username
scottworld.net-solaris
You can answer through the questions…. check the /etc/ddclient.conf file for settings below.
Edit the /etc/ddclient.conf
sudo nano /etc/ddclient.conf
daemon=600 # check every 600 seconds syslog=yes # log update msgs to syslog mail=mark@scottworld.net # mail all msgs to root mail-failure=mark@scottworld.net # mail failed update msgs to root pid=/var/run/ddclient.pid # record PID in file. cache=/tmp/ddclient.cache # Cache file ### Select one of these options to determine your IP address ## via hardware interface (if you don't have a router/firewall) #use=if, if=eth0 ## via our CheckIP server use=web, web=www.scottworld.net/ip.php, web-skip='IP Address' #use=web, web=checkip.dynu.com/, web-skip='IP Address' ## from the status page for a linksys router/firewall #use=linksys, fw=linksys, fw-login=admin, fw-password=admin ## from a FW status page #fw-login=admin, fw-password=XXXXXX #use=fw, fw=192.168.1.254/status.htm, fw-skip='IP Address' ## Enter your Ovh DynHost username and password here login=XXXXXXXX # your Ovh DynHost username password=XXXXXXXX # your Ovh DynHost password ## This section requires no changes unless you need to set a default proxy server ## or you need to bypass your proxy server (because it interferes with the updates) protocol=dyndns2 # default protocol server=www.ovh.com # default server #server=members.dyndns.org:8245 # default server (bypassing proxies) #proxy=fasthttp.sympatico.ca:80 # default proxy ## Default options for Dynamic/Static DNS Hosts #mx= # default MX host (leave undefined by default) #backupmx=NO # MX host is primary MX? (leave undefined by default) #wildcard=YES # add wildcard CNAME? ## Dynamic DNS hosts go here solaris.scottworld.net ## Static DNS hosts go here #static=yes, your-static-host.dyndns.org,another-static-host.dyndns.org ## Custom DNS hosts go here #custom=yes, your-domain.top-level,your-other-domain.top-level
We then mount a file on the web “ip.php” (this returns your external ip address) This is pointed to in the ddclient config file via the entry use=web, web=www.scottworld.net/ip.php, web-skip='IP Address'
The WEB file contains this php / HTML to return the external IP remote address.
<?php $ipaddress = "Current IP Address: ".$_SERVER['REMOTE_ADDR']; echo $ipaddress; ?>