项目作者: SpaceRouter

项目描述 :
PYTHON REST API for isc-bind-server
高级语言: Python
项目地址: git://github.com/SpaceRouter/isc-bind-api.git
创建时间: 2021-05-31T17:56:22Z
项目社区:https://github.com/SpaceRouter/isc-bind-api

开源协议:GNU General Public License v3.0

下载


isc-bind-api

PYTHON REST API for isc-bind-server (soon using jwt authentication)

Run:

  1. python isc-bind-api.py

Record Types :

RECORD_TYPES = [‘A’, ‘AAAA’, ‘CNAME’, ‘MX’, ‘NS’, ‘TXT’, ‘SOA’]

API List :

ADD DNS record:

Create a DNS record

  1. const response = await fetch("http://localhost:8090/add", {
  2. method: "POST",
  3. headers: { "content-type": "application/json" },
  4. body: JSON.stringify({
  5. Answer: 192.168.1.70,
  6. Hostname: "devtest" + ".opengate.lan",
  7. RecordType: A,
  8. TTL: 300,
  9. }),
  10. });
  11. curl -H "Content-Type: application/json" -d '{"Hostname":"devtest.opengate.lan","TTL":"300","RecordType":"A","Answer":"192.168.1.70"}' -X POST http://localhost:8090/add

UPDATE DNS record:

Update a DNS record

  1. const response = await fetch("http://localhost:8090/update", {
  2. method: "PUT",
  3. headers: { "content-type": "application/json" },
  4. body: JSON.stringify({
  5. Answer: 192.168.1.71,
  6. Hostname: "devtest" + ".opengate.lan",
  7. RecordType: A,
  8. TTL: 300,
  9. }),
  10. });
  11. curl -H "Content-Type: application/json" -d '{"Hostname":"devtest.opengate.lan","TTL":"300","RecordType":"A","Answer":"192.168.1.71"}' -X PUT http://localhost:8090/update

DELETE DNS record:

Delete a DNS record

  1. const response = await fetch("http://localhost:8090/delete", {
  2. method: "DELETE",
  3. headers: { "content-type": "application/json" },
  4. body: JSON.stringify({
  5. Hostname: "devtest" + ".opengate.lan",
  6. RecordType: A,
  7. }),
  8. });
  9. curl -H "Content-Type: application/json" -d '{"Hostname":"devtest.opengate.lan","RecordType":"A"}' -X DELETE http://localhost:8090/delete

SHOW Entire Zone:

Retrieve data regarding the specified zone.

  1. const response = await fetch("http://localhost:8090/zone");
  2. curl http://localhost:8090/zone

Return example:

  1. {
  2. "safe.lan.": [
  3. {
  4. "Answer": "ns",
  5. "Hostname": "@",
  6. "RecordType": 2,
  7. "TTL": 604800
  8. },
  9. {
  10. "Answer": "192.168.1.1",
  11. "Hostname": "ns",
  12. "RecordType": 1,
  13. "TTL": 604800
  14. },
  15. {
  16. "Answer": "192.168.1.50",
  17. "Hostname": "test",
  18. "RecordType": 1,
  19. "TTL": 604800
  20. },
  21. {
  22. "Answer": "192.168.1.51",
  23. "Hostname": "test1",
  24. "RecordType": 1,
  25. "TTL": 604800
  26. }]
  27. }