|
|
| (One intermediate revision by the same user not shown) |
| Line 1: |
Line 1: |
| − | __TOC__
| |
| − |
| |
| | == Compilation == | | == Compilation == |
| | | | |
| Line 25: |
Line 23: |
| | --with-dynmodules="" | | --with-dynmodules="" |
| | * make && make install | | * make && make install |
| − |
| |
| − | == Configuration ==
| |
| − |
| |
| − | === Basic 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
| |
| − |
| |
| − | === Advanced options ===
| |
| − |
| |
| − | The opendbx backend gives you the power to modify all the SQL statements used in its code. This enables you to enhance them for specific needs or adapt them to your environment. The list of statements consists of:
| |
| − |
| |
| − | ; opendbx-sql-list : Select records which will be returned to clients asking for zone transfers (AXFR). Default is:
| |
| − |
| |
| − | SELECT
| |
| − | "domain_id", "name", "type",
| |
| − | "ttl", "prio", "content"
| |
| − | FROM "records"
| |
| − | WHERE "domain_id"=:id
| |
| − |
| |
| − | ; opendbx-sql-lookup : Retrieve DNS records by name. Default is:
| |
| − |
| |
| − | SELECT
| |
| − | "domain_id", "name", "type",
| |
| − | "ttl", "prio", "content"
| |
| − | FROM "records"
| |
| − | WHERE "name"=':name'
| |
| − |
| |
| − | ; opendbx-sql-lookupid : Retrieve DNS records by id and name. Default is:
| |
| − |
| |
| − | SELECT
| |
| − | "domain_id", "name", "type",
| |
| − | "ttl", "prio", "content"
| |
| − | FROM "records"
| |
| − | WHERE "domain_id"=:id AND "name"=':name'
| |
| − |
| |
| − | ; opendbx-sql-lookuptype : Retrieve DNS records by name and type. Default is:
| |
| − |
| |
| − | SELECT
| |
| − | "domain_id", "name", "type",
| |
| − | "ttl", "prio", "content"
| |
| − | FROM "records"
| |
| − | WHERE "name"=':name' AND "type"=':type'
| |
| − |
| |
| − | ; opendbx-sql-lookuptypeid : Retrieve DNS records by id, name and type. Default is:
| |
| − |
| |
| − | SELECT
| |
| − | "domain_id", "name", "type",
| |
| − | "ttl", "prio", "content"
| |
| − | FROM "records"
| |
| − | WHERE "domain_id"=:id AND "name"=':name' AND "type"=':type'
| |
| − |
| |
| − | ; opendbx-sql-zonedelete : Delete all records from zone before inserting new ones via AXFR. Default is:
| |
| − |
| |
| − | DELETE FROM "records" WHERE "domain_id"=:id
| |
| − |
| |
| − | ; opendbx-sql-zoneinfo : Get stored information about a domain. Default is:
| |
| − |
| |
| − | SELECT
| |
| − | d."id", d."name", d."type",
| |
| − | d."master", d."last_check", r."content"
| |
| − | FROM "domains" d
| |
| − | LEFT JOIN "records" r ON ( d."id"=r."domain_id" AND r."type"='SOA' )
| |
| − | WHERE d."name"=':name' AND d."status"='A'
| |
| − |
| |
| − | ; opendbx-sql-transactbegin : Start transaction before updating a zone via AXFR. Default is:
| |
| − |
| |
| − | BEGIN
| |
| − |
| |
| − | ; opendbx-sql-transactend : Commit transaction after updating a zone via AXFR. Default is:
| |
| − |
| |
| − | COMMIT
| |
| − |
| |
| − | ; opendbx-sql-transactabort : Undo changes if an error occurred while updating a zone via AXFR. Default is:
| |
| − |
| |
| − | ROLLBACK
| |
| − |
| |
| − | ; opendbx-sql-insert-slave : Adds a new zone from the authoritative DNS server which is currently retrieved via AXFR. Default is:
| |
| − |
| |
| − | INSERT INTO "domains"
| |
| − | ( "name", "type", "master", "account" )
| |
| − | VALUES ( '%s', 'SLAVE', '%s', '%s' )
| |
| − |
| |
| − | ; opendbx-sql-insert-record : Adds new records of a zone form the authoritative DNS server which are currently retrieved via AXFR. Default is:
| |
| − |
| |
| − | INSERT INTO "records"
| |
| − | ( "domain_id", "name", "type", "ttl", "prio", "content" )
| |
| − | VALUES ( %d, '%s', '%s', %d, %d, '%s' )
| |
| − |
| |
| − | ; opendbx-sql-update-serial : Set zone serial to value of last update. Default is:
| |
| − |
| |
| − | UPDATE "domains"
| |
| − | SET "notified_serial"=%d
| |
| − | WHERE "id"=%d
| |
| − |
| |
| − | ; opendbx-sql-update-lastcheck : Set time of last zone check. Default is:
| |
| − |
| |
| − | UPDATE "domains"
| |
| − | SET "last_check"=%d
| |
| − | WHERE "id"=%d
| |
| − |
| |
| − | ; opendbx-sql-master : Get master record for zone. Default is:
| |
| − |
| |
| − | SELECT "master"
| |
| − | FROM "domains"
| |
| − | WHERE "name"=':name' AND "status"='A' AND "type"='SLAVE'
| |
| − |
| |
| − | ; opendbx-sql-supermaster : Get supermaster info. Default is:
| |
| − |
| |
| − | SELECT "account"
| |
| − | FROM "supermasters"
| |
| − | WHERE "ip"=':ip' AND "nameserver"=':ns'
| |
| − |
| |
| − | ; opendbx-sql-infoslaves : Get all unfresh slaves. Default is:
| |
| − |
| |
| − | SELECT
| |
| − | d."id", d."name", d."master", d."notified_serial",
| |
| − | d."last_check", r."change_date", r."content"
| |
| − | FROM "domains" d
| |
| − | LEFT JOIN "records" r ON ( d."id"=r."domain_id" AND r."type"='SOA' )
| |
| − | WHERE d."status"='A' AND d."type"='SLAVE'
| |
| − |
| |
| − | ; opendbx-sql-infomasters : Get all updates masters. Default is:
| |
| − |
| |
| − | SELECT
| |
| − | d."id", d."name", d."master", d."notified_serial",
| |
| − | d."last_check", r."change_date", r."content"
| |
| − | FROM "domains" d
| |
| − | JOIN "records" r ON d."id"=r."domain_id"
| |
| − | WHERE d."status"='A' AND d."type"='MASTER' AND r."type"='SOA'
| |
| − |
| |
| − | '''Note''': If you change one of the SELECT statements must not change the order of the retrieved columns!
| |
| − |
| |
| − | == 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.
| |
| − |
| |
| − | * [http://www.linuxnetworks.de/pdnsodbx/download/tables-mysql.sql MySQL]
| |
| − | * [http://www.linuxnetworks.de/pdnsodbx/download/tables-pgsql.sql PostgreSQL]
| |
| − | * [http://www.linuxnetworks.de/pdnsodbx/download/tables-sqlite.sql SQLite]
| |
| − | * [http://www.linuxnetworks.de/pdnsodbx/download/tables-sybase.sql MS SQL Server]
| |
| − | * [http://www.linuxnetworks.de/pdnsodbx/download/tables-sybase.sql Sybase]
| |
| − | * [http://www.linuxnetworks.de/pdnsodbx/download/tables-oracle.sql Oracle]
| |
| − |
| |
| − | == 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 [[PowerDNS OpenDBX Backend|Overview]]
| |
If you don't want to use a pre-compiled package from your favorite distribution, you have to build the PowerDNS binaries for your platform yourself.
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.