Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python dns更新密钥环对象_Python_Dns - Fatal编程技术网

python dns更新密钥环对象

python dns更新密钥环对象,python,dns,Python,Dns,我试图使用python更新dns服务器区域中的记录,但遇到了一些关键问题 使用类似于nsupdate-k Ktest.com.+165+48236.key-v update.txt的命令,该键在命令行上可以正常工作-因此我知道dns服务器可以使用该键 这是所有测试/伪值,所以我也发布了键字符串 print "Updating zone [%s] record [%s] on dns host [%s] with new ip [%s]" % (zone, record, dns_host, ne

我试图使用python更新dns服务器区域中的记录,但遇到了一些关键问题

使用类似于nsupdate-k Ktest.com.+165+48236.key-v update.txt的命令,该键在命令行上可以正常工作-因此我知道dns服务器可以使用该键

这是所有测试/伪值,所以我也发布了键字符串

print "Updating zone [%s] record [%s] on dns host [%s] with new ip [%s]" % (zone, record, dns_host, new_ip)
keyring = dns.tsigkeyring.from_text({record : key})
print ""
print key
print ""
print keyring
print ""
update = dns.update.Update(record, keyring = keyring, keyname = record, keyalgorithm = 'hmac-sha512')
update.replace(record, 300, 'A', new_ip)
输出: 使用新ip[123.123.123.123]更新dns主机[127.0.0.1]上的区域[test.com]记录[auth.test.com]

Q3oiZUnS83s9+8bBWwn+5ZMfj/qHwAWVuAt2Zck1YhYUygPeTwkKbXjV 6Wj+cIf/2IRdjv5OEDUrrA/orGAlZw==


{<DNS name auth.test.com.>: 'Cz"eI\xd2\xf3{=\xfb\xc6\xc1[\t\xfe\xe5\x93\x1f\x8f\xfa\x87\xc0\x05\x95\xb8\x0bve\xc95b\x16\x14\xca\x03\xdeO\t\nmx\xd5\xe9h\xfep\x87\xff\xd8\x84]\x8e\xfeN\x105+\xac\x0f\xe8\xac`%g'}

Traceback (most recent call last):
  File "./service_tester.py", line 122, in <module>
    check_nodes(config)
  File "./service_tester.py", line 107, in check_nodes
    check_dns(record_name, record_items['zone'], record_items['failover_type'],      record_items['key'], record_items['good_nodes'], record_items['dns_host'])
  File "./service_tester.py", line 69, in check_dns
    update_dns(zone, record, dns_server, good_hosts[0], key)
  File "./service_tester.py", line 44, in update_dns
    response = dns.query.tcp(update, dns_host)
  File "/usr/lib/python2.7/site-packages/dns/query.py", line 323, in tcp
    one_rr_per_rrset=one_rr_per_rrset)
  File "/usr/lib/python2.7/site-packages/dns/message.py", line 786, in from_wire
    reader.read()
  File "/usr/lib/python2.7/site-packages/dns/message.py", line 727, in read
    self._get_section(self.message.additional, adcount)
  File "/usr/lib/python2.7/site-packages/dns/message.py", line 679, in _get_section
    self.message.first)
  File "/usr/lib/python2.7/site-packages/dns/tsig.py", line 163, in validate
    raise PeerBadKey
 dns.tsig.PeerBadKey
在我看来,keyring对象不正确,但我不知道为什么不正确

编辑:dns服务器上的错误是:对于更新区域NOTAUTH来说不是权威性的


但是如果我使用ndupdate-k keyfile-v update.txt,它的效果非常好。

问题是:

update=dns.update.Updaterecord,keyring=keyring,keyname=record,keyalgorithm='hmac-sha512'

应该是

update=dns.update.Updatezone,keyring=keyring,keyname=record,keyalgorithm='hmac-sha512'

这个错误消息非常混乱,因为它说它无法更新dns服务器上的区域,而不是说客户端实际上试图更新该区域