Running any server on Raspberry will require a Dynamic DNS if you are having it on your home Internet connection or somewhere with dynamic IP address allocation from ISP.
sudo apt-get install ddclient
will get you the little app you need and you can edit
to get the required results. Consult your DNS hosting for information to go in this file. For NameCheap which I use the information is:
use=web, web=dynamicdns.park-your-domain.com/getip protocol=namecheap server=dynamicdns.park-your-domain.com login=yourdomain.com password=password subdomain
Do not change the top three lines. In ‘login=’ line, you need to enter your domain name, password should be obtained from NameCheap DNS hosting interface and is NOT your NameCheap account password. Finally the subdomain is whatever A or CName you are updating.
You can test with the following snippet that its working and checking your ‘syslog’ file in /var/logs
sudo /usr/sbin/ddclient -daemon 300 -syslog
Now you would want the ddclient to run as daemon on startup so run this one line to have it added to your startup scripts.
sudo update-rc.d ddclient defaults