Skip to content

Instantly share code, notes, and snippets.

@sasajib
Last active January 12, 2023 12:24
Show Gist options
  • Save sasajib/3bdf78761c973bc880c1e43afd0f4ffd to your computer and use it in GitHub Desktop.
Save sasajib/3bdf78761c973bc880c1e43afd0f4ffd to your computer and use it in GitHub Desktop.

Installing PowerDNS with SQLite3 and Enabling the Backend Service

PowerDNS is a widely used DNS server software that can be configured to use different backends, including SQLite3. In this article, we will show you how to install PowerDNS with SQLite3 on Ubuntu 22.04 and enable the backend service.

# note: become root or use sudo

Step 1: Configure DNS

'systemd-resolved' conflict with port 53, The first step is to configure the DNS settings in the file.

# nano /etc/systemd/resolved.conf
DNS=1.1.1.1

This will set the DNS server to 1.1.1.1, which is a popular public DNS server.

Next, create a symbolic link

ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

This will ensure that the DNS settings are used by the system.

Step 2: Disable systemd-resolved

The next step is to disable the systemd-resolved service. This service is used by default in Ubuntu to handle DNS resolution and conflicts with PowerDNS. To disable the service, run the following command

systemctl disable --now systemd-resolved

Step 3: Install PowerDNS and SQLite3

Now that the DNS settings are configured and the systemd-resolved service is disabled, we can install PowerDNS and SQLite3. To do this, run the following command:

apt-get install sqlite3 pdns-server pdns-backend-sqlite3

This command will install both PowerDNS and the SQLite3 backend for PowerDNS.

Step 4: Configure SQLite3 for PowerDNS

The next step is to configure PowerDNS to use SQLite3 as the backend. To do this, we will create a new file in the directory /etc/powerdns/pdns.d/ called sqlite.conf. In this file, we will add the following lines:

# nano /etc/powerdns/pdns.d/sqlite.conf
launch=gsqlite3
gsqlite3-database=/var/lib/powerdns/pdns.sqlite3

This tells PowerDNS to use the SQLite3 backend and the location of the SQLite3 database.

Step 5: Create the SQLite3 Database

We will now create the SQLite3 database and configure the correct permissions on it with the following command:

sqlite3 /var/lib/powerdns/pdns.sqlite3 < /usr/share/doc/pdns-backend-sqlite3/schema.sqlite3.sql
sudo chown -R pdns:pdns /var/lib/powerdns

Step 6: Configure PowerDNS

Next, we will configure PowerDNS to allow API access. To do this, open the file /etc/powerdns/pdns.conf with a text editor and add the following lines:

# nano /etc/powerdns/pdns.conf
api=yes
api-key=some_api_key_123

Replace "some_api_key_123" with the desired password you want to use.

Step 7: Restart PowerDNS

Finally, restart the PowerDNS service to apply

systemctl restart pdns

now you have configured the powerdns, and api server is running on port 8081

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment