简体   繁体   中英

DNS Packet IP Address Structure

I have been writing a python program that builds a packet and sends the packet request to a dns server. I have a problem the IP address is stored in hex in a way that is difficult to understand. In the hex field it has the number of each iteration with a 3 in front of it, so 8 in 8.8.8.8 is represented in hex as '38'. Is there an easy way to make 38 in hex from integer type 8?

Wireshark DNS 数据包捕获

That's not an address field, it's the domain name field. You're trying to look up the IP associated with the domain name 8.8.8.8 . I'm not sure why you're trying to do this -- if you have a numeric IP, you don't need to use DNS to translate it to an address.

Domain names are represented as ASCII text, and 38 is ASCII code for the character 8 .

From int 8 to hex 38, you'll need to go through a few conversions. From int to string, to decimal, to hex.

For example: int 8 -> string = '8' -> ord('8') = 56 -> hex(56) = 0x38

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM