FreeBSD に PowerDNS をインストールする

PowerDNSPostgreSQL バックエンドでインストールして、PowerDNS Admin を動かしたいということで、 順を追って手順を記録していきます。

もくじ

  • PostgreSQL をインストールする
  • PowerDNS をインストールする ← 今回
  • PowerDNS Admin をインストールする

インストールと設定

パッケージから PowerDNS をインストールします。

# pkg install powerdns

PostgreSQL の設定

PostgreSQL を操作するための postgres というユーザーは既にできているはずなので、PostgreSQL に pdns というユーザーと pdns というデータベースを作成します。

# psql postgres
postgres=# CREATE ROLE pdns WITH LOGIN PASSWORD 'password';
CREATE ROLE
postgres=# CREATE DATABASE pdns OWNER pdns ENCODING 'UTF8';
CREATE DATABASE

同じことを shell のコマンドラインからは次のように行なえます。

# sudo -u postgres createuser -P -s -e pdns
# sudo -u postgres createdb -O pdns -E UTF8 pdns "Database for PowerDNS"

次に、データベースにスキーマを適用します。スキーマの定義は /usr/local/share/doc/powerdns/schema.pgsql.sql にあるはずです。

# psql -U pdns -d pdns -a -f /usr/local/share/doc/powerdns/schema.pgsql.sql

pdns.conf の設定

/usr/local/etc/pdns/pdns.conf を以下のように変更します。PowerDNSAdmin が API を使うので、API も有効にします。

launch=gpgsql
gpgsql-host=/tmp/.s.PGSQL.5432  # listen している UNIX ソケットを確認のこと
gpgsql-dbname=pdns
gpgsql-user=pdns
gpgsql-password=password

api=yes
api-key=なんかランダムな文字列

PowerDNS 実行

/etc/rc.conf に

pdns_enable="YES"

を入れて、

# service pdns start

を実行します。