0
我想通過python代碼以編程方式創建dns TXT記錄類型。
我沒有找到有關如何做的數據或TXT記錄的特定格式。如何創建DNS TXT記錄?
這裏是我試圖用Python創建TXT記錄:
# copy the id of the request
packet+=self.data[:2]
# Add the flags of response
packet+= "\x81\x80"
# Questions and Answers Counts
packet+='\x00\x01'
packet+='\x00\x01'
#No records follow
packet+='\x00\x00'
# Additional records follow
packet+='\x00\x00'
#packet+='\x00\x01'
(urlList,urlDataLength) = DecodeQuery(self.data)
urlPosition = urlDataLength
# Original Domain Name Question
packet+=self.data[12:12+urlDataLength+4]
# Pointer to domain name
packet+='\xc0\x0c'
#response type ~~~~~~~~~~~~~~~~
# Response type (TXT)
packet+='\x00\x10'
#CLASS
packet+='\x00\x01'
#TTL
packet+='\x00\x00\x02\x58'
#Data Length
packet+='\x00\x04'
#txt length
packet+='\x04'
packet+= 'hi'.encode('hex')
這個? http://www.zytrax.com/books/dns/ch8/txt.html –
你想達到什麼目的?在您的腳本中編寫TXT記錄有什麼好處?你想在Python中寫一個DNS服務器嗎?因爲只有DNS服務器正在編寫帶有回覆記錄的DNS數據包...... –