Wood Chen

DNSPOD: Automatic Carrier-Specific DNS with Optimized IPs

0 comments227 views284 words

This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文

Github URL: https://github.com/woodchen-ink/dnspod-yxip

Primarily addresses conflicts between CNAME and MX records at the root domain, If you are using a subdomain, you do not need this project; you can point it directly to **.cf.cname.vvhan.com, reference site: https://cf.vvhan.com/
Thanks to https://cf.vvhan.com/ for providing the API

Creates or updates DNS records in DNSPOD using the IP addresses returned by the API, automatically creating records for four routing lines: Default, China Unicom, China Telecom, and China Mobile.

Supports running in docker, requires Tencent Cloud credentials, and supports configuring multiple domains. Queries the API every 5 minutes and compares the results.

Results

image

Features

  • Automatically fetches optimized IP addresses
  • Supports IPv4 and IPv6
  • Supports China Mobile, China Unicom, and China Telecom routing lines
  • Automatically selects the IP with the lowest latency
  • Supports multiple domain configurations
  • Configurable update interval and TTL
  • Comprehensive logging
  • Docker support

Quick Start

Using Docker Compose

  1. Create the configuration file:
cp .env.example .env
  1. Edit the .env file with your configuration:
# DNSPOD API configuration
TENCENT_SECRET_ID=your_secret_id_here
TENCENT_SECRET_KEY=your_secret_key_here

# Domain configuration - Domain 1
DOMAIN_1=example1.com
SUB_DOMAIN_1=@           # Subdomain; @ represents the root domain
REMARK_1=优选IP          # Record remark
TTL_1=600               # TTL value (seconds)
IPV4_ENABLED_1=true     # Whether to enable IPv4 records
IPV6_ENABLED_1=true     # Whether to enable IPv6 records
ENABLED_1=true          # Whether to enable this domain configuration
  1. Pull and run the container:
docker compose pull
docker compose up -d

Building and Running Manually

  1. Clone the repository:
git clone https://github.com/your-username/dnspod-yxip.git
cd dnspod-yxip
  1. Create and edit the configuration file:
cp .env.example .env
# Edit the .env file
  1. Build the image:
docker compose build
  1. Run the container:
docker compose up -d

Configuration

Each domain configuration includes the following parameters:

  • DOMAIN_n: Domain name
  • SUB_DOMAIN_n: Subdomain; @ represents the root domain, * represents a wildcard
  • REMARK_n: Record remark
  • TTL_n: TTL value (seconds)
  • IPV4_ENABLED_n: Whether to enable IPv4 records
  • IPV6_ENABLED_n: Whether to enable IPv6 records
  • ENABLED_n: Whether to enable this domain configuration

Here, n is the domain number (1, 2, 3...). You can configure any number of domains.

Viewing Logs

Log files are saved in the logs directory:

# View live logs
docker compose logs -f

# View the log file
cat logs/dnspod.log

Updating

  1. Pull the latest image:
docker compose pull
  1. Restart the container:
docker compose up -d

Related posts

Comments 0