$30
Most of what you’ll need in this assignment is included in the resolve.py skeleton file included in this archive. You’ll need to install the dnspython (https://www.dnspython.org/). You can do so using pip (https://pip.pypa.io/en/stable). In most cases you can do so by running one of the following commands on your system:
• pip3 install dnspython
• pip install dnspython
• python -m pip install dnspython
An essential piece of documentation that you’ll need to reference for this assignment is the documentation for dnspython which is here: https://dnspython.readthedocs.io/en/stable/
The Assignment
You’ll find a resolve.py file in your repo. This file contains code that approximates the functionality of the host program. The program takes a domain name, and returns a summary of DNS information about the domain. For example, given the domain “yahoo.com”, host returns the “A”, “AAAA” and “MX” records for the domain.
You can test this out by running the resolve.py command as so:
python resolve.py yahoo.com.
resolve.py currently queries a DNS server (8.8.8.8) to find information about domains. That DNS server handles the recursive part of DNS for you (i.e. 8.8.8.8 by default doesn’t know where to find yahoo.com., so it asks a root server, and the root server tells 8.8.8.8 where to find information about .com, so then 8.8.8.8 asks the new server where to find yahoo.com., etc.)
Your task in this assignment is to implement this recursive functionality on your own. When your version of resolve.py is run, it will not query 8.8.8.8 (or any other recursive resolver). Your resolve.py will query a root server itself, as well as performing any further needed queries.
The IP addresses of the root servers are hard coded into the resolve.py in the global ROOT_SERVERS list. Your program should start by querying one of these servers. A very good first step in your solution will be to find where 8.8.8.8 is in the code currently, and make sure you instead query one of the root servers.
Using the responses from what you get from the root severs, you will then ask one of the TLD servers, and so on and so on. The base case of your recursive function will be when you have received the actual A, AAA, and MX records for a given domain.