NB! The API server must be installed on a server where is running BIND9 as master or slave DNS.
NB2! Commands are executed as su to root or sudo all the time.
sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install -y dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf module reset php
sudo dnf module enable php:remi-8.3
sudo dnf install -y php php-bz2 php-cli php-common php-curl php-fpm php-gd php-gmp php-pecl-imagick php-intl php-mbstring php-opcache php-readline php-soap php-pecl-swoole php-xml git net-tools composer
sudo dnf install -y php-sqlite3 sqlitesudo visudoAdd the following line:
named ALL=NOPASSWD: /usr/sbin/rndc reload, /usr/sbin/rndc notifyFirst, clone the project repository into the /opt/bind9_api directory:
git clone https://github.com/getnamingo/bind9-api-server-sqlite /opt/bind9_api
cd /opt/bind9_apiNext, create the directory for logs. This directory will be used to store log files generated by the API server:
mkdir -p /var/log/plexdns
chown named:named /var/log/plexdns
chmod 750 /var/log/plexdnssqlite3 /opt/bind9_api/bind9_api.sqlite < /opt/bind9_api/database/bind9_api.sql
chown named:named /opt/bind9_api/bind9_api.sqlite
chmod 660 /opt/bind9_api/bind9_api.sqlitecd /opt/bind9_api
composer install
cp env-sample .env
nano .envEdit the .env with the appropriate preferences as required.
Open create_user.php, set the username and password the API will use, run the script, then delete it after confirming it works.
DB_TYPE=sqlite
DB_DATABASE=/opt/bind9_api/bind9_api.sqlite
...other content here...
BIND9_CONF_FILE=/opt/bind9_api/bind_zones.conf
BIND9_ZONE_DIR=/opt/bind9_api/zonesEdit /etc/named.conf, and add this line at the bottom:
include "/opt/bind9_api/bind_zones.conf";Then execute:
mkdir -p /opt/bind9_api/zones
touch /opt/bind9_api/bind_zones.conf
chown -R named:named /opt/bind9_api
chmod -R 750 /opt/bind9_api
restorecon -RFv /opt/bind9_api
semanage fcontext -a -t named_conf_t "/opt/bind9_api/bind_zones.conf"
semanage fcontext -a -t named_zone_t "/opt/bind9_api/zones(/.*)?"
restorecon -RFv /opt/bind9_apiCreate file /etc/systemd/system/bind9_api.service:
[Unit]
Description=BIND9 API Server
After=network.target
[Service]
Type=simple
User=bind
Group=bind
WorkingDirectory=/opt/bind9_api
ExecStart=/usr/bin/php /opt/bind9_api/start_bind9_api.php
Restart=always
RestartSec=3
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=bind9api
[Install]
WantedBy=multi-user.targetsystemctl daemon-reload
systemctl enable --now bind9_api.service
systemctl status bind9_api
systemctl restart bind9_apiAfter that you can manage BIND9 API via systemctl as any other service.