Connecting a Domain to a Network with a Changing IP using Dynamic DNS (Linux)

A static IP address is usually required so that a computer, a home network, or a small company network can always be reached through the Internet under the same host name. This is also necessary if you want to connect to your home network using a VPN, for example. However, if your home network or small business network is connected to the Internet through certain types of connections like DSL, a new (dynamic) IP address is regularly assigned to the network. As a result, the computer, home network, or small business network cannot be permanently reached using the IP address.

In this case, you can use Dynamic Domain Name System (DNS) to automatically update the constantly changing IP addresses in the domain's DNS record so that your home network is permanently accessible under your domain.

To use the Dynamic DNS, you can use the multi-platform client from 1&1 IONOS. This multi-platform client was written in Python.

The following describes the steps required to use the multi-platform client:

Installing Python on a Computer Running Ubuntu

The following step-by-step instructions will show you how to install Python on a computer running the Ubuntu operating system.

Check for the Installation
  • Check whether Python is already installed. To do this, enter the following command:
    python --version

  • To check if pip is installed correctly, enter the following command:
    pip --version

Install Python
  • To install Python 3.x, enter the following commands.
    sudo apt update
    sudo apt upgrade
    sudo apt install software-properties-common
    sudo apt-get install python3

  • To install pip, enter the following command:
    apt install python-pip

Installing Python on a Computer Running CentOS 7

The following step-by-step instructions will show you how to install Python on a computer running CentOS 7.

Python 3 is not installed in CentOS 7 by default. Furthermore, Python is not offered in the official repository. For this reason, the first step requires the installation of the Inline Upstream Stable (IUS) package.

Check for the Installation
  • Check whether Python is already installed. To do this, enter the following command:
    python --version

  • To check if pip is installed correctly, enter the following command:
    pip --version

Install Python
  • To update the yum package manager, type the following command:yum -y update
    yum upgrade

  • To install the IUS package, type the following command:sudo yum -y install https://centos7.iuscommunity.org/ius-release.rpm

  • To install the latest version of Python, enter the following command: yum -y install python36u

  • To check if Python was successfully installed, enter the following command:
    python 3.x -V Example: python3.6 -V

  • To install pip, type the following command:
    yum -y install python-pip

  • Update six. Enter the following command:
    pip install --upgrade six

Installing the Multi-Platform Client

  • To install the multi-platform client, enter the following command:
    pip install domain-connect-dyndns

  • To add the domain whose DNS settings are to be updated automatically, type the following command:
    domain-connect-dyndns setup --domain NAME_OF_THE_DOMAIN Example:
    domain-connect-dyndns setup --domain example.com

  • Copy the URL and paste it into your browser.

  • Log in to 1&1 IONOS.

  • Click Allow.

  • Make a copy of the code displayed.

  • Open the command prompt and enter the code.

  • To update all domains, type the following command: domain-connect-dyndns update --all
    For example, after entering the command, the following message appears:
    [root@localhost ~]# domain-connect-dyndns update --all
    Read example.com config.
    IP 217.160.25.20 found in A record
    New IP: 217.160.25.20
    A record up to date.

  • For the IP address to be updated regularly in the DNS record, a cronjob must be configured. To edit the crontab file, type the following command: crontab -e

Please Note
  • Cron jobs are executed by the Cron-Deamon. The Cron-Deamon is a service with which you can execute time-based scripts and programs. The commands to be executed are stored in a table, which is called Crontab.

  • Information on editing and building the crontab file and syntax can be found in the article Cron.

  • Insert the cron job below:
    */1 * * * * /usr/bin/killall -9 domain-connect-dyndns; /usr/local/bin/domain-connect-dyndns update --all --config /root/dyndns/settings.txt