PowerDNS OpenDBX Backend/Installation

From Linuxnetworks
Jump to: navigation, search

Compilation

Before performing the steps to compile the PowerDNS server and the OpenDBX backend you have to install the OpenDBX library, the OpenDBX backend you would like to use and its development package, which includes the necessary header.

Apply these steps to the source pdns-x.xx.tar.gz file, if you don't want to use a precompiled package:

* Extract the pdns tar file
* Change into the newly created pdns directory
* Extract the opendbxbackend tar file
* Run "cat <patch> | patch -p1" (if available)
* Type ./configure --help for the available options
* For dynamic modules:
  ./configure
     --prefix=/usr
     --with-modules=""
     --with-dynmodules="opendbx"
     --enable-recursor
* For a static module:
  ./configure
     --prefix=/usr
     --with-modules="opendbx"
     --with-dynmodules=""
     --enable-recursor
* make && make install

Configuration options

There are a few options through the OpenDBX backend can be configured for your environment. Add them to the pdns.conf file located in /etc/powerdns or /usr/local/etc/ (depends on your configuration while compiling):

opendbx-backend (default "mysql") 
Name of the backend used to connect to the database server. Currently mysql, pgsql, sqlite, sqlite3 and sybase are available.
opendbx-host-read (default "127.0.0.1") 
One or more host names or IP addresses of the database servers. These hosts will be used for retrieving the records via SELECT queries.
opendbx-host-write (default "127.0.0.1") 
Same as opendbx-host-read, except for INSERT/UPDATE statements (mostly used by zonetransfers).
opendbx-port (default "") 
TCP/IP port number where the database server is listening to. Most databases will use their default port if you leave this empty.
opendbx-database (default "powerdns") 
The database name where all domain and record entries are stored.
opendbx-username (default "powerdns") 
Name of the user send to the DBMS for authentication.
opendbx-password (default "") 
Clear text password for authentication in combination with the username.
opendbx-host (deprecated, default "127.0.0.1") 
Host name or IP address of the database server. This parameter is deprecated in favor of opendbx-host-read and opendbx-host-write.

Example configuration

Configuring PowerDNS is straight forward. You only have to launch the opendbx backend and configure the database connection correctly. The lines below are an example for configuring PowerDNS to connect to a MySQL server:

launch=opendbx
opendbx-backend=mysql
opendbx-host-read=192.168.1.1
opendbx-host-write=192.168.1.1
opendbx-port=3306
opendbx-database=powerdns
opendbx-username=powerdns
opendbx-password=secret

Backend specific configuration

MySQL

Supported without changes since OpenDBX 1.0.0

PostgreSQL

Supported without changes since OpenDBX 1.0.0

SQLite and SQLite3

Supported without changes since OpenDBX 1.0.0 but requires to set opendbx-host to the path of the SQLite file (including the trailing slash or backslash, depending on your operating system) and opendbx-database to the name of the file, e.g.

opendbx-host-read = /path/to/file/
opendbx-host-write = /path/to/file/
opendbx-database = powerdns.sqlite

MS SQL Server

Supported by PowerDNS 2.9.20 (with latest patch) and OpenDBX 1.1.4 by using the FreeTDS library. It uses a different scheme for host configuration (requires the name of the host section in the configuration file of the dblib client library) and doesn't support the default statement for starting transactions. Please add the following lines to your pdns.conf:

opendbx-host-read = MSSQL2k
opendbx-host-write = MSSQL2k
opendbx-sql-transactbegin = BEGIN TRANSACTION

Sybase ASE

Supported by PowerDNS 2.9.20 (with latest patch) and OpenDBX 1.1.5 by using the native Sybase ctlib or the FreeTDS library. It uses a different scheme for host configuration (requires the name of the host section in the configuration file of the ctlib client library) and doesn't support the default statement for starting transactions. Please add the following lines to your pdns.conf:

opendbx-host-read = SYBASE
opendbx-host-write = SYBASE
opendbx-sql-transactbegin = BEGIN TRANSACTION

Oracle

Supported by PowerDNS 2.9.20 (with latest patch) and OpenDBX 1.1.6. It uses a different syntax for transactions and requires the following additional line in your pdns.conf:

opendbx-sql-transactbegin = SET TRANSACTION NAME 'AXFR'

Database setup

You need one of the DBMS supported by the OpenDBX library for storing your records and domain infomation. Please have a look at the documentation of your DBMS for the task of creating a database and an user.

After that you're almost done. Use the appropriate table definition below to create the tables in the new database after which you can populate your database with dns information with e.g. zone2sql.

Migration

To convert an existing gMySQL Database to an OpenDBX MySQL database, an additional status column is required since patch 2.9.20-3:

ALTER TABLE domains ADD ( status CHAR(1) NOT NULL DEFAULT 'A' )

Adding a foreign key constraint from records.domain_id to domains.id is a good idea too:

ALTER TABLE records ADD CONSTRAINT fk_records_domainid
FOREIGN KEY (domain_id) REFERENCES domains (id)
ON UPDATE CASCADE ON DELETE CASCADE

You should also recreate your indices for optimal performance. Please have a look in the appropriate file listed in the section above.



Back to Overview