Install PowerDNS and PowerAdmin on Centos 7: Reliable DNS Server
This guide provides a comprehensive walkthrough on how to Install PowerDNS and PowerAdmin on Centos 7. PowerDNS (pdns) stands out as a secure, scalable, and reliable software solution for DNS server management. Complementing this, PowerAdmin offers a user-friendly graphical interface, simplifying the management of your DNS servers.
This tutorial on the Orcacore website offers a detailed, step-by-step approach to installing and configuring PowerDNS and PowerAdmin on a Centos 7 system, utilizing Apache, MariaDB, and PHP. The goal is to provide a solid foundation for managing your DNS infrastructure efficiently.
Before diving into the installation process for PowerDNS Centos and PowerAdmin Centos, it’s essential to ensure your server meets the necessary prerequisites.
Requirements for PowerDNS Centos
-
Server Access: You’ll need access to your Centos 7 server with a non-root user account that has sudo privileges. Instructions for setting this up can be found in this guide: Initial Server Setup with Centos 7.
-
Firewall Configuration: A basic firewall should be configured on your server. A guide for setting up a firewall using Firewalld is available here: Set Up a Firewall with FirewallD on CentOS 7.
-
SELinux Disabled: It’s recommended to disable SELinux on your Centos 7 server for easier configuration. Instructions on how to do this are available here: How To Disable SELinux on Centos.
With these prerequisites in place, you can proceed with the following steps to complete your PowerDNS Centos and PowerAdmin Centos setup.
Step 1 – Install Epel and PHP Remi for PowerDNS
Begin by updating your system with the following command:
sudo yum update -y
Next, add the Epel and Remi repositories to your server using these commands:
# sudo yum install epel-release -y
# sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
Install the yum-utils
package, which provides helpful utilities for managing yum repositories:
sudo yum install yum-utils -y
Enable the Remi PHP 7.2 repository (or a later version if available) using the yum-config-manager
command:
sudo yum-config-manager --enable remi-php72
Step 2 – Install and Configure MariaDB for PowerDNS
Now, install MariaDB, which will serve as your database server. Use the following command:
sudo yum install mariadb mariadb-server -y
Once the installation is complete, start the MariaDB service and enable it to start automatically on boot:
# sudo systemctl start mariadb
# sudo systemctl enable mariadb
Run the mysql_secure_installation
script to enhance the security of your MariaDB installation, including setting a password for the root user:
sudo mysql_secure_installation
Follow the prompts, answering the questions appropriately and setting a strong password for the MySQL root user.
Note: The default version of MariaDB on Centos 7 might be an older version (MariaDB 5). If desired, you can upgrade your MariaDB version by following this guide: How To Upgrade MariaDB on Centos 7.
Step 3 – Configure MariaDB for PowerDNS: Create a PowerDNS Database and Database User
Log in to your MariaDB shell as the root user to create a database for PowerDNS and a dedicated user account to manage it:
sudo mysql -u root -p
Inside the MariaDB shell, create a database for PowerDNS (e.g., powerdb
):
**MariaDB [(none)]>** CREATE DATABASE powerdb;
Create a user account specifically for PowerDNS, setting a strong password:
**MariaDB [(none)]>** CREATE USER 'poweruser' identified by 'strongpassword';
Grant all necessary privileges to the PowerDNS user for the powerdb
database:
**MariaDB [(none)]>** GRANT ALL PRIVILEGES ON powerdb.* to 'poweruser'@'localhost' identified by 'strongpassword';
Apply the privilege changes:
**MariaDB [(none)]>** FLUSH PRIVILEGES;
Create table structures for PowerDNS Database
Select the powerdb
database:
**MariaDB [(none)]>** USE powerdb;
Execute the following MySQL commands to create the required table structures:
**MariaDB [(none)]>** CREATE TABLE domains (
id INT AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
PRIMARY KEY (id)
) Engine=InnoDB;
CREATE UNIQUE INDEX name_index ON domains(name);
CREATE TABLE records (
id BIGINT AUTO_INCREMENT,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(10) DEFAULT NULL,
content VARCHAR(64000) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
disabled TINYINT(1) DEFAULT 0,
ordername VARCHAR(255) BINARY DEFAULT NULL,
auth TINYINT(1) DEFAULT 1,
PRIMARY KEY (id)
) Engine=InnoDB;
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE INDEX recordorder ON records (domain_id, ordername);
CREATE TABLE supermasters (
ip VARCHAR(64) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) NOT NULL,
PRIMARY KEY (ip, nameserver)
) Engine=InnoDB;
CREATE TABLE comments (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
type VARCHAR(10) NOT NULL,
modified_at INT NOT NULL,
account VARCHAR(40) NOT NULL,
comment VARCHAR(64000) NOT NULL,
PRIMARY KEY (id)
) Engine=InnoDB;
CREATE INDEX comments_domain_id_idx ON comments (domain_id);
CREATE INDEX comments_name_type_idx ON comments (name, type);
CREATE INDEX comments_order_idx ON comments (domain_id, modified_at);
CREATE TABLE domainmetadata (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
kind VARCHAR(32),
content TEXT,
PRIMARY KEY (id)
) Engine=InnoDB;
CREATE INDEX domainmetadata_idx ON domainmetadata (domain_id, kind);
CREATE TABLE cryptokeys (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
flags INT NOT NULL,
active BOOL,
content TEXT,
PRIMARY KEY(id)
) Engine=InnoDB;
CREATE INDEX domainidindex ON cryptokeys(domain_id);
CREATE TABLE tsigkeys (
id INT AUTO_INCREMENT,
name VARCHAR(255),
algorithm VARCHAR(50),
secret VARCHAR(255),
PRIMARY KEY (id)
) Engine=InnoDB;
CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);
Verify the table creation:
**MariaDB [(none)]>** SHOW TABLES;
**Output**
+-------------------+
| Tables_in_powerdb |
+-------------------+
| comments |
| cryptokeys |
| domainmetadata |
| domains |
| records |
| supermasters |
| tsigkeys |
+-------------------+
7 rows in set (0.001 sec)
Exit the MariaDB shell:
**MariaDB [(none)]>** quit;
Step 3 – How To Install PowerDNS on Centos 7?
Install PowerDNS and the required packages:
sudo yum install pdns pdns-backend-mysql bind-utils -y
Navigate to the PowerDNS configuration directory:
cd /etc/pdns/
Edit the PowerDNS configuration file (pdns.conf
) using your preferred text editor (e.g., vi
):
sudo vi pdns.conf
Comment out the default bind
backend and configure the MySQL backend with your database credentials:
#launch=bind
launch=gmysql
gmysql-host=localhost
gmysql-user=poweruser
gmysql-password=strongpassword
gmysql-dbname=powerdb
Note: Ensure you replace the placeholder values with your actual database credentials.
Save and close the file.
Step 4 – How To Start PowerDNS Service on Centos 7?
Start and enable the PowerDNS service:
# sudo systemctl start pdns
# sudo systemctl enable pdns
Check the status of the PowerDNS service to confirm it’s running:
sudo systemctl status pdns
**Output**
● pdns.service - PowerDNS Authoritative Server
Loaded: loaded (/usr/lib/systemd/system/pdns.service; enabled; vendor preset: disabled)
Active: **active** (**running**) since Tue 2023-05-30 06:34:41 EDT; 11s ago
Docs: man:pdns_server(1)
man:pdns_control(1)
https://doc.powerdns.com
Main PID: 8982 (pdns_server)
CGroup: /system.slice/pdns.service
└─8982 /usr/sbin/pdns_server --guardian=no --daemon=no --disable-s...
...
Step 5 – Configure Firewall for PowerDNS
Allow DNS traffic through the firewall:
sudo firewall-cmd --add-service=dns --permanent
Reload the firewall to apply the changes:
sudo firewall-cmd --reload
With PowerDNS installed and configured, you can now proceed to install PowerAdmin for a graphical management interface.
For more information, refer to the PowerDNS Documentation.
Step 5 – How To Install PowerAdmin on Centos 7?
Install Apache, PHP, and necessary PHP extensions:
sudo yum install httpd php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mhash gettext -y
Install the PHP pear DB package:
sudo pear install db
**Output**
downloading DB-1.11.0.tgz ...
Starting to download DB-1.11.0.tgz (132,549 bytes)
.............................done: 132,549 bytes
install ok: channel://pear.php.net/DB-1.11.0
Start and enable the Apache web server:
# sudo systemctl start httpd
# sudo systemctl enable httpd
Verify that the Apache service is running:
sudo systemctl status httpd
**Output**
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: **active** (**running**) since Tue 2023-05-30 06:40:52 EDT; 14s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 9634 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
...
Download PowerAdmin Source Code
Download the PowerAdmin source code:
cd /var/www/html/
sudo wget https://sourceforge.net/projects/poweradmin/files/poweradmin-2.2.1.tar.gz
Extract the downloaded archive:
sudo tar xvf poweradmin-2.2.1.tar.gz
Move the extracted directory to /var/www/html/poweradmin/
:
sudo mv poweradmin-2.2.1 /var/www/html/poweradmin/
Allow HTTP and HTTPS traffic through the firewall:
# sudo firewall-cmd --add-service={http,https} --permanent
# sudo firewall-cmd --reload
Step 6 – How To Access PowerAdmin Dashboard on Centos 7?
Access the PowerAdmin installation through your web browser by navigating to http://your-server-ip/poweradmin/install
.
Follow the on-screen instructions to complete the PowerAdmin installation. This involves:
-
Language Selection: Choose your preferred language and proceed.
-
License Agreement: Read and accept the license agreement.
-
Database Configuration: Enter your PowerDNS database credentials (username, password, database name) and set a password for the PowerAdmin administrator account.
-
User Setup: Create a new user account for PowerAdmin, specify your hostmaster email address, and configure your nameservers.
-
Database Population: Execute the provided SQL commands in your MariaDB shell to populate the PowerAdmin database.
sudo mysql -u root -p
Then, add the commands that you have seen from your installation step 5. When you are done, click Go to step 6.
- Configuration File Editing: Edit the
inc/config.inc.php
file to include the configuration settings generated during the installation process.
cd /var/www/html/poweradmin
vi inc/config.inc.php
Add the lines that you have got from the installer into the file. When you are done, save and close the file. And Click Go to step 7.
Finish PowerAdmin Configuration
Copy the .htaccess
file (if needed) and remove the install/
directory:
cd /var/www/html/poweradmin
cp install/htaccess.dist .htaccess
rm -rf /var/www/html/poweradmin/install
Access the PowerAdmin login page by clicking on Poweradmin. Log in with the administrator credentials you created during the installation:
admin
PowerAdmin Centos Login
You should now be able to access the PowerAdmin dashboard and manage your DNS zones through the web interface.
PowerAdmin Centos Dashboard
Conclusion
This guide provided a detailed walkthrough of how to Install PowerDNS and PowerAdmin on Centos 7, enabling you to create a reliable and manageable DNS server. You’ve learned how to set up PowerAdmin to manage your DNS servers using a graphical interface.
Alternative Solutions for DNS Management
While PowerDNS with PowerAdmin provides a robust solution, there are alternative approaches to DNS management on Centos 7. Here are two different methods:
1. BIND (Berkeley Internet Name Domain) with Webmin:
BIND is the most widely used DNS server software. While it lacks a built-in web interface like PowerAdmin, you can use Webmin, a web-based system administration tool, to manage BIND.
- Explanation: BIND is highly configurable and offers extensive features. Webmin simplifies the management of BIND by providing a graphical interface for creating and modifying DNS zones, records, and other settings.
-
Installation:
-
Install BIND:
sudo yum install bind bind-utils -y
-
Install Webmin (follow the instructions on the Webmin website, as the repository might need to be added):
#Example sudo wget http://prdownloads.sourceforge.net/webadmin/webmin-1999-1.noarch.rpm sudo yum install webmin-1999-1.noarch.rpm
-
Access Webmin through your browser (e.g.,
https://your-server-ip:10000
) and install the BIND module.
-
2. Cloud-Based DNS Services (e.g., Cloudflare, AWS Route 53):
Instead of self-hosting a DNS server, you can leverage cloud-based DNS services.
- Explanation: Cloud-based DNS services offer high availability, scalability, and performance. They typically provide a web-based interface for managing your DNS zones and records. These services often come with added benefits like DDoS protection and improved DNS resolution speeds due to their globally distributed infrastructure.
- Implementation:
- Create an account with your chosen cloud DNS provider.
- Follow the provider’s instructions to add your domain and configure your DNS records.
- Update your domain’s registrar settings to point to the provider’s nameservers.
- Example (Cloudflare):
- Sign up for a Cloudflare account.
- Add your website to Cloudflare.
- Cloudflare will scan your existing DNS records.
- Review and confirm the DNS records.
- Cloudflare will provide you with new nameservers.
- Update your domain registrar with the Cloudflare nameservers.
These alternatives offer different trade-offs in terms of control, complexity, and cost. Cloud-based solutions offer simplicity and scalability but rely on a third-party provider. BIND with Webmin provides more control but requires more technical expertise to configure and maintain. The decision of which method to choose depends on your specific needs and resources.