好物优选点击查看详情 京东购买

暂无内容

【DNS解析】使用DNSPOD实现动态公网解析(DDNS)

背景

公司电信宽带(PPoE)分配了一个公网IP,但它每过一段时间就变了,如果我要用它远程桌面,意味着每过一段时间就要改一次IP,记一个新的IP,非常复杂,该如何用一个固定的地址来替代这些变化的IP并且实现定时自动替换呢?虽然可以通过购买EIP来固定这个地址,但是成本稍微高了。替代的办法就是动态解析,用一个别名代替变换的IP。而别名就是域名,用一个固定的域名,解析到这些IP,即可实现DDNS。

原理

基本流程就是获取公网IP,然后修改某个域名的解析为获得的IP
流程图如下
在这里插入图片描述

实施

网络:
将服务器网络出口NAT到动态IP线路上(其他设置可自行科普,以下仅供参考)
此处已Cisco路由器为例:

ip nat inside source static tcp 192.168.0.217 80 interface Dialer1 11180 #Dialer1为PPOE拨号线路 access-list 100 permit ip host 192.168.0.217 any #ACL 100为PPOE拨号线路
ip nat inside source static tcp 192.168.0.217 80 interface Dialer1 11180 #Dialer1为PPOE拨号线路 access-list 100 permit ip host 192.168.0.217 any #ACL 100为PPOE拨号线路 
ip nat inside source static tcp 192.168.0.217 80 interface Dialer1 11180 #Dialer1为PPOE拨号线路 access-list 100 permit ip host 192.168.0.217 any #ACL 100为PPOE拨号线路

密钥:
在确定服务器经由PPoE线路上网后,需要在DNSPod上申请API密钥,从而获取SecretId以及SecretKey
在这里插入图片描述

环境:
Ubuntu 20.04 + Python 3.8.10

安装依赖包:

pip install tencentcloud-sdk-python pip install tencentcloud-sdk-python-dnspod
pip install tencentcloud-sdk-python pip install tencentcloud-sdk-python-dnspod 
pip install tencentcloud-sdk-python pip install tencentcloud-sdk-python-dnspod

**详细脚本如下: **
Ref: 腾讯云 API Explorer

<span class="token keyword">import</span> json <span class="token keyword">import</span> requests <span class="token keyword">import</span> logging <span class="token keyword">from</span> datetime <span class="token keyword">import</span> datetime <span class="token keyword">from</span> tencentcloud<span class="token punctuation">.</span>common <span class="token keyword">import</span> credential <span class="token keyword">from</span> tencentcloud<span class="token punctuation">.</span>common<span class="token punctuation">.</span>profile<span class="token punctuation">.</span>client_profile <span class="token keyword">import</span> ClientProfile <span class="token keyword">from</span> tencentcloud<span class="token punctuation">.</span>common<span class="token punctuation">.</span>profile<span class="token punctuation">.</span>http_profile <span class="token keyword">import</span> HttpProfile <span class="token keyword">from</span> tencentcloud<span class="token punctuation">.</span>common<span class="token punctuation">.</span>exception<span class="token punctuation">.</span>tencent_cloud_sdk_exception <span class="token keyword">import</span> TencentCloudSDKException <span class="token keyword">from</span> tencentcloud<span class="token punctuation">.</span>dnspod<span class="token punctuation">.</span>v20210323 <span class="token keyword">import</span> dnspod_client<span class="token punctuation">,</span> models Domain <span class="token operator">=</span> <span class="token string">"*****.com"</span> SubDomain <span class="token operator">=</span> <span class="token string">"p1234"</span> SecretId <span class="token operator">=</span> <span class="token string">"SecretId"</span> SecretKey <span class="token operator">=</span> <span class="token string">"SecretKey"</span> filename <span class="token operator">=</span> <span class="token string">"./"</span> <span class="token operator">+</span> datetime<span class="token punctuation">.</span>now<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span>strftime<span class="token punctuation">(</span><span class="token string">"%Y%m%d"</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"-"</span> <span class="token operator">+</span> SubDomain <span class="token operator">+</span> <span class="token string">"-DDNS-Log.log"</span> logging<span class="token punctuation">.</span>basicConfig<span class="token punctuation">(</span>filename<span class="token operator">=</span>filename<span class="token punctuation">,</span> level<span class="token operator">=</span>logging<span class="token punctuation">.</span>INFO<span class="token punctuation">,</span> <span class="token builtin">format</span><span class="token operator">=</span><span class="token string">'%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s'</span><span class="token punctuation">)</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"脚本开始运行..."</span><span class="token punctuation">)</span> <span class="token keyword">def</span> <span class="token function">get_external_ip</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">try</span><span class="token punctuation">:</span> ip <span class="token operator">=</span> requests<span class="token punctuation">.</span>get<span class="token punctuation">(</span><span class="token string">'https://checkip.amazonaws.com/'</span><span class="token punctuation">)</span><span class="token punctuation">.</span>text<span class="token punctuation">.</span>strip<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">return</span> ip logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"成功获取当前公网地址..."</span><span class="token punctuation">)</span> <span class="token keyword">except</span><span class="token punctuation">:</span> <span class="token keyword">return</span> <span class="token boolean">None</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"获取当前公网地址失败..."</span><span class="token punctuation">)</span> CurrentGlobalIP <span class="token operator">=</span> get_external_ip<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">try</span><span class="token punctuation">:</span> cred <span class="token operator">=</span> credential<span class="token punctuation">.</span>Credential<span class="token punctuation">(</span>SecretId<span class="token punctuation">,</span> SecretKey<span class="token punctuation">)</span> httpProfile <span class="token operator">=</span> HttpProfile<span class="token punctuation">(</span><span class="token punctuation">)</span> httpProfile<span class="token punctuation">.</span>endpoint <span class="token operator">=</span> <span class="token string">"dnspod.tencentcloudapi.com"</span> clientProfile <span class="token operator">=</span> ClientProfile<span class="token punctuation">(</span><span class="token punctuation">)</span> clientProfile<span class="token punctuation">.</span>httpProfile <span class="token operator">=</span> httpProfile client <span class="token operator">=</span> dnspod_client<span class="token punctuation">.</span>DnspodClient<span class="token punctuation">(</span>cred<span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">,</span> clientProfile<span class="token punctuation">)</span> req <span class="token operator">=</span> models<span class="token punctuation">.</span>DescribeRecordListRequest<span class="token punctuation">(</span><span class="token punctuation">)</span> params <span class="token operator">=</span> <span class="token punctuation">{<!-- --></span> <span class="token string">"Domain"</span><span class="token punctuation">:</span> Domain<span class="token punctuation">,</span> <span class="token string">"Subdomain"</span><span class="token punctuation">:</span> SubDomain <span class="token punctuation">}</span> req<span class="token punctuation">.</span>from_json_string<span class="token punctuation">(</span>json<span class="token punctuation">.</span>dumps<span class="token punctuation">(</span>params<span class="token punctuation">)</span><span class="token punctuation">)</span> resp <span class="token operator">=</span> client<span class="token punctuation">.</span>DescribeRecordList<span class="token punctuation">(</span>req<span class="token punctuation">)</span> RecordID <span class="token operator">=</span> resp<span class="token punctuation">.</span>RecordList<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>RecordId RecordValue <span class="token operator">=</span> resp<span class="token punctuation">.</span>RecordList<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>Value RecordLine <span class="token operator">=</span> resp<span class="token punctuation">.</span>RecordList<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>Line RecordType <span class="token operator">=</span> resp<span class="token punctuation">.</span>RecordList<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>Type logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"成功获取域名信息..."</span><span class="token punctuation">)</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"域名信息: "</span> <span class="token operator">+</span> SubDomain<span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>Domain<span class="token operator">+</span><span class="token string">" "</span><span class="token operator">+</span>RecordValue<span class="token punctuation">)</span> <span class="token keyword">except</span> TencentCloudSDKException <span class="token keyword">as</span> err<span class="token punctuation">:</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"获取域名信息失败..."</span> <span class="token operator">+</span> err<span class="token punctuation">)</span> <span class="token keyword">if</span> CurrentGlobalIP <span class="token operator">==</span> RecordValue<span class="token punctuation">:</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"域名信息未发生变动..."</span><span class="token punctuation">)</span> <span class="token keyword">else</span><span class="token punctuation">:</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"域名信息发生变动..."</span><span class="token punctuation">)</span> <span class="token keyword">try</span><span class="token punctuation">:</span> req <span class="token operator">=</span> models<span class="token punctuation">.</span>ModifyRecordRequest<span class="token punctuation">(</span><span class="token punctuation">)</span> params <span class="token operator">=</span> <span class="token punctuation">{<!-- --></span> <span class="token string">"Domain"</span><span class="token punctuation">:</span> Domain<span class="token punctuation">,</span> <span class="token string">"RecordId"</span><span class="token punctuation">:</span> RecordID<span class="token punctuation">,</span> <span class="token string">"RecordLine"</span><span class="token punctuation">:</span> RecordLine<span class="token punctuation">,</span> <span class="token string">"RecordType"</span><span class="token punctuation">:</span> RecordType<span class="token punctuation">,</span> <span class="token string">"SubDomain"</span><span class="token punctuation">:</span> SubDomain<span class="token punctuation">,</span> <span class="token string">"Value"</span><span class="token punctuation">:</span> CurrentGlobalIP <span class="token punctuation">}</span> req<span class="token punctuation">.</span>from_json_string<span class="token punctuation">(</span>json<span class="token punctuation">.</span>dumps<span class="token punctuation">(</span>params<span class="token punctuation">)</span><span class="token punctuation">)</span> resp <span class="token operator">=</span> client<span class="token punctuation">.</span>ModifyRecord<span class="token punctuation">(</span>req<span class="token punctuation">)</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"新域名信息: "</span> <span class="token operator">+</span> SubDomain <span class="token operator">+</span> <span class="token string">"."</span> <span class="token operator">+</span> Domain <span class="token operator">+</span> <span class="token string">" "</span> <span class="token operator">+</span> CurrentGlobalIP<span class="token punctuation">)</span> <span class="token keyword">except</span> TencentCloudSDKException <span class="token keyword">as</span> err<span class="token punctuation">:</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"修改域名信息失败..."</span> <span class="token operator">+</span> err<span class="token punctuation">)</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"脚本结束运行..."</span><span class="token punctuation">)</span>
<span class="token keyword">import</span> json <span class="token keyword">import</span> requests <span class="token keyword">import</span> logging <span class="token keyword">from</span> datetime <span class="token keyword">import</span> datetime <span class="token keyword">from</span> tencentcloud<span class="token punctuation">.</span>common <span class="token keyword">import</span> credential <span class="token keyword">from</span> tencentcloud<span class="token punctuation">.</span>common<span class="token punctuation">.</span>profile<span class="token punctuation">.</span>client_profile <span class="token keyword">import</span> ClientProfile <span class="token keyword">from</span> tencentcloud<span class="token punctuation">.</span>common<span class="token punctuation">.</span>profile<span class="token punctuation">.</span>http_profile <span class="token keyword">import</span> HttpProfile <span class="token keyword">from</span> tencentcloud<span class="token punctuation">.</span>common<span class="token punctuation">.</span>exception<span class="token punctuation">.</span>tencent_cloud_sdk_exception <span class="token keyword">import</span> TencentCloudSDKException <span class="token keyword">from</span> tencentcloud<span class="token punctuation">.</span>dnspod<span class="token punctuation">.</span>v20210323 <span class="token keyword">import</span> dnspod_client<span class="token punctuation">,</span> models   Domain <span class="token operator">=</span> <span class="token string">"*****.com"</span>  SubDomain <span class="token operator">=</span> <span class="token string">"p1234"</span>  SecretId <span class="token operator">=</span> <span class="token string">"SecretId"</span> SecretKey <span class="token operator">=</span> <span class="token string">"SecretKey"</span>  filename <span class="token operator">=</span> <span class="token string">"./"</span> <span class="token operator">+</span> datetime<span class="token punctuation">.</span>now<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span>strftime<span class="token punctuation">(</span><span class="token string">"%Y%m%d"</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"-"</span> <span class="token operator">+</span> SubDomain <span class="token operator">+</span> <span class="token string">"-DDNS-Log.log"</span> logging<span class="token punctuation">.</span>basicConfig<span class="token punctuation">(</span>filename<span class="token operator">=</span>filename<span class="token punctuation">,</span> level<span class="token operator">=</span>logging<span class="token punctuation">.</span>INFO<span class="token punctuation">,</span> <span class="token builtin">format</span><span class="token operator">=</span><span class="token string">'%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s'</span><span class="token punctuation">)</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"脚本开始运行..."</span><span class="token punctuation">)</span>  <span class="token keyword">def</span> <span class="token function">get_external_ip</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">try</span><span class="token punctuation">:</span> ip <span class="token operator">=</span> requests<span class="token punctuation">.</span>get<span class="token punctuation">(</span><span class="token string">'https://checkip.amazonaws.com/'</span><span class="token punctuation">)</span><span class="token punctuation">.</span>text<span class="token punctuation">.</span>strip<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">return</span> ip logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"成功获取当前公网地址..."</span><span class="token punctuation">)</span> <span class="token keyword">except</span><span class="token punctuation">:</span> <span class="token keyword">return</span> <span class="token boolean">None</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"获取当前公网地址失败..."</span><span class="token punctuation">)</span> CurrentGlobalIP <span class="token operator">=</span> get_external_ip<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">try</span><span class="token punctuation">:</span> cred <span class="token operator">=</span> credential<span class="token punctuation">.</span>Credential<span class="token punctuation">(</span>SecretId<span class="token punctuation">,</span> SecretKey<span class="token punctuation">)</span>  httpProfile <span class="token operator">=</span> HttpProfile<span class="token punctuation">(</span><span class="token punctuation">)</span> httpProfile<span class="token punctuation">.</span>endpoint <span class="token operator">=</span> <span class="token string">"dnspod.tencentcloudapi.com"</span> clientProfile <span class="token operator">=</span> ClientProfile<span class="token punctuation">(</span><span class="token punctuation">)</span> clientProfile<span class="token punctuation">.</span>httpProfile <span class="token operator">=</span> httpProfile client <span class="token operator">=</span> dnspod_client<span class="token punctuation">.</span>DnspodClient<span class="token punctuation">(</span>cred<span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">,</span> clientProfile<span class="token punctuation">)</span> req <span class="token operator">=</span> models<span class="token punctuation">.</span>DescribeRecordListRequest<span class="token punctuation">(</span><span class="token punctuation">)</span> params <span class="token operator">=</span> <span class="token punctuation">{<!-- --></span> <span class="token string">"Domain"</span><span class="token punctuation">:</span> Domain<span class="token punctuation">,</span> <span class="token string">"Subdomain"</span><span class="token punctuation">:</span> SubDomain <span class="token punctuation">}</span> req<span class="token punctuation">.</span>from_json_string<span class="token punctuation">(</span>json<span class="token punctuation">.</span>dumps<span class="token punctuation">(</span>params<span class="token punctuation">)</span><span class="token punctuation">)</span> resp <span class="token operator">=</span> client<span class="token punctuation">.</span>DescribeRecordList<span class="token punctuation">(</span>req<span class="token punctuation">)</span> RecordID <span class="token operator">=</span> resp<span class="token punctuation">.</span>RecordList<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>RecordId RecordValue <span class="token operator">=</span> resp<span class="token punctuation">.</span>RecordList<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>Value RecordLine <span class="token operator">=</span> resp<span class="token punctuation">.</span>RecordList<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>Line RecordType <span class="token operator">=</span> resp<span class="token punctuation">.</span>RecordList<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>Type logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"成功获取域名信息..."</span><span class="token punctuation">)</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"域名信息: "</span> <span class="token operator">+</span> SubDomain<span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>Domain<span class="token operator">+</span><span class="token string">" "</span><span class="token operator">+</span>RecordValue<span class="token punctuation">)</span> <span class="token keyword">except</span> TencentCloudSDKException <span class="token keyword">as</span> err<span class="token punctuation">:</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"获取域名信息失败..."</span> <span class="token operator">+</span> err<span class="token punctuation">)</span> <span class="token keyword">if</span> CurrentGlobalIP <span class="token operator">==</span> RecordValue<span class="token punctuation">:</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"域名信息未发生变动..."</span><span class="token punctuation">)</span> <span class="token keyword">else</span><span class="token punctuation">:</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"域名信息发生变动..."</span><span class="token punctuation">)</span> <span class="token keyword">try</span><span class="token punctuation">:</span> req <span class="token operator">=</span> models<span class="token punctuation">.</span>ModifyRecordRequest<span class="token punctuation">(</span><span class="token punctuation">)</span> params <span class="token operator">=</span> <span class="token punctuation">{<!-- --></span> <span class="token string">"Domain"</span><span class="token punctuation">:</span> Domain<span class="token punctuation">,</span> <span class="token string">"RecordId"</span><span class="token punctuation">:</span> RecordID<span class="token punctuation">,</span> <span class="token string">"RecordLine"</span><span class="token punctuation">:</span> RecordLine<span class="token punctuation">,</span> <span class="token string">"RecordType"</span><span class="token punctuation">:</span> RecordType<span class="token punctuation">,</span> <span class="token string">"SubDomain"</span><span class="token punctuation">:</span> SubDomain<span class="token punctuation">,</span> <span class="token string">"Value"</span><span class="token punctuation">:</span> CurrentGlobalIP <span class="token punctuation">}</span> req<span class="token punctuation">.</span>from_json_string<span class="token punctuation">(</span>json<span class="token punctuation">.</span>dumps<span class="token punctuation">(</span>params<span class="token punctuation">)</span><span class="token punctuation">)</span> resp <span class="token operator">=</span> client<span class="token punctuation">.</span>ModifyRecord<span class="token punctuation">(</span>req<span class="token punctuation">)</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"新域名信息: "</span> <span class="token operator">+</span> SubDomain <span class="token operator">+</span> <span class="token string">"."</span> <span class="token operator">+</span> Domain <span class="token operator">+</span> <span class="token string">" "</span> <span class="token operator">+</span> CurrentGlobalIP<span class="token punctuation">)</span> <span class="token keyword">except</span> TencentCloudSDKException <span class="token keyword">as</span> err<span class="token punctuation">:</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"修改域名信息失败..."</span> <span class="token operator">+</span> err<span class="token punctuation">)</span> logging<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"脚本结束运行..."</span><span class="token punctuation">)</span> 
import json import requests import logging from datetime import datetime from tencentcloud.common import credential from tencentcloud.common.profile.client_profile import ClientProfile from tencentcloud.common.profile.http_profile import HttpProfile from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException from tencentcloud.dnspod.v20210323 import dnspod_client, models Domain = "*****.com" SubDomain = "p1234" SecretId = "SecretId" SecretKey = "SecretKey" filename = "./" + datetime.now().strftime("%Y%m%d") + "-" + SubDomain + "-DDNS-Log.log" logging.basicConfig(filename=filename, level=logging.INFO, format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s') logging.info("脚本开始运行...") def get_external_ip(): try: ip = requests.get('https://checkip.amazonaws.com/').text.strip() return ip logging.info("成功获取当前公网地址...") except: return None logging.info("获取当前公网地址失败...") CurrentGlobalIP = get_external_ip() try: cred = credential.Credential(SecretId, SecretKey) httpProfile = HttpProfile() httpProfile.endpoint = "dnspod.tencentcloudapi.com" clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile client = dnspod_client.DnspodClient(cred, "", clientProfile) req = models.DescribeRecordListRequest() params = { "Domain": Domain, "Subdomain": SubDomain } req.from_json_string(json.dumps(params)) resp = client.DescribeRecordList(req) RecordID = resp.RecordList[0].RecordId RecordValue = resp.RecordList[0].Value RecordLine = resp.RecordList[0].Line RecordType = resp.RecordList[0].Type logging.info("成功获取域名信息...") logging.info("域名信息: " + SubDomain+"."+Domain+" "+RecordValue) except TencentCloudSDKException as err: logging.info("获取域名信息失败..." + err) if CurrentGlobalIP == RecordValue: logging.info("域名信息未发生变动...") else: logging.info("域名信息发生变动...") try: req = models.ModifyRecordRequest() params = { "Domain": Domain, "RecordId": RecordID, "RecordLine": RecordLine, "RecordType": RecordType, "SubDomain": SubDomain, "Value": CurrentGlobalIP } req.from_json_string(json.dumps(params)) resp = client.ModifyRecord(req) logging.info("新域名信息: " + SubDomain + "." + Domain + " " + CurrentGlobalIP) except TencentCloudSDKException as err: logging.info("修改域名信息失败..." + err) logging.info("脚本结束运行...")

将脚本设置成定时运行

此处是将脚本设置为每小时的10分运行一次,也可按照自己需求进行修改。
![在这里插入图片描述](https://img-blog.csdnimg.cn/3a69d904c78a4fa3a926445ea95acda1.png
日志输出:
在这里插入图片描述
到此,就完成了动态公网解析,更多可能,需要我们一起继续探索…

原文链接:https://blog.csdn.net/u012153104/article/details/129162140?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168466843816800211583225%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168466843816800211583225&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-2-129162140-null-null.blog_rank_default&utm_term=NAS%E3%80%81%E7%BE%A4%E6%99%96%E3%80%81%E9%98%BF%E9%87%8C%E4%BA%91%E3%80%81%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90%E3%80%81%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F%E3%80%81ipv6%E3%80%81ddns%E3%80%81%E8%BD%BB%E9%87%8F%E7%BA%A7%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E3%80%81%E9%93%81%E5%A8%81%E9%A9%AC%E3%80%81%E5%A8%81%E8%81%94%E9%80%9A%E3%80%81DSM%E3%80%81DSM6.0%E3%80%81%E7%BE%A4%E6%99%96nas%E3%80%81%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E3%80%81%E8%9C%97%E7%89%9B%E6%98%9F%E9%99%85%E3%80%81%E9%BB%91%E7%BE%A4%E6%99%96%E3%80%81docker%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81%E5%9F%9F%E5%90%8D%E6%B3%A8%E5%86%8C%E3%80%81%E5%AE%9D%E5%A1%94%E3%80%81%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E3%80%81nginx%E3%80%81frp%E3%80%81%E5%8A%A8%E6%80%81%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享