Setting up a dynamic
DNS
with OVH

My ISP, like most of the others in France, only assigns dynamic IP addresses to its customers: this means that the IP address is likely to change at any time, especially when my box is updated or rebooted. Most of the time, the possibility to have a fixed IP address is an option, reserved for expensive offers.

For most users, this does not present any practical problems. However, the situation becomes more complicated when you want to self-host sites or services that are intended to be accessible from the outside: how can you associate a domain name with a machine whose IP address can change at any time?

This is the principle of dynamic DNS: you install on your machine a small software that regularly checks the current IP address, and as soon as it changes, sends it to your provider to update the DNS zone accordingly.

This article shows how to do this with OVH and a Raspberry Pi running Raspbian.

Configuration on the OVH side

This part assumes that the domain name is managed by OVH, and that no record exists in the DNS zone for the domain name or subdomain that will point to our machine.

Creation of a DynHost identifier.

The first step is to create a DynHost ID, which will automatically update the DNS record.

To do this, go to Web Cloud, Domain name, select your domain name (we will use domain.tld for the rest of this article), then the DynHost tab. Then select Manage accesses and Create a login.

We indicate the login suffix (in my case, domain.tld-pi for a Raspberry Pi), the subdomain concerned (* to manage all domains with this login) and a password. This account will allow us to identify ourselves to update the zone.

Once the DNS zone is propagated, your server should now be accessible from the chosen domain name.

Setting up the dynamic recording

Once the identifier has been created, we can now create the DNS record. Still in the DynHost tab, we select Add a DynHost, then we indicate the domain name concerned, and the current IP address. It is this last one which will be updated automatically.

Automate the DNS change

Our server must now be able to update the DNS zone when it detects an IP change. We will use ddclient for this:

sudo apt install ddclient

Let’s skip the questions that are asked. Once finished, we directly modify the configuration file as follows (with, of course, your login, your password and your domain):

# /etc/ddclient.conf

protocol=dyndns2
use=web, web=checkip.dyndns.com, web-skip='Current IP Address'
server=www.ovh.com
login=domain.tld-user
password='password'
subdomain.domain.tld

Then, we restart the service:

sudo systemctl restart ddclient

Your server will now communicate to OVH the new IP address when it changes!