CS305 Lab assignment 5.3 (Solution)

$ 29.99
Category:

Description

wangw6@sustech.edu.cn Using python to implement a ‘Local DNS Server’.
NOTES: the python source file should be named as ‘LocalDNSServer.py’ using UTF-8 as file coding, work on port 5353 of 127.0.0.1, there is no need to zip the source file, Comments in code is MUST.
1. The ‘Local DNS Server’ is expected work on port 5353 of 127.0.0.1, its function should include:
(1) Listen and accept DNS queries from client, support default query type: A type.
(2) Maintain a Cache:
Cache should be read.
Cache should be write while response is coming.While the query is new, cache the query and response.
(3) Maintain a list of records about the domain name and IPv4 address of Root DNS servers.
(4) Search related DNS response in Cache according to the received query.
example.com. level
DNS Server
Cache
(5) Invoke DNS queries to other DNS server if needed and cache the new response.
(6) Send the response to the client.
(7) EDNS: here ‘Local DNS server’ doesn’t do special process on EDNS rrs, while it received a query with EDNS rr, it just send this special EDNS rr as an attachment of the following queries and responses.
2. TESTING suggestion:
(1) using ‘dig’ as client to communicate with ‘Local DNS Server’.
(2) using ‘Wireshark’ to trace the communication between client, ‘Local DNS Server’ and other DNS servers.
3. Take a DNS query to “www.example.com” as an example:
Root level

Client

Local DNS Server

com. level
DNS Server

DNS Server
(1) Client send an DNS query about “www.example.com” to ‘Local DNS server’
(2) ‘Local DNS server’ search its answer in Cache if the answer is found in cache, ‘Local DNS Server’ send this answer to Client as DNS response.
if the answer is not found:
a. ‘Local DNS Server’ send the query to Root level DNS Server, got the DNS response message about the list of com level Name server and its ip address.
b. ‘Local DNS Server’ send the query to com. level DNS Server, got the DNS response message about the list of example.com level Name server and its ip address.
c. ‘Local DNS Server’ send the query to example.com. level DNS Server, got the DNS response message about the answer of the original DNS query.
d. ‘Local DNS Server’ cache the query and answer to Cache.
(3) ‘Local DNS Server’ send the DNS response message to Client.
TIPS:
1. Using ‘dig’ to invoke a DNS query, ‘rd’ field of query is set 1 by default.
2. While ‘Local DNS Server’ receive a DNS query with ‘rd’ field set as 1, it will send several DNS queries to other DNS server, the value of ‘rd’ field of all these queries is set as 0.
3. There will be several pairs of query and response while the answer is not in the Cache, response message share the same transaction ID with query in a pair.
Following is a list of captured packets :Client(42) send query to ‘Local DNS server’(217), ‘Local DNS server’ do the queries and finally get answer, ‘Local DNS server’ send the answer in DNS response to Client.

More details:
(1) Client (42) send query to ‘Local DNS server’(217)

(2) ‘Local DNS server’(217) invoke DNS query to 192.42.93.30.

(3) ‘Local DNS server’ received DNS response from 192.42.93.30.

(4) ‘Local DNS server’(217) send query to 125.254.154.167.

(5) ‘Local DNS server’(217) received response from 125.254.154.167.

(6) ‘Local DNS server’(217) send query to 111.230.159.13.

(7) ‘Local DNS server’(217) receive response from 111.230.159.13.

(8) ‘Local DNS server’(217) send response to client(42).

Reviews

There are no reviews yet.

Be the first to review “CS305 Lab assignment 5.3 (Solution)”

Your email address will not be published. Required fields are marked *