简体   繁体   English

如何解析私有LAN上的IP地址并获取bash中的关联主机名?

[英]How to resolve an IP-address on a private LAN and get the associated hostname in bash?

I am writing a bash script that collects information on the LAN to which I am connected. 我正在编写一个bash脚本,用于收集有关我所连接的LAN的信息。

After following instructions from post How can I write a linux bash script that tells me which computers are ON in my LAN? 按照发布后的说明如何编写一个linux bash脚本,告诉我哪些计算机在我的局域网中打开? , I would like to collect some other information on the computers connected on my same LAN, such as their hostname. ,我想收集在同一局域网上连接的计算机上的其他一些信息,例如他们的主机名。

I looked in the PING command man page but didn't find anything useful, and also checked NSLOOKUP command, but without success. 我查看了PING命令手册页但没有找到任何有用的东西,并且还检查了NSLOOKUP命令,但没有成功。

Are there any already existing bash commands which resolves IP addresses to hostnames on a private LAN? 是否有已存在的bash命令将IP地址解析为专用LAN上的主机名?

In case not, do you have some ideas on how to write a script for getting it? 如果没有,你对如何编写脚本获取它有什么想法吗?

你有尝试过的host命令吗?

host 204.152.191.5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM