使用 PowerDNS REST api 插入 A 记录

Inserting A records using the PowerDNS REST api

我的网络界面有问题。我正在使用带有 mysql 作为后端的 powerdns v3.4.5。 我已按照此处的说明进行操作: 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 .

我收到以下错误:

"error": "RRset test.example.org. IN A: Name is out of zone"

有什么我遗漏的吗?

应该是这样的:

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 .

随着时间的推移,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.