[Assignment in the course Introduction to Communication Networks
]
Python implementation for DNS server and client. The server holds a .txt
file that contains mapping addresses and IP & port addresses of a higher DNS server. When a client requests a domain, the server will look in its .txt file for the appropriate IP address and return it to the client. If the server is not found, it will contact its "father" (the DNS server above it) requesting the IP address of that domain. Then, when it gets the answer, the server will keep it for TTL time in its mapping file. In this implementation there is an assumption that there is some server in the hierarchy that knows the requested domain.
- Windows / Linux / macOS with python3
- Git
- Clone the repository:
$ git clone https://github.com/tomershay100/DNS-local-server.git
- Run the server using python3:
With "12345" as the server's port number (you can choose a free port as you like), "127.0.0.1" and "11223" as the IP and port addresses of the higher DNS server and "ips.txt" as a
$ python3 server.py 12345 127.0.0.1 11223 ips.txt
.txt
mapping file. In order to run a root server (without a server above it) you must put -1 in the DNS server addresses as follows:$ python3 server.py 12345 -1 -1 ips.txt
. - Run the client using python3. The client will receive as arguments the IP and port of the DNS server as follows:
With "12345" as the server's port number (you can choose a free port as you like) and "127.0.0.1" as the server's IP.
$ python3 client.py 127.0.0.1 12345
- Enter the required domain as input next to the customer. For example, for "mail.google.com" the output will be 9.9.9.9 (as long as it is written in an ips.txt file).
You can run the client and the DNS servers on the same computer (different terminal) or on another computer on the same network.