Python dns lookup script

The python dns lookup script performs a dns lookup with python and returns the IP address of the corresponding DNS name. The script can be used to find the IP address of a website , URL etc. The source code is shown below.

Online Python Network Programming Course

The above code is a inserted in a python file and executed from the command line. The explanation of the code is provided below.

1. The 1st line imports the module socket
2. The 2nd line takes the URL/Website name from the user
3. The 3rd line prints the IP address.

The name of the python file is dnslookup.py and executed from the command line.

Online Python Network Programming Course