找出网络上所有活动计算机的IP [英] Find out IP of all active machines on network

查看:101
本文介绍了找出网络上所有活动计算机的IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到我LAN上所有当前活动机器的IP?如何编写可在任何子网中使用的通用程序?

How can I find out the IPs of all the currently active machines on my LAN? How can I write a general program which will work on any subnet?

我目前正在这样做:

  1. 尝试isReachable()是否到达我的子网中的所有计算机.
  2. 如果这样做,请存储其IP地址.

是否还有其他方法可以手动输入子网掩码(增加IP地址)并到达所有机器(从而获得其IP)?

Is there anyway to do this other that manually enter subnet mask(increment the IP addresse) and hence reach all the machines(and thus get their IPs)?

推荐答案

您应该向子网中的所有主机发送ICMP回显消息.例如,如果您的子网是192.168.1.0/24,则将ICMP ping发送到192.168.1.255,所有主机都会响应.

You should send out a ICMP echo message to all hosts in the subnet. For example, if you subnet is 192.168.1.0/24 send a ICMP ping to 192.168.1.255 and all hosts would respond.

[06:43:11 :~]$ ping 192.168.0.255
PING 192.168.0.255 (192.168.0.255): 56 data bytes
64 bytes from 192.168.0.12: icmp_seq=0 ttl=64 time=0.159 ms
64 bytes from 192.168.0.1: icmp_seq=0 ttl=64 time=5.581 ms
64 bytes from 192.168.0.12: icmp_seq=1 ttl=64 time=0.135 ms
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=5.540 ms
^C
--- 192.168.0.255 ping statistics ---
2 packets transmitted, 2 packets received, +2 duplicates, 0.0% packet loss
round-trip min/avg/max/stddev = 0.135/2.854/5.581/2.707 ms
[06:43:21 :~]$ 

这篇关于找出网络上所有活动计算机的IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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