4

我的 Web 界面有问题。我使用 powerdns v3.4.5 和 mysql 作为后端。我已按照此处的说明进行操作: https ://www.unixmen.com/how-to-install-powerdns-on-ubuntu-14-04/

我已经用 mysql 成功安装了 powerdns 并让 web-api 工作。但是我无法使用 REST api 插入 A 记录。我从这里遵循了命令: https ://doc.powerdns.com/md/httpapi/README/

这将创建一个新区域:

curl -X POST --data '{"name":"example.org.", "kind": "Native", "masters": [], "nameservers": ["ns1.example.org.", "ns2.example.org."]}' -v -H 'X-API-Key: changeme' http://127.0.0.1:8081/servers/localhost/zones | jq .

(请注意,我更改了 url 并删除了 /api/v1/)

但是,当我运行以下命令来添加新的 A 记录时:

curl -X PATCH --data '{"rrsets": [ {"name": "test.example.org.", "type": "A", "ttl": 86400, "changetype": "REPLACE", "records": [ {"content": "192.0.5.4", "disabled": false } ] } ] }' -H 'X-API-Key: changeme' http://127.0.0.1:8081/servers/localhost/zones/example.org. | jq .

我收到以下错误:

“错误”:“RRset test.example.org。IN A:名称超出区域”

有什么我想念的吗?

4

2 回答 2

3

它应该如下:

curl -X POST --data '{"name":"example.org", "kind": "Master","dnssec":false,"soa-edit":"INCEPTION-INCREMENT","masters": [], "nameservers": ["ns1.example.org"]}' -v -H 'X-API-Key: changeme' http://127.0.0.1:8081/servers/localhost/zones | jq .

接着:

curl -X PATCH --data '{"rrsets": [ {"name": "test.example.org", "type": "A", "changetype": "REPLACE", "records": [ {"content": "192.168.9.9", "disabled": false, "name": "test.example.org", "ttl": 86400, "type": "A", "priority": 0 } ] } ] }' -H 'X-API-Key: changeme' http://127.0.0.1:8081/servers/localhost/zones/example.org | jq .
于 2017-02-16T04:27:57.427 回答
2

随着时间的推移,API 发生了变化。当前的 json 结构有点不同,power-dns 也坚持获取以点结尾的规范名称。

# cat example_zone.json
{
    "kind": "Native",
    "masters": [],
    "name": "example.com.",
    "nameservers": [
        "ns1.example.com.",
        "ns2.example.com."
    ]
}

# curl -s -H 'X-API-Key: changeme' --data @example_zone.json  http://127.0.0.1:8081/api/v1/servers/localhost/zones

# cat example_rrset.json
{
    "rrsets":
    [
    {
        "name": "test.example.com.",
        "type": "A",
        "changetype": "REPLACE",
        "ttl": 86400,

        "records":
        [
        {
            "content": "192.168.9.9",
            "disabled": false,
            "name": "test.example.com.",
            "type": "A",
            "priority": 0
        }
        ]
    }
    ]
}

# curl -v -X PATCH -H 'X-API-Key: changeme' --data @example_rrset.json http://127.0.0.1:8081/api/v1/servers/localhost/zones/example.com.
于 2021-12-04T17:55:38.483 回答