5.2. Programming Assignment 2 - DNS MX Record LookupsΒΆ

A list of e-mail servers

You are to add a few lines of code to the stub program provided. (Download, dns_MX_stub.py) The function MX_lookup() should return a list of strings for e-mail servers. The servers should be sorted by the domain’s priorities as specified in their DNS MX records.

Here is a sample output from the provided stub program:

Enter a domain name to look up: sal.ksu.edu
(100, <DNS name mx2.cc.ksu.edu.>)
(100, <DNS name mx3.cc.ksu.edu.>)
(10, <DNS name postman.sal.ksu.edu.>)
(100, <DNS name mx1.cc.ksu.edu.>)

Here is what the output of the completed project should look like:

Enter a domain to look up: sal.ksu.edu

Notice that in the initial program, the servers list contains tuples where the first value of the tuple is a MX preference and the second value is the server name. Thus, all that is needed is to sort the list and print the second value of each tuple.

This is obviously a pretty short assignment, intended mostly to let you work some with lists, tuples and strings.

The module dnspython is needed for the programming assignment. It can be installed with the easy_install command from the setuptools package. See Installation of Python Packages for a description of how to install dnspython.