引入:

    这个问题,本人仅从Linux系统环境给出解决途径。而且答案在博文“学生机房虚拟化(十五)集中控制学生机 ”中已经给出。

环境要求:

    Linux系统、nmap软件

整体实现:

1、查询所有对应子网主机信息,以192.168.0.0/24为例。

   
   
   
   
  1. $ nmap -sP 192.168.0.0/24 

2、查看所获得信息

    此处做了一下筛选,仅显示当前活动的主机。

   
   
   
   
  1. $ grep 0x2 /proc/net/arp 
  2. 192.168.0.102    0x1         0x2         00:25:86:96:5d:0e     *        eth0  
  3. 192.168.0.111    0x1         0x2         00:30:18:a7:12:92     *        eth0  
  4. 192.168.0.100    0x1         0x2         00:0c:76:cc:2f:78     *        eth0  
  5. 192.168.0.15     0x1         0x2         00:30:18:a7:0e:0b     *        eth0  
  6. 192.168.0.112    0x1         0x2         00:25:86:98:43:f4     *        eth0  
  7. 192.168.0.1      0x1         0x2         00:03:0f:10:d4:78     *        eth0  
  8. 192.168.0.201    0x1         0x2         00:10:20:18:24:68     *        eth0  
  9. 192.168.0.99     0x1         0x2         00:e0:0f:9c:81:c4     *        eth0  
  10. 192.168.0.103    0x1         0x2         00:25:86:97:60:c3     *        eth0  
  11. 192.168.0.107    0x1         0x2         00:30:18:a7:11:fc     *        eth0  
  12. 192.168.0.113    0x1         0x2         d0:27:88:5e:47:9f     *        eth0  
  13. 192.168.0.200    0x1         0x2         00:30:48:70:ea:d3     *        eth0  
  14. 192.168.0.104    0x1         0x2         00:1f:d0:67:96:cc     *        eth0  
  15. 192.168.0.105    0x1         0x2         00:19:e0:1c:cb:ec     *        eth0  
  16. shenzhi@sz0850:~$  

细节实现:

    将上一步中的命令更改为“grep <目标MAC地址> /proc/net/arp”,即可查询到所需信息,只是这里有一个前提,此主机要处于开机状态才可查到。

   
   
   
   
  1. $ grep '00:30:18:a7:12:92' /proc/net/arp  
  2. 192.168.0.111    0x1         0x2         00:30:18:a7:12:92     *        eth0