Modifying the answer from dns.query.udp
#1070
-
Good afternoon, How to modify the answer received from For example: import dns.message
import dns.query
query = dns.message.make_query("cloudflare.com", dns.rdatatype.A)
response = dns.query.udp(query, "8.8.8.8")
for answer in response.answer:
if answer.rdtype == dns.rdatatype.A:
for rdata in answer:
if str(rdata) == "127.0.0.1":
print(rdata) except instead of reading the IP, I want to replace it in the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This response is slightly more general than your question, in that it shows you how to change a field of an rdata and replace it in the response. In your case, replacing an rdata field and replacing the whole rdata are the same as A records only have one field, but this technique would work if you (say) wanted to change the priority of an MX record without changing its target.
|
Beta Was this translation helpful? Give feedback.
This response is slightly more general than your question, in that it shows you how to change a field of an rdata and replace it in the response. In your case, replacing an rdata field and replacing the whole rdata are the same as A records only have one field, but this technique would work if you (say) wanted to change the priority of an MX record without changing its target.