How can 西部数码 domain names implement the DDNS function (dynamic resolution)?

Published: 2023-11-06

Function Introduction:
Dynamic DNS (DDNS) allows users to use a fixed domain name to access a dynamic IP address, solving the situation where services cannot be accessed due to IP address changes.

This article will introduce how to use the API of 西部数码 to implement the DDNS function, 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 and copy.

image.png


2. User-level authentication (supports managing multiple domains, for resellers only)

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

How to obtain user KEY: https://www.west.cn/manager/API/APIconfig.asp

image.png

Note: When updating DNS records, the dnsrec.update API will delete existing A records and re-add them. For other API functions, see Domain API Interface Documentation


Usage examples:



1. 群晖NAS - Built-in DDNS


Configuration example (not compatible with IPv6; if IPv6 is required, it is recommended to use a third-party package or Docker instance of DDNS-GO)

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__

image.png

Add DDNS, select the west service provider, and for Password/Key, enter the domain's [ApiKey]. Add the corresponding information as shown in the screenshot

image.png


2.openwrt - ddns-script component

Configuration example

Parameter name (English/Chinese)
Parameter valueConfiguration description
Service provider--custom--
update_url/custom update URLhttps://api.west.cn/API/v2/domain/dns/?act=dnsrec.update&domain=[USERNAME]&hostname=[DOMAIN]&record_value=[IP]&apidomainkey=[PASSWORD]
LookupHost/lookup hostnametest.domain.comThis is the hostname to be resolved, such as test.domain.com or domain.com
domain/domain nametest.domain.comThis is the hostname to be resolved, such as test.domain.com or domain.com
username/usernamedomain.comEnter the main domain
password/passwordDomain KEYEnter [ApiKey] on the domain details page


Here, for the domain KEY, enter [ApiKey] on the domain details page; for how to obtain it, see item 1 of this article.

Note: In custom mode, you need to first manually add an A record resolution for test.domain.com in the domain control panel of 西部数码 (where test.domain.com should be replaced with your actual domain situation).


3.DDNS-GO

Configuration example (compatible with IPv6)

Select [Callback] as the DNS service provider

URL: https://api.west.cn/API/v2/domain/dns/

RequestBody: act=dnsrec.update&domain=#{domain}&hostname=#{domain}&record_value=#{ip}&apidomainkey=domainKEY

Note that the domain KEY here should be filled with [ApiKey] on the domain details page; for how to obtain it, see item 1 of this article.

Domains: subdomain:root domain  

Note: When actually filling it in, replace the part ddnsgo:westlytest.top in the screenshot with your own actual situation. The ddnsgo part refers to the subdomain and can be defined as another subdomain, such as bbs.

 Replace westlytest.top with your own domain.

image.png