简体   繁体   English

使用pygodaddy模块更新我的域的IP地址

[英]Using pygodaddy module to update IP address of my domain

I saw an example that use pygodaddy to update IP address of my domain. 我看到了一个使用pygodaddy更新域IP地址的示例 Here is the python script (removed account info): 这是python脚本(已删除的帐户信息):

#!/usr/bin/env python

import logging
import pif
import pygodaddy

LOG_PATH = '/Users/csj/godaddy.log'
logging.basicConfig(filename=LOG_PATH, format='%(asctime)s %(message)s', level=logging.INFO)
GODADDY_USERNAME="MY_LOGIN_ID"
GODADDY_PASSWORD="MYPASSWORD"
client = pygodaddy.GoDaddyClient()

try:
    client.login(GODADDY_USERNAME, GODADDY_PASSWORD)
    for domain in client.find_domains():
        dns_records = client.find_dns_records(domain)
        public_ip = pif.get_public_ip()
        logging.debug("Domain '{0}' DNS records: {1}".format(domain, dns_records))
        # only update if IP not the same with previous one
        if public_ip != dns_records[0].value:
            client.update_dns_record(domain, public_ip)
            logging.info("Domain '{0}' public IP set to '{1}'".format(domain, public_ip))
except Exception, err:
    logging.info("Error: %s" % err)

after execute the script, everything looks fine. 执行脚本后,一切看起来都很好。 The log is as below: 日志如下:

015-02-01 18:00:30,200 Starting new HTTPS connection (1): dns.godaddy.com 2015-02-01 18:00:31,134 Starting new HTTPS connection (1): idp.godaddy.com 2015-02-01 18:00:36,779 Starting new HTTP connection (1): v4.ident.me 2015-02-01 18:00:38,654 Domain 'csj.io' public IP set to '122.121.103.37' 015-02-01 18:00:30,200开始新的HTTPS连接(1):dns.godaddy.com 2015-02-01 18:00:31,134开始新的HTTPS连接(1):idp.godaddy.com 2015-02- 01 18:00:36,779开始新的HTTP连接(1):v4.ident.me 2015-02-01 18:00:38,654域'csj.io'公用IP设置为'122.121.103.37'

However, I checked the manager panel in godaddy website, the IP address did not change. 但是,我在godaddy网站上检查了管理器面板,IP地址没有更改。 neither by ping it. 都不通过ping它。

Is there any convenient to update IP address of my domain? 是否可以方便地更新我的域的IP地址? or anything I can try on the script? 或任何我可以尝试使用的脚本?

There was an exploit on Godaddy that was patched on Jan 18, and that broke PyGodaddy. 1月18日修补了Godaddy的漏洞,并破坏了PyGodaddy。 There´sa new version of the script on Github. Github上有脚本的新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM