如何从IP(Linux)获取主机名? [英] How to get hostname from IP (Linux)?

查看:1053
本文介绍了如何从IP(Linux)获取主机名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过IP地址获取远程计算机/主机名. 我找到了很多答案,例如nslookup,主机,resloveip等. 但是我仍然无法从我的目标机器上获得主机名(cent OS,ubuntu等...) 似乎需要注册到DNS服务器?

I'd like to get remote machine/hostname through IP Address. I found lots of answer such as nslookup, host, resloveip, etc.. but I still can't get hostname from my target machine(cent OS, ubuntu etc...) It seems need to register to DNS server?

我有一台名为 test 的计算机,并且使用IP 10.1.27.97

I have a machine named test and using IP 10.1.27.97

但是我使用上面的方法仍然无法获得"测试"

but I used the method above still can't not get "test"

有人可以帮助我从IP地址获取主机名吗?

Does anyone can help me to get the hostname form IP Address?

推荐答案

要使用nslookuphostgethostbyname(),则目标的名称需要通过DNS注册或在主机文件中静态定义在运行程序的计算机上.是的,您可以使用SSH或其他应用程序连接到目标并直接对其进行查询,但是对于通用解决方案,您将需要某种DNS条目.

In order to use nslookup, host or gethostbyname() then the target's name will need to be registered with DNS or statically defined in the hosts file on the machine running your program. Yes, you could connect to the target with SSH or some other application and query it directly, but for a generic solution you'll need some sort of DNS entry for it.

这篇关于如何从IP(Linux)获取主机名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆