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
        }
    ]
}