How can 西部数码 domain names implement the DDNS function (dynamic resolution)?
Published: 2023-11-06
Function Overview:
Dynamic DNS (DDNS) allows users to use a fixed domain name to access a dynamic IP address, solving the issue where services become inaccessible due to IP address changes.
This article will introduce how to use 西部数码's API to implement DDNS, so that your domain name always points to your dynamic IP address.
API Introduction:
API endpoint https://api.west.cn/API/v2/domain/dns/ Related documentation>>
The API supports two authentication methods
1. Domain-level authentication (single domain only)
Supported parameters https://api.west.cn/API/v2/domain/dns/?act=dnsrec.update&domain=Specified domain&apidomainkey=Domain key&hostname=Full subdomain&record_value=Set IP
How to obtain the Domain KEY:
As shown in the figure below, go to Management Center - Domain Management - click the domain - upper right side [ApiKey] click to copy.

2. User-level authentication (supports managing multiple domains, only for agents)
Supported parameters https://api.west.cn/API/v2/domain/dns/?act=dnsrec.update&username=Username&apikey=User key&domain=Specified domain&hostname=Full subdomain&record_value=Set IP
User KEY retrieval address: https://www.west.cn/manager/API/APIconfig.asp

Note: The dnsrec.update interface deletes the existing A record and re-adds it when updating DNS records. For other API functions, see Domain API documentation
Usage examples:
1. Synology NAS - Built-in DDNS
Configuration example (not compatible with IPv6; if you need IPv6, it is recommended to use DDNS-GO's third-party package or Docker instance)
First, add a custom service provider
Service provider:
west
Query URL:
https://api.west.cn/API/v2/domain/dns/?act=dnsrec.update&domain=__USERNAME__&hostname=__HOSTNAME__&record_value=__MYIP__&apidomainkey=__PASSWORD__

Add DDNS, select the west service provider, for password/key fill in the domain's [ApiKey], and add the corresponding information as shown in the screenshot.

2.openwrt - ddns-script component
Configuration example
| Parameter name (English/Chinese) | Parameter value | Configuration description |
| Service provider/Service provider | --custom-- | |
| update_url/Custom update URL | https://api.west.cn/API/v2/domain/dns/?act=dnsrec.update&domain=[USERNAME]&hostname=[DOMAIN]&record_value=[IP]&apidomainkey=[PASSWORD] | |
| LookupHost/Lookup hostname | test.domain.com | This item is the hostname to be resolved, such as test.domain.com or domain.com |
| domain/Domain | test.domain.com | This item is the hostname to be resolved, such as test.domain.com or domain.com |
| username/Username | domain.com | Fill in the main domain |
| password/Password | Domain KEY | Fill in [ApiKey] on the domain details page |
The Domain KEY here is filled in with [ApiKey] on the domain details page; for the retrieval method, see item 1 of this article.
Note: In custom mode, you need to first manually add an A record resolution for test.domain.com (where test.domain.com should be replaced with your actual domain situation) in the 西部数码 domain control panel.
Configuration example (compatible with IPv6)
Select [Callback] for DNS service provider
URL: https://api.west.cn/API/v2/domain/dns/
RequestBody: act=dnsrec.update&domain=#{domain}&hostname=#{domain}&record_value=#{ip}&apidomainkey=Domain KEY
Note: The Domain KEY here is filled in with [ApiKey] on the domain details page; for the retrieval method, see item 1 of this article.
Domains: Subdomain:root domain
Note: When actually filling in, replace the part in the screenshot: ddnsgo:westlytest.top with your own actual situation. The ddnsgo part refers to the subdomain, which can be defined as another subdomain, such as bbs.
Replace westlytest.top with your own domain.

