{"id":2961,"date":"2019-06-05T09:02:53","date_gmt":"2019-06-05T06:02:53","guid":{"rendered":"https:\/\/kifarunix.com\/?p=2961"},"modified":"2021-11-27T19:24:15","modified_gmt":"2021-11-27T16:24:15","slug":"install-powerdns-with-mariadb-backend-on-fedora-30-29-centos-7","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-powerdns-with-mariadb-backend-on-fedora-30-29-centos-7\/","title":{"rendered":"Install PowerDNS with MariaDB Backend on Fedora 30\/29\/CentOS 7"},"content":{"rendered":"\n
In this guide, we are going to learn how to install PowerDNS<\/a> with MariaDB backend on Fedora 30\/29\/CentOS 7. PowerDNS is a powerful opensource DNS server that provides alternative DNS services to BIND. It provides two nameserver products namely, the Authoritative Server and the Recursor. <\/p>\n\n\n\n While the Authoritative Server only answer questions about domains it knows about, Recursor on the other hand has no knowledge of domains itself by default it will always consult other authoritative servers to answer questions given to it.<\/p>\n\n\n\n The authoritative PowerDNS server supports different backends ranging from database backends such as MySQL, PostgreSQL, Oracle and BIND zone files<\/a> to co-processes<\/a> and JSON API\u2019s<\/a>.<\/p>\n\n\n\n In this guide, we will use MariaDB as the PowerDNS backend. Hence before you can proceed, you need to install and configure MariaDB.<\/p>\n\n\n\n See our guide on how to install MariaDB 10.3 by following the links below;<\/p>\n\n\n\n Install MariaDB 10.3 on Fedora 30<\/a><\/p>\n\n\n\n Install MariaDB 10.3 on CentOS 7<\/a><\/p>\n\n\n\n Once the installation is done, proceed to create MariaDB database and user for PowerDNS.<\/p>\n\n\n\n Next, use the PowerDNS database created above and run the following commands to create the table structures.<\/p>\n\n\n\n Next, you need to add foreign key constraints to the tables in order to automate deletion of records, key material, and other information upon deletion of a domain from the domains table. This ensures that no records, comments or keys exists for domains that you already removed.<\/p>\n\n\n\n Once the configuration of database is done, proceed to install PowerDNS.<\/p>\n\n\n\n On Fedora 30, PowerDNS is available on the default repos and thus can be simply installed by running the command below;<\/p>\n\n\n\n For CentOS 7, you need to install EPEL repos.<\/p>\n\n\n\n PowerDNS uses bind as the default backend. Therefore, open the PowerDNS configuration and comment out the line, launch=bind<\/strong>, replace it with the following lines. Replace you configs accordingly.<\/p>\n\n\n\n Before you can start PowerDNS, run in it in foreground as shown below to verify the connection to MariaDB backend.<\/p>\n\n\n\n If all is well, then;<\/p>\n\n\n\n If you encounter any error, please fix it before you can proceed.<\/p>\n\n\n\n To start and enable PowerDNS to run on system boot;<\/p>\n\n\n\n To check the status of PowerDNS,<\/p>\n\n\n\n If FirewallD is running, allow DNS through it.<\/p>\n\n\n\n You can verify that DNS port 53 is opened.<\/p>\n\n\n\n Well, you have successfully installed PowerDNS with MariaDB configured as the backend. In our next guide, we will learn how to administer PowerDNS using the web based tool called Poweradmin. Enjoy<\/p>\n\n\n\n Reference:<\/p>\n\n\n\n Getting Started with PowerDNS<\/a><\/p>\n\n\n\n Other related Guides’<\/p>\n\n\n\nInstall PowerDNS with MariaDB Backend on Fedora 30\/29\/CentOS 7<\/h2>\n\n\n\n
Install PowerDNS on Fedora 30\/29\/CentOS 7<\/h3>\n\n\n\n
Update and upgrade your system.<\/h4>\n\n\n\n
yum update\nyum upgrade<\/code><\/pre>\n\n\n\n
Install MariaDB<\/h4>\n\n\n\n
Configuring MariaDB Backend for PowerDNS<\/h3>\n\n\n\n
Create PowerDNS MariaDB User and Database<\/h4>\n\n\n\n
mysql -u root -p<\/code><\/pre>\n\n\n\n
create database powerdns;\ngrant all privileges on powerdns.* to dnsadmin@localhost identified by 'StrongP@SS';<\/code><\/pre>\n\n\n\n
use powerdns;<\/code><\/pre>\n\n\n\n
CREATE TABLE domains (\n id INT AUTO_INCREMENT,\n name VARCHAR(255) NOT NULL,\n master VARCHAR(128) DEFAULT NULL,\n last_check INT DEFAULT NULL,\n type VARCHAR(6) NOT NULL,\n notified_serial INT UNSIGNED DEFAULT NULL,\n account VARCHAR(40) CHARACTER SET 'utf8' DEFAULT NULL,\n PRIMARY KEY (id)\n) Engine=InnoDB;<\/code><\/pre>\n\n\n\n
CREATE UNIQUE INDEX name_index ON domains(name);<\/code><\/pre>\n\n\n\n
CREATE TABLE records (\n id BIGINT AUTO_INCREMENT,\n domain_id INT DEFAULT NULL,\n name VARCHAR(255) DEFAULT NULL,\n type VARCHAR(10) DEFAULT NULL,\n content VARCHAR(64000) DEFAULT NULL,\n ttl INT DEFAULT NULL,\n prio INT DEFAULT NULL,\n disabled TINYINT(1) DEFAULT 0,\n ordername VARCHAR(255) BINARY DEFAULT NULL,\n auth TINYINT(1) DEFAULT 1,\n PRIMARY KEY (id)\n) Engine=InnoDB;<\/code><\/pre>\n\n\n\n
CREATE INDEX nametype_index ON records(name,type);\nCREATE INDEX domain_id ON records(domain_id);\nCREATE INDEX ordername ON records (ordername);<\/code><\/pre>\n\n\n\n
CREATE TABLE supermasters (\n ip VARCHAR(64) NOT NULL,\n nameserver VARCHAR(255) NOT NULL,\n account VARCHAR(40) CHARACTER SET 'utf8' NOT NULL,\n PRIMARY KEY (ip, nameserver)\n) Engine=InnoDB;<\/code><\/pre>\n\n\n\n
CREATE TABLE comments (\n id INT AUTO_INCREMENT,\n domain_id INT NOT NULL,\n name VARCHAR(255) NOT NULL,\n type VARCHAR(10) NOT NULL,\n modified_at INT NOT NULL,\n account VARCHAR(40) CHARACTER SET 'utf8' DEFAULT NULL,\n comment TEXT CHARACTER SET 'utf8' NOT NULL,\n PRIMARY KEY (id)\n ) Engine=InnoDB;<\/code><\/pre>\n\n\n\n
CREATE INDEX comments_name_type_idx ON comments (name, type);\nCREATE INDEX comments_order_idx ON comments (domain_id, modified_at);<\/code><\/pre>\n\n\n\n
CREATE TABLE domainmetadata (\n id INT AUTO_INCREMENT,\n domain_id INT NOT NULL,\n kind VARCHAR(32),\n content TEXT,\n PRIMARY KEY (id)\n ) Engine=InnoDB;<\/code><\/pre>\n\n\n\n
CREATE INDEX domainmetadata_idx ON domainmetadata (domain_id, kind);<\/code><\/pre>\n\n\n\n
CREATE TABLE cryptokeys (\n id INT AUTO_INCREMENT,\n domain_id INT NOT NULL,\n flags INT NOT NULL,\n active BOOL,\n content TEXT,\n PRIMARY KEY(id)\n) Engine=InnoDB;<\/code><\/pre>\n\n\n\n
CREATE INDEX domainidindex ON cryptokeys(domain_id);<\/code><\/pre>\n\n\n\n
CREATE TABLE tsigkeys (\n id INT AUTO_INCREMENT,\n name VARCHAR(255),\n algorithm VARCHAR(50),\n secret VARCHAR(255),\n PRIMARY KEY (id)\n) Engine=InnoDB;<\/code><\/pre>\n\n\n\n
CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);<\/code><\/pre>\n\n\n\n
ALTER TABLE records ADD CONSTRAINT `records_domain_id_ibfk` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\nALTER TABLE comments ADD CONSTRAINT `comments_domain_id_ibfk` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\nALTER TABLE domainmetadata ADD CONSTRAINT `domainmetadata_domain_id_ibfk` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;\nALTER TABLE cryptokeys ADD CONSTRAINT `cryptokeys_domain_id_ibfk` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;<\/code><\/pre>\n\n\n\n
Install PowerDNS<\/h3>\n\n\n\n
dnf install pdns pdns-backend-mysql bind-utils<\/code><\/pre>\n\n\n\n
yum install epel-release\nyum install pdns pdns-backend-mysql bind-utils<\/code><\/pre>\n\n\n\n
Configure PowerDNS Backend<\/h3>\n\n\n\n
vim \/etc\/pdns\/pdns.conf<\/code><\/pre>\n\n\n\n
...\n#launch=bind\nlaunch=gmysql\ngmysql-host=127.0.0.1\ngmysql-user=dnsadmin\ngmysql-dbname=powerdns\ngmysql-password=StrongP@SS\n...<\/code><\/pre>\n\n\n\n
Verify PowerDNS connection to Backend<\/h4>\n\n\n\n
pdns_server --daemon=no --guardian=no --loglevel=9<\/code><\/pre>\n\n\n\n
...\nJun 05 01:24:36 Creating backend connection for TCP\nJun 05 01:24:36 gmysql Connection successful. Connected to database 'powerdns' on '127.0.0.1'.\nJun 05 01:24:36 About to create 3 backend threads for UDP\nJun 05 01:24:36 gmysql Connection successful. Connected to database 'powerdns' on '127.0.0.1'.\nJun 05 01:24:36 gmysql Connection successful. Connected to database 'powerdns' on '127.0.0.1'.\nJun 05 01:24:36 gmysql Connection successful. Connected to database 'powerdns' on '127.0.0.1'.\nJun 05 01:24:36 Done launching threads, ready to distribute questions<\/code><\/pre>\n\n\n\n
Running PowerDNS<\/h3>\n\n\n\n
systemctl start pdns\nsystemctl enable pdns<\/code><\/pre>\n\n\n\n
systemctl status pdns\n\u25cf pdns.service - PowerDNS Authoritative Server\n Loaded: loaded (\/usr\/lib\/systemd\/system\/pdns.service; enabled; vendor preset: disabled)\n Active: active (running) since Wed 2019-06-05 01:29:33 EAT; 3min 9s ago\n Docs: man:pdns_server(1)\n man:pdns_control(1)\n https://doc.powerdns.com\n Main PID: 4066 (pdns_server)\n Tasks: 8 (limit: 2351)\n Memory: 4.3M\n CGroup: \/system.slice\/pdns.service\n \u2514\u25004066 \/usr\/sbin\/pdns_server --guardian=no --daemon=no --disable-syslog --log-timestamp=no --write-pid=no<\/code><\/pre>\n\n\n\n
firewall-cmd --add-service=dns --permanent\nfirewall-cmd --reload<\/code><\/pre>\n\n\n\n
ss -altnp | grep 53\nLISTEN 0 128 0.0.0.0:53 0.0.0.0:* users:((\"pdns_server\",pid=4066,fd=8)) \nLISTEN 0 128 [::]:53 [::]:* users:((\"pdns_server\",pid=4066,fd=9))<\/code><\/pre>\n\n\n\n