DNS 記錄

獲取 DNS 記錄列表

URI

GET /admin-api/dns/{id}/record

URI 引數

  • detail

    type: integer

    required: no

    description: 獲取詳細的 DNS 應用資訊

  • page

    type: integer

    required: no

    description: 第幾頁,從 1 開始

  • page_size

    type: integer

    required: no

    description: 每頁大小,預設 20

請求示例

Shell

curl http://{admin-site}/admin-api/dns/{id}/record?page=1&page_size=20&detail=1

響應示例

Status: 200 OK
{
    "status": 0,
    "data": {
        "meta": {
            "count": 2  // 結果數量
        },
        "data": [
            {
                "ttl": 5,
                "type": "A",
                "_modified_unix": 1614829316.766,
                "priority": 1,
                "id": 15,
                "_created_unix": 1614829316.766,
                "is_master": true,
                "unit": "min",
                "disabled": false,
                "sub_domain": "abc",
                "line": 0,
                "gateway": 1
            },
            {
                "ttl": 5,
                "type": "A",
                "_modified_unix": 1614829311.0838,
                "priority": 1,
                "id": 14,
                "_created_unix": 1614829311.0838,
                "is_master": true,
                "unit": "min",
                "disabled": false,
                "sub_domain": "www",
                "line": 0,
                "gateway": 1
            }
        ]
    }
}

新增 DNS 記錄

URI

POST /admin-api/dns/{id}/record

JSON Body 引數

  • sub_domain

    type: string

    required: yes

    description: 子域名

  • type

    type: string

    required: yes

    description: 子域名型別,可選值:A/AAAA/CNAME/MX/TXT/NS/CAA/SRV

  • disabled

    type: boolean

    required: no

    description: 是否禁用

  • ttl

    type: integer

    required: no

    description: DNS 結果的有效時間

  • unit

    type: string

    required: no

    description: DNS 結果的有效時間

  • priority

    type: integer

    required: no

    description: 優先順序

  • weight

    type: integer

    required: no

    description: 權重

  • port

    type: integer

    required: no

    description: 埠

  • is_master

    type: boolean

    required: yes

    description: 是否是主記錄

  • cidr

    type: string

    required: no

    description: 匹配此 CIDR 的 IP 地址,將解析此記錄。(和 line 二選一)

  • line

    type: integer

    required: no

    description: 匹配此網路型別的 IP 地址,將解析此記錄(和 cidr 二選一)

  • ip

    type: string

    required: no

    description: DNS 響應內容, 可以用於 A/AAAA 等記錄.

  • domain

    type: string

    required: no

    description: DNS 響應內容, 可以用於 CNAME 記錄.

  • gateway

    type: integer

    required: no

    description: DNS 響應內容, 可以用於 A/AAAA 記錄.

  • enable_checker

    type: boolean

    required: no

    description: 是否啟用健康檢查

  • checker_port

    type: integer

    required: yes

    description: 健康檢查的埠(enable_checker = true 時,必選)

  • checker_timeout

    type: integer

    required: yes

    description: 健康檢查超時時間(enable_checker = true 時,必選)

  • checker_fail_times

    type: integer

    required: yes

    description: 健康檢查失敗次數,達到此次數後,將被標記為不健康(enable_checker = true 時,必選)

請求示例

Shell

curl -X POST http://{admin-site}/admin-api/dns/{id}/record -d '
{
    "line": 0,
    "disabled": false,
    "type": "A",
    "sub_domain": "abc",
    "ttl": 5,
    "unit": "min",
    "priority": 1,
    "is_master": true,
    "enable_checker": true,
    "checker_port": 80,
    "checker_timeout": 3,
    "checker_fail_times": 3,
    "gateway": 1,
    "ip": null
}'

響應示例

Status: 200 OK
{
    "status": 0,
    "data": {
        "id": 1
    }
}

修改 DNS 記錄

URI

PUT /admin-api/dns/{id}/record

JSON Body 引數

  • sub_domain

    type: string

    required: yes

    description: 子域名

  • type

    type: string

    required: yes

    description: 子域名型別,可選值:A/AAAA/CNAME/MX/TXT/NS/CAA/SRV

  • disabled

    type: boolean

    required: no

    description: 是否禁用

  • ttl

    type: integer

    required: no

    description: DNS 結果的有效時間

  • unit

    type: string

    required: no

    description: DNS 結果的有效時間

  • priority

    type: integer

    required: no

    description: 優先順序

  • weight

    type: integer

    required: no

    description: 權重

  • port

    type: integer

    required: no

    description: 埠

  • is_master

    type: boolean

    required: yes

    description: 是否是主記錄

  • cidr

    type: string

    required: no

    description: 匹配此 CIDR 的 IP 地址,將解析此記錄。(和 line 二選一)

  • line

    type: integer

    required: no

    description: 匹配此網路型別的 IP 地址,將解析此記錄(和 cidr 二選一)

  • ip

    type: string

    required: no

    description: DNS 響應內容, 可以用於 A/AAAA 等記錄.

  • domain

    type: string

    required: no

    description: DNS 響應內容, 可以用於 CNAME 記錄.

  • gateway

    type: integer

    required: no

    description: DNS 響應內容, 可以用於 A/AAAA 記錄.

  • enable_checker

    type: boolean

    required: no

    description: 是否啟用健康檢查

  • checker_port

    type: integer

    required: yes

    description: 健康檢查的埠(enable_checker = true 時,必選)

  • checker_timeout

    type: integer

    required: yes

    description: 健康檢查超時時間(enable_checker = true 時,必選)

  • checker_fail_times

    type: integer

    required: yes

    description: 健康檢查失敗次數,達到此次數後,將被標記為不健康(enable_checker = true 時,必選)

  • backup

    type: object

    required: no

    description: 舊配置

請求示例

Shell

curl -X PUT http://{admin-site}/admin-api/dns/{id}/record/{id} -d '
{
    "line": 1,
    "ttl": 5,
    "type": "A",
    "_modified_unix": 1614828677.1785,
    "id": 13,
    "_created_unix": 1614828677.1785,
    "is_master": true,
    "disabled": false,
    "sub_domain": "www",
    "unit": "sec",
    "backup": {
        "ttl": 5,
        "type": "A",
        "_modified_unix": 1614828677.1785,
        "id": 13,
        "_created_unix": 1614828677.1785,
        "is_master": true,
        "disabled": false,
        "ip": "11.11.11.11",
        "sub_domain": "www",
        "line": 1,
        "unit": "min",
        "isSwitchingMaster": false,
        "isSwitchingDisabled": false,
        "isSelected": false,
        "errors": false,
        "saved": false,
        "value": null,
        "domain": null,
        "text": null,
        "cidr": null,
        "gateway": null,
        "isEdited": false,
        "errorTitle": null,
        "errorContent": null
    },
    "ip": "11.11.11.11",
    "gateway": null
}'

響應示例

Status: 200 OK
{
    "status": 0
}

刪除 DNS 記錄

URI

DELETE /admin-api/dns/{id}/record/{id}

請求示例

Shell

curl -X DELETE http://{admin-site}/admin-api/dns/{id}/record/{id}

響應示例

Status: 200 OK
{
    "status": 0
}

計算推薦配置

URI

GET /admin-api/dns-util/recommend

URI 引數

  • sub_domain

    type: string

    required: yes

    description: 子域名

  • app_id

    type: integer

    required: yes

    description: DNS 應用 ID

請求示例

Shell

curl http://{admin-site}/admin-api/dns-util/recommend?sub_domain=www&app_id=4

響應示例

Status: 200 OK
{
    "time": 1614829925,
    "status": 0,
    "data": [
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 0,
            "gateway": 1
        },
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 1,
            "gateway": 1
        },
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 2,
            "gateway": 1
        },
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 3,
            "gateway": 1
        },
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 4,
            "gateway": 1
        },
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 5,
            "gateway": 1
        },
        {
            "ttl": 1,
            "type": "A",
            "unit": "min",
            "sub_domain": "www",
            "line": 6,
            "gateway": 1
        }
    ]
}