了解 DNS 解析管理、API 对接与自建系统
欢迎使用 自助授权解析v2!本系统支持 Cloudflare、西部数码、华为云、腾讯云、阿里云 等主流 DNS 服务商,提供快速稳定的多平台 DNS 解析管理。
以下是系统中已配置的域名及其支持的解析类型:
| 类型 | 名称 | 说明 | 示例值 |
|---|---|---|---|
| A | A (IPv4地址) | 将域名指向一个IPv4地址 |
192.168.1.1 |
| AAAA | AAAA (IPv6地址) | 将域名指向一个IPv6地址 |
2001:db8::1 |
| CAA | CAA (证书授权) | 指定允许的证书颁发机构 |
0 issue "letsencrypt.org" |
| CNAME | CNAME (别名) | 将域名指向另一个域名 |
example.com |
| MX | MX (邮件交换) | 指定邮件服务器地址 |
mail.example.com |
| NS | NS (域名服务器) | 指定DNS服务器 |
ns1.example.com |
| PTR | PTR (反向解析) | IP地址反向解析为域名 |
host.example.com |
| SPF | SPF (发件人策略) | 指定允许的发件服务器 |
v=spf1 mx -all |
| SRV | SRV (服务记录) | 指定服务的主机名和端口 |
0 5 5060 sip.example.com |
| TXT | TXT (文本) | 文本记录,常用于SPF、DKIM等验证 |
v=spf1 ~all |
本系统提供完整的 RESTful API,支持 DNS 记录管理、套餐查询、订单管理、SSL 证书等。所有 API 需携带登录 Session Cookie。
POST /endpoints/records.php
Content-Type: application/x-www-form-urlencoded
action=add_record
&domain_id=1
&name=www
&type=A
&content=192.168.1.1
POST /endpoints/records.php
action=update_record
&id=123
&name=api
&type=CNAME
&content=example.com
POST /endpoints/records.php
action=delete_record
&id=123
POST /endpoints/api.php
action=list_records
&page=1
&limit=20
&search=www
&type=A
POST /endpoints/api.php
# 域名列表
action=list_domains
# 套餐列表
action=list_packages
# 订单列表
action=list_orders
# 用户信息
action=get_profile
# 管理统计
action=admin_get_stats
// 成功
{ "success": true, "data": [...] }
// 带分页
{ "success": true, "data": [...], "pagination": { "page":1, "limit":20, "total":50, "total_pages":3 } }
// 错误
{ "error": "错误描述" }
您可以基于本系统的 API 构建自己的 DNS 管理面板:
<?php
class DnsClient {
private $baseUrl;
private $cookieFile;
public function __construct($baseUrl) {
$this->baseUrl = rtrim($baseUrl, '/');
$this->cookieFile = tempnam(sys_get_temp_dir(), 'dns_');
}
public function login($username, $password) {
return $this->request('/endpoints/auth.php', [
'action' => 'login', 'username' => $username, 'password' => $password
])['success'] ?? false;
}
public function addRecord($domainId, $name, $type, $content) {
return $this->request('/endpoints/records.php', [
'action' => 'add_record', 'domain_id' => $domainId,
'name' => $name, 'type' => $type, 'content' => $content
]);
}
public function listRecords($page = 1) {
return $this->request('/endpoints/api.php', [
'action' => 'list_records', 'page' => $page
]);
}
public function deleteRecord($recordId) {
return $this->request('/endpoints/records.php', [
'action' => 'delete_record', 'id' => $recordId
]);
}
private function request($endpoint, $data) {
$ch = curl_init($this->baseUrl . $endpoint);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($data),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_COOKIEFILE => $this->cookieFile,
CURLOPT_COOKIEJAR => $this->cookieFile,
]);
$res = curl_exec($ch); curl_close($ch);
return json_decode($res, true);
}
}
$client = new DnsClient('https://your-domain.com');
$client->login('username', 'password');
$client->addRecord(1, 'www', 'A', '192.168.1.100');
import requests
class DnsClient:
def __init__(self, base_url):
self.base_url = base_url.rstrip('/')
self.session = requests.Session()
def login(self, username, password):
r = self.session.post(f'{self.base_url}/endpoints/auth.php',
data={'action':'login','username':username,'password':password})
return r.json().get('success', False)
def add_record(self, domain_id, name, rtype, content):
r = self.session.post(f'{self.base_url}/endpoints/records.php',
data={'action':'add_record','domain_id':domain_id,
'name':name,'type':rtype,'content':content})
return r.json()
def list_records(self, page=1):
r = self.session.post(f'{self.base_url}/endpoints/api.php',
data={'action':'list_records','page':page})
return r.json()
client = DnsClient('https://your-domain.com')
client.login('username', 'password')
client.add_record(1, 'www', 'A', '192.168.1.100')