How to Install PowerDNS on CentOS 9
Welcome to the Greenhost.cloud blog! In today’s post, we’ll be walking you through a step-by-step guide on how to install PowerDNS on CentOS 9. PowerDNS is a powerful and flexible DNS server that is widely used due to its performance and ease of use. Whether you’re managing your own domains or providing DNS services for clients, PowerDNS offers great features such as support for multiple backends, a user-friendly web interface, and scalability.
Prerequisites
Before we begin the installation process, make sure you have the following:
- A CentOS 9 machine (either virtual or physical).
- Root or sudo access to your server.
- Firewall configured to allow DNS traffic (UDP and TCP port 53).
Step 1: Update Your System
Always start by updating your system to the latest available packages. Run:
sudo dnf update -y
Step 2: Install EPEL Repository
To install PowerDNS, you will need the Extra Packages for Enterprise Linux (EPEL) repository. Install it using:
sudo dnf install epel-release -y
Step 3: Install PowerDNS
Now that the EPEL repository is set up, you can install PowerDNS. You’ll likely want to choose between using PowerDNS Authoritative Server
or PowerDNS Recursor
. This guide will focus on installing the authoritative server.
Install PowerDNS with the following command:
sudo dnf install pdns pdns-backend-mysql -y
In this example, we are also installing the MySQL backend, which is commonly used for managing DNS records.
Step 4: Configure MySQL Database (Optional)
If you opted for the MySQL backend, you’ll need to create a database and user for PowerDNS. Log into the MySQL shell:
mysql -u root -p
Create a new database and user:
CREATE DATABASE powerdns;
CREATE USER 'powerdns'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON powerdns.* TO 'powerdns'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 5: Import the Schema
PowerDNS provides a schema file to set up your database. Download it directly from the PowerDNS GitHub repository and import it into your newly created database:
# Download the schema
curl -O https://raw.githubusercontent.com/PowerDNS/pdns/master/modules/gmysql/schema.mysql.sql
# Import the schema
mysql -u powerdns -p powerdns < schema.mysql.sql
Step 6: Configure PowerDNS
Now that the database is in place, it’s time to configure PowerDNS to use it. Open the PowerDNS configuration file:
sudo nano /etc/pdns/pdns.conf
Add or uncomment the following lines to set the database connection details:
launch=gmysql
gmysql-host=localhost
gmysql-user=powerdns
gmysql-password=your_strong_password
gmysql-dbname=powerdns
You may also want to set the local-address
and local-port
to bind PowerDNS to your network interfaces:
local-address=0.0.0.0
local-port=53
Step 7: Start and Enable PowerDNS Service
After configuring PowerDNS, start the service and enable it to run at boot:
sudo systemctl start pdns
sudo systemctl enable pdns
Step 8: Configure Firewall
If your firewall is enabled, you’ll need to allow DNS traffic:
sudo firewall-cmd --add-service=dns --permanent
sudo firewall-cmd --reload
Step 9: Test Your Installation
You can test whether PowerDNS is running by using the dig
command from another machine (replace your_server_ip
with your server’s actual IP address):
dig @your_server_ip example.com
If everything is installed and configured correctly, you should see a standard DNS response.
Conclusion
Congratulations! You’ve successfully installed PowerDNS on CentOS 9. You can now continue to set up your DNS zones and records through either the MySQL interface or a web GUI like PowerDNS-Admin for easier management.
For more tutorials on server management, cloud solutions, and more, stay tuned to the Greenhost.cloud blog. If you have any questions or run into issues, feel free to reach out to our support team. Happy hosting!