当前位置: 首页 > 工具软件 > PowerDNS > 使用案例 >

PowerDNS在ubuntu 20.04 server部署

席俊
2023-12-01

1. 开始安装配置MariaDB

sudo apt install mariadb-server

我们需要给ROOT用户设置一个初始密码。

方法1:
      mysql -u root

      use mysql;

      update user set password=password("root")where user='root';

      flush privileges;

      exit;

方法2:用mysqladmin 

      格式:mysqladmin -u用户名 -p旧密码 password 新密码 

      例子:

         mysqladmin -uroot -p1234567 password admini

测试:
service start mysql
mysql -u root -p
  • 获取mysql表结构文件和外键修改文件
wget -c https://raw.githubusercontent.com/PowerDNS/pdns/rel/auth-4.1.x/modules/gmysqlbackend/schema.mysql.sql
wget -c https://raw.githubusercontent.com/PowerDNS/pdns/rel/auth-4.1.x/modules/gmysqlbackend/enable-foreign-keys.mysql.sql
  • 登录MariaDB执行,创建用户,数据库和表
    ~$ sudo mysql -u root -p
    
    MariaDB [(none)]> CREATE USER 'pdns'@'localhost' IDENTIFIED BY 'pdns';
    MariaDB [(none)]> CREATE DATABASE powerdns;
    MariaDB [(none)]> GRANT ALL ON powerdns.* TO 'pdns'@'localhost';
    MariaDB [(none)]> FLUSH PRIVILEGES;
    MariaDB [(none)]> exit;
    
    ~$ sudo mysql -u pdns -p
    
    MariaDB [(none)]> use powerdns;
    MariaDB [powerdns]> source ~/schema.mysql.sql
    MariaDB [powerdns]> source ~/enable-foreign-keys.mysql.sql
    MariaDB [powerdns]> exit

    2. 安装配置PowerDNS

  • ~$ sudo apt install pdns-server pdns-backend-mysql pdns-backend-lua pdns-tools 
    ~$ sudo vim /etc/powerdns/pdns.d/gmysql.conf
    
    launch+=gmysql
    gmysql-host=127.0.0.1
    gmysql-port=3306
    gmysql-dbname=powerdns
    gmysql-user=pdns
    gmysql-password=pdns
    gmysql-dnssec=no
    gmysql-innodb-read-committed=yes
    gmysql-timeout=10
    
    
    
    ~$ sudo vim /etc/powerdns/pdns.conf
    
    local-address=本机IP
    
    
    # 开机启动pdns服务
    ~$ sudo systemctl enable pdns
    ~$ sudo systemctl start pdns

    3. 启用API服务

  • 要启用 API,需要启用网络服务器和 HTTP API。将这些行添加到recursor.conf
webserver=yes
api-key=changeme
  • 并重新启动pdns_recursor,以下示例应该开始工作:

     
    sudo systemctl restart pdns
    
    
    curl -v -H 'X-API-Key: changeme' http://127.0.0.1:8081/api/v1/servers/localhost | jq .
    curl -v -H 'X-API-Key: changeme' http://127.0.0.1:8081/api/v1/servers/localhost/zones | jq .
    

 类似资料: