Skip to content

Optional: Dynamic DNS

If you operate your Pi-hole + OpenVPN at home, you are likely sitting behind a NAT / dynamically changing IP address. In this case, you should set up a dynamic DNS record, which allows you to reach your server. You can exchange the address that has been configured during the setup of OpenVPN like this:

vim /etc/openvpn/server/client-common.txt

Look for the remote line and adjust it accordingly (remove IP address, add hostname), e.g.

remote 1194

This change has to be repeated in each client config file (*.conf) that you have been created up till now.

If you have set up a DDNS domain for your IP address, you will likely need to add a host-record to Pi-hole's settings.

pihole -a hostrecord

If you don't do this, clients (like the Android OpenVPN client) will not able to connect to the VPN server when inside the internal network (while it will work from outside). Afterward, the client will be able to connect to the VPN server both from inside and outside your local network.

Setting up DynDNS update

If your router cannot update the dynamic DNS record, you can use for example ddclient.

sudo apt install ddclient

This configuration file resides in /etc/ddclient.conf. During installation, apt probably already asked you some questions and prepared a useful config file. In general, configuration files look like:

# /etc/ddclient.conf

If you want to have ddclient running as daemon (recommended!), change also your /etc/default/ddclient to:

# Configuration for ddclient scripts
# generated from debconf on Do 9. Feb 22:29:13 CET 2017
# /etc/default/ddclient





Example: Strato DynDNS

In the following, we give an example of how to set up ddclient using the German Internet hosting provider Strato. First, you need to create a subdomain. Then you need to enable DnyDNS for this domain:

Afterwards, modify your ddclient config file to look like:

use=if, if=eth0

where you replace strato-login-name by your Strato login name (most likely your domain name, like, password1234 by the password you configured above (see the third screenshot), and by the subdomain you created and enabled dynamic DNS for.

Last update: January 19, 2021