Selfhosting is not accessible to everyone, although several projects such as YunoHost and Cozycloud that are drastically simplifying how to install, configure and manage your server with pre-configured applications (Mails, Jabber, blog, torrent, calendar, file sharing, etc…), it’s still require few additional configuration from your DNS. And it can be quite annoying to run your own server@home when you have a dynamic IP.
It’s actually my case…..well only since this monday…I’ve been able to upgrade my home connection to 100M/100M. Although I was at 100M/40M before with a static IP, now they “cannot” keep a static IP except if I’m willing to get their professional package (The double!). Technically there is no reason for them not to provide me a static IP…but commercially I can understand they want to protect their premium offer for pro…
So I had to figure it out…. and well it’s quite easy to run a server on a dynamic IP.
I bought my domain name with OVH, and they have a dedicated service call DynHost, accepting to update redirections using an external software. But many other providers have this option (DynDNS and co).
Basically, you need a script or so, that will check every xx minutes for the change of your public IP and immediately update your domain name settings.
I’ve used a simple application called DDclient.
DDclient, written in Perl, is a dedicated client used to update dynamic DNS entries. It was made for accounts on ‘Dynamic DNS Network Services’, the previously-free DNS service (DynDNS), but since their business model’s change, DDclient team have integrated several others services by implementing new protocols.
Easy to install and configure, DDclient suits me well.
1) Install ddclient from your distro’s repository
In root (or with sudo), type:
apt-get install ddclient
You will need to answer several questions. But no worry, you are able to directly update the conf file later (Even better!).
You will have questions such as:
– Selecting your Dynamic DNS Service Provider (For auto config). If not listed, simply select “other”, in that case, you will need to enter the Dynamic DNS Server (www.ovh.com in my case) and the protocol (dyndns2 in my case)
– Username (From your registrar Dynamic DNS service)
– DynDNS fully qualified domain name (the domain name you want to update, freedif.org in my case), make sure it’s in line with your registrar Dyn DNS service.
– Run ddclient on PPP connect, select NO in that case, as you want to have it run in daemon instead.
– Interval between ddclient runs (Like 5mn for example)
2) Double confirm the configuration
(Or start from mine)
In some cases (behind some router,…) it will takes your local network IP…of course, it won’t work in that case. So the best is to double check this.
Modify /etc/ddclient.conf (Still in root):
and if you have something like
# Configuration file for ddclient generated by debconf # # /etc/ddclient.conf protocol=dyndns2 use=if, if=eth0
while eth0 is only giving local network IP, it won’t work…Simply replace the line use=xxx by:
use=web, web=checkip.dyndns.com, web-skip='IP Address'
This will directly check your IP with checkip.dyndns.com’s website.
Here is my full ddclient.conf file for your reference:
# Configuration file for ddclient generated by debconf # # /etc/ddclient.conf protocol=dyndns2 use=web, web=checkip.dyndns.com, web-skip='IP Address' server=www.ovh.com login=myprivaterlogin password='myprivatepassword' ssl=yes freedif.org
Simply adapt it for your own registrar.
3) Restart the service and check if it works
To check the new configuration, no need to wait 5mn or whatever number you have set. Simply restart the service and read the log:
/etc/init.d/ddclient restart tail /var/log/syslog
You should get something like:
ddclient: SUCCESS: updating freedif.org: good: IP address set to 22.214.171.124
then you can double check this in your registrar admin panel (Immediate update).
You should now be good to host your own server on a dynamic IP!
If you want to know more about DDclient, I suggest you reading their official wiki.
If DDclient is not your taste, there are many others script/apps to update your domain name IP. One of the most famous one is certainly ipcheck.py, as shown in the official OVH support page on DynDNS.