PowerDNS is an open-source DNS server that provides excellent performance and reliability. This tutorial will guide you through the process of how to install and configure a PowerDNS server on openSUSE, including the necessary steps to secure your server and ensure optimal performance. We will be using openSUSE Leap 15.3 for this tutorial, but the instructions should apply to other versions as well.
Before we begin, ensure that you have:
- An openSUSE system installed and updated.
- A user account with sudo privileges.
How to Install PowerDNS Server on openSUSE
Install PowerDNS Server and Backend
First, we need to install the PowerDNS server and its required backend. In this tutorial, we will be using the MySQL backend, but you can choose another backend such as PostgreSQL or SQLite if you prefer. To install the PowerDNS server and the MySQL backend, run the following command:
sudo zypper install pdns pdns-backend-mysql
If you haven’t already installed MySQL, follow our guide on how to install MySQL on openSUSE.
Configure MySQL for PowerDNS
Now that we have installed the necessary packages, we need to create a MySQL database and user for PowerDNS. Log in to MySQL using the following command:
mysql -u root -p
Enter your MySQL root password when prompted. Next, run the following commands to create a new database and user for PowerDNS:
CREATE DATABASE powerdns; GRANT ALL PRIVILEGES ON powerdns.* TO 'powerdns'@'localhost' IDENTIFIED BY 'your_password'; FLUSH PRIVILEGES; EXIT;
your_password with a secure password of your choice.
Import PowerDNS Database Schema
To set up the PowerDNS database schema, first, download the schema file:
Then, import the schema into the PowerDNS database:
mysql -u powerdns -p powerdns < schema.mysql.sql
Enter the password you set for the
powerdns user when prompted.
Now, it’s time to configure the PowerDNS server. Open the PowerDNS configuration file with your preferred text editor, such as Vim:
sudo vim /etc/pdns/pdns.conf
Add or modify the following lines to configure the MySQL backend:
launch=gmysql gmysql-host=localhost gmysql-dbname=powerdns gmysql-user=powerdns gmysql-password=your_password
your_password with the password you set for the
powerdns user. Save the changes and exit the editor.
Start and Enable PowerDNS Service
Enable and start the PowerDNS service using the following commands:
sudo systemctl enable pdns sudo systemctl start pdns
To allow DNS queries to reach your PowerDNS server, you need to open the necessary ports on your firewall. If you haven’t already set up a firewall, follow our guide on how to install CSF on openSUSE. Then, open the ports by running the following commands:
sudo firewall-cmd --permanent --zone=public --add-service=dns sudo firewall-cmd --reload
Test PowerDNS Server
To verify that your PowerDNS server is functioning correctly, you can use the
dig command. First, install the
bind-utils package if you haven’t already:
sudo zypper install bind-utils
Next, run the following command to query your PowerDNS server:
dig @localhost example.com
You should see a response from your PowerDNS server, even though the query may return a “NXDOMAIN” status since we haven’t added any domain records yet.
Add Domain Records
Now that your PowerDNS server is up and running, you can add domain records to your server. You can use a web-based interface like PowerDNS-Admin or insert records directly into the MySQL database.
To add records directly into the database, log in to MySQL as the
mysql -u powerdns -p
Enter the password you set for the
powerdns user when prompted. Then, run the following SQL commands to insert a new domain and some basic records:
USE powerdns; INSERT INTO domains (name, type) VALUES ('example.com', 'NATIVE'); SET @domain_id = LAST_INSERT_ID(); INSERT INTO records (domain_id, name, type, content, ttl) VALUES (@domain_id, 'example.com', 'SOA', 'ns1.example.com [email protected] 2023040301 10800 3600 604800 3600', 86400); INSERT INTO records (domain_id, name, type, content, ttl) VALUES (@domain_id, 'example.com', 'NS', 'ns1.example.com', 86400); INSERT INTO records (domain_id, name, type, content, ttl) VALUES (@domain_id, 'ns1.example.com', 'A', '192.0.2.1', 86400);
example.com with your domain name and
192.0.2.1 with the IP address of your DNS server.
Congratulations! You have successfully installed and configured a PowerDNS server on openSUSE. You can now manage your DNS records using your preferred method and enjoy the benefits of running your own DNS server.
For further reading on openSUSE and related topics, you can check out the following articles: