Hi All,
I am trying to use dnspython to update my dyndns entry. But i
can't figure out how to do it.
I've literally spent hours looking at the example and trying different
things out but can't get it to work.
I've attached my code in here, maybe someone can point out to me what i
am doing wrong.
Thanks
Anish
import sys
import os
import time
import dns.query
import dns.update
import dns.tsigkeyring
from urllib import urlopen
dns_name = ""
key_name = ""
key_hmac = ""
update_server = "update.dynsdns.com"
ip_resolver = "http://automation.whatismyip.com/n09230945.asp"
external_ip = urlopen(ip_resolver).read()
def update_dns():
print "updating"
print external_ip
outfile = open("/tmp/.ipaddr","w")
outfile.write(external_ip)
outfile.close()
#add TSIG update code here
tsig_server = "update.dyndns.com"
tsig_server_port = "53"
keyring = dns.tsigkeyring.from_text({
ley_name : key_hmac
})
print "attempting to push new ip"
push = dns.update.Update(update_server,keyring=keyring )
print push
push.replace(dns_name,300,'a',external_ip)
print push
response = dns.query.tcp(push,"localhost")
print response
if os.path.exists("/tmp/.ipaddr"):
old_ip_file = open("/tmp/.ipaddr",'r')
old_ip = old_ip_file.read()
if (old_ip != external_ip ):
update_dns()
else:
print "IP addrs match, no need to update"
else:
update_dns()
_______________________________________________
dnspython-users mailing list
[email protected]
http://howl.play-bow.org/mailman/listinfo.cgi/dnspython-users