Reputation: 1292
I have an issue with the web interface. I'm using powerdns v3.4.5 with mysql as the back-end. I have followed instructions from here: https://www.unixmen.com/how-to-install-powerdns-on-ubuntu-14-04/
I have successfully installed powerdns with mysql and got the web-api to work. However I have trouble inserting A records using the REST api. I have followed command from here: https://doc.powerdns.com/md/httpapi/README/
This creates a new zone:
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 .
(note that I changed the url and removed /api/v1/)
However when I run the following command to add a new A record:
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 .
I get the following error:
"error": "RRset test.example.org. IN A: Name is out of zone"
is there anything that I'm missing?
Upvotes: 4
Views: 21532
Reputation: 4612
As time passes by, the API changed. The current json structure is a little bit different, also power-dns insists of getting canonical names ending with a dot.
# 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.
Upvotes: 2
Reputation: 1292
It should be as follows:
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 .
and then:
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 .
Upvotes: 4