接口
- HTTP host: dynupdate.no-ip.com/ic
- HTTP url: /nic/update?hostname=[域名]&myip=[要更新的IP]
- HTTP method: GET
- HTTP headers:
- Authorization: 'Basic ' + Base64([No-IP登录名] + ':' + [No-IP登录密码])
- User-Agent: 'ddnslib.UpdateNoIP/[UA版本] [UA作者]'
参数示例
- HTTP host: dynupdate.no-ip.com/ic
- HTTP url: /nic/update?hostname=cocoonshu.ddns.net&myip=185.199.110.153
- HTTP method: GET
- HTTP headers:
- Authorization: 'Basic ' + Base64('Cocoonshu:123456')
- User-Agent: 'ddnslib.UpdateNoIP/1.0 Cocoonshu'
Python验证
import httplib2
import base64
def update(noipAccount, noipPassword, updateDomain, updatingAddress):
"""update IP Address to No-IP"""
auth = base64.b64encode((noipAccount + ':' + noipPassword).encode('utf-8')).decode('utf-8')
headers = {
'Authorization' : 'Basic ' + auth,
'User-Agent' : 'ddnslib.UpdateNoIP/1.0 Cocoonshu'
}
url = '/nic/update?hostname=' + updateDomain + '&myip=' + updatingAddress
host = 'dynupdate.no-ip.com'
http = httplib2.Http()
response = http.request(uri='https://' + host + url, method='GET', headers=headers)
return response
if __name__ == '__main__':
domain='cocoonshu.ddns.net'
address='185.199.110.153'
result = update(
noipAccount='Cocoonshu',
noipPassword='123456',
updateDomain=domain,
updatingAddress=address
)
print(
'Updating ' + domain + '(' + address + ') to No-IP: '
+ str(result[0].status) + '->' + result[0].reason + "::" + result[1].decode()
)