NavigationContentFooter
Jump toSuggest an edit

Reviewed on 15 October 2024Published on 10 September 2020
  • dns
  • ubuntu
  • PowerDNS
  • server
  • MariaDB

The PowerDNS authoritative server is an open-source DNS server written in C++. An authoritative DNS server contains a database of public IP addresses and their associated domain names, serving the purpose of resolving those common names into machine-understandable IP addresses.

PowerDNS runs on most Linux distributions, including Ubuntu. This tutorial demonstrates how to install PowerDNS authoritative server with a MariaDB backend and PowerDNS Admin frontend, running on Ubuntu 22.04 LTS (Jammy Jellyfish).

Before you start

To complete the actions presented below, you must have:

  • A Scaleway account logged into the console
  • Owner status or IAM permissions allowing you to perform actions in the intended Organization
  • An SSH key
  • At least 2 Instances running on Ubuntu Jammy Jellyfish (22.04 LTS)

Installing PowerDNS

Note

This section covers the basic installation of PowerDNS. Execute these steps on both your primary and secondary Instances.

  1. Log into your Instance using SSH:

    ssh root@<your_virtual_instance_ip>
  2. Update the apt package cache and upgrade the software to the latest version available:

    apt update && apt upgrade -y
  3. Install MariaDB using the apt package manager:

    apt install mariadb-server -y
  4. Initialize the database server by running the interactive setup wizard:

    mysql_secure_installation

    You will be prompted with the following questions:

    • Enter current password for root: Press Enter if none is set.
    • Set root password? Y
    • Type in the new MariaDB root password and confirm it.
    • Remove anonymous users? Y
    • Disallow root login remotely? Y
    • Remove test database and access to it? Y
    • Reload privilege tables now? Y
  5. Install PowerDNS and the MySQL backend:

    apt install pdns-server pdns-backend-mysql -y

    Confirm that you want to use dbconfig-common to automatically configure the database.

    During the installation, you’ll be asked to enter a password for the MySQL backend user. Press Enter to generate a random password automatically.

Configuring the primary Instance

On the primary Instance, three main options need to be configured in the pdns.conf configuration file: allow-axfr-ips, api, and master.

  1. Open the PowerDNS configuration file:

    nano /etc/powerdns/pdns.conf
  2. Configure zone transfers to other hosts by editing the allow-axfr-ips block. In this example, we set up one primary (ns1.example.com with IP 192.0.2.1) and one secondary (ns2.example.com with IP 192.0.2.2) DNS server:

    allow-axfr-ips=192.0.2.2
  3. Enable the API and set an api-key:

    api=yes
    api-key=<MY_SECRET_API_KEY>
  4. Specify that this Instance is the primary server:

    master=yes
  5. Save the file and restart the PowerDNS server to apply the configuration:

    systemctl restart pdns.service

Configuring the secondary Instance

For the secondary Instance, configure PowerDNS to act as a secondary server.

Note

If you have more than one secondary Instance, repeat these steps and change the DNS hostnames accordingly (e.g., ns3.example.com).

  1. Open the PowerDNS configuration file on the secondary Instance:

    nano /etc/powerdns/pdns.conf
  2. Enable the slave mode and configure it to regularly refresh its data with the slave-cycle-interval option:

    slave=yes
    slave-cycle-interval=60
  3. Add the primary Instance as a supermaster to the MariaDB backend. Connect to MariaDB and insert the necessary values:

    mysql -p -u root
    insert into pdns.supermasters values ('192.0.2.1', 'ns2.example.com', 'admin');
    quit;
  4. Restart the PowerDNS service on the secondary Instance:

    systemctl restart pdns.service

Testing replication

  1. On the primary Instance, create a test DNS zone:

    pdnsutil create-zone example.com
  2. Add the primary NS entry:

    pdnsutil add-record example.com @ NS ns1.example.com
  3. Add the secondary NS entry:

    pdnsutil add-record example.com @ NS ns2.example.com
  4. Increase the zone’s serial number to prepare for the zone transfer:

    pdnsutil increase-serial example.com
  5. Send a NOTIFY message to the secondary Instance:

    pdns_control notify example.com
  6. Verify the replication by querying the secondary Instance:

    dig NS example.com @ns2.example.com

Setting up a graphical interface (PowerDNS Admin)

  1. Install Docker prerequisites:

    apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
  2. Download and install Docker’s official GPG key:

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
  3. Add Docker’s official repository:

    add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  4. Update the package list and install Docker:

    apt update && apt install docker-ce docker-ce-cli containerd.io -y
  5. Run PowerDNS Admin using Docker:

    docker run --net=host -d -v pda-data:/data ngoduykhanh/powerdns-admin:latest
  6. Open your Instance IP in a web browser: http://<your_powerdns_admin_ip>. Create a user account and log in.

  7. On your first login, enter the API credentials for your PowerDNS Instance.

  8. After logging in, you can manage your DNS zones through the PowerDNS Admin web interface.

Conclusion

You have successfully installed a replicated PowerDNS server with a MariaDB backend on Ubuntu 22.04 LTS. Additionally, you have set up PowerDNS Admin, a web-based interface to manage your DNS zones.

For more advanced configuration options, refer to the PowerDNS documentation and the PowerDNS Admin project for further customization.

API DocsScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCareers
© 2023-2024 – Scaleway