[英]How to find a host's FQDN from its IP address in Python
I am writing a python script in which I have an IP address from which I need to find the associated host's FQDN. 我正在编写一个python脚本,其中有一个IP地址,我需要从该IP地址中找到关联的主机的FQDN。
I know there are socket.getfqdn() and socket.gethostbyaddr() calls but they are giving only the hostname in this case and not the FQDN. 我知道有socket.getfqdn()和socket.gethostbyaddr()调用,但是在这种情况下,它们仅提供主机名,而不提供FQDN。
However, if I'm running 'host ' or 'nslookup ' on my local linux pc it shows me the FQDN of that host. 但是,如果我在本地linux PC上运行“ host”或“ nslookup”,则会显示该主机的FQDN。
Please help me if there is any way to achieve it in Python. 如果有任何方法可以用Python实现,请帮助我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.