How can I do DNS lookups in Python, including referring to /etc/hosts?

Answer

mport socket
print socket.gethostbyname('localhost') # result from hosts file
print socket.gethostbyname('google.com') # your os sends out a dns query

All dns Questions

Ask your interview questions on dns

Write Your comment or Questions if you want the answers on dns from dns Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---