Kamis, 26 Maret 2020

Python: Making DNS server

FACT
1. DNS server program can be tested locally and interlocally using local program like cmd or using other host on the LAN network.
2. This the result of the local testing, using command:
nslookup www.google.com 127.0.0.1
in command prompt window or cmd.

(b'\x00\x01\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x011\x010\x010\x03127\x07in-addr\x04arpa\x00\x00\x0c\x00\x01', ('127.0.0.1', 56921))
(b'\x00\x02\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03www\x06google\x03com\x00\x00\x01\x00\x01', ('127.0.0.1', 56922))
(b'\x00\x03\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03www\x06google\x03com\x00\x00\x1c\x00\x01', ('127.0.0.1', 56923))
(b'\x00\x04\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03www\x06google\x03com\x00\x00\x01\x00\x01', ('127.0.0.1', 56924))
(b'\x00\x05\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03www\x06google\x03com\x00\x00\x1c\x00\x01', ('127.0.0.1', 56926))

3. You can't use wireshark to capture local traffic. So, you need to rely on the output of the python:
4. The \x is define that the next 2 characters are hex characters. For example \x00
5. \x03 is end of text.
6. When someone asks, you need to answer.
7. UDP Header is always 8 byte.
8. The DNS query length is = UDP length - 8 byte - (2 byte * 8)

Tidak ada komentar:

Posting Komentar