美文网首页
[DDNS] No-IP更新DDNS记录接口

[DDNS] No-IP更新DDNS记录接口

作者: Cocoonshu | 来源:发表于2023-06-25 12:46 被阅读0次

    接口

    • 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()
            )
    

    相关文章

      网友评论

          本文标题:[DDNS] No-IP更新DDNS记录接口

          本文链接:https://www.haomeiwen.com/subject/cppiydtx.html