1

我使用 from twisted.names import dns 在我的网络上提供 dns 查询。我想回复我的域的 IP 地址列表(例如“mydomain22.com”查询)我使用这个示例来提供查询https://gist.github.com/johnboxall/1147973

    for answer in ans:
        if answer.type != dns.A:
            continue
        if domain['name'] not in answer.name.name:
            continue

        answer.payload.address = socket.inet_aton(list_of_ip) # here 
        answer.payload.ttl = TTL 

谢谢!

4

1 回答 1

1

I can guess that ans is a list of RRHeader instances (but it's sad that I had to guess, try including this sort of information in your questions in the future :) which is used to populate the answers section of the DNS message your code sends as a response.

However, it's not obvious that my guess is correct because if it were correct then you'd already be able to send back multiple answers. ans is a list of RRHeader instances and each of those instances will be included in the answer that is sent out. So if you'd like more answers to be sent, just add more RRHeader instances to ans.

And of course, if the records are more suitable as authority or additional records, then put them into one of those lists instead of into the answers list.

于 2013-03-16T16:03:23.293 回答