PHP网络设备监控脚本
我正在改进现有的基于 Web 的 IPPBX 管理应用程序。我们真的希望该应用程序能够检测网络上最近连接的 IP 电话,以便我们能够知道 MAC 地址。我读过,一个可行的解决方案是从 DHCP 服务器的租约文件中获取该信息,但不幸的是 DHCP 服务器没有告诉我它在租约条目中引用的是哪种类型的设备。也许我需要一些网络监控协议才能实现这一目标。
我正在寻找一些提示作为快速入门,这样我就可以编写一个 PHP 脚本,让我能够执行上面解释的操作。现有的脚本也很好......:)
欢迎评论或反馈并表示赞赏!
I'm improving an existent Web-based management application for an IPPBX. We would really like that the app detects recently connected IP phones on the network so we can know the MAC address. I've read that a feasible solution would be to fetch that information from DHCP server's leases file, but unfortunately the DHCP server does not tell me which type of device it is referring to in a lease entry. Perhaps I need some network monitoring protocol in order to achieve this.
I'm looking for some hints as a jumpstart so I can write a PHP script that allows me to do that what I explained above. An existent script would be nice too... :)
Comments or feedback welcome and appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
老实说,我认为这将是一个反复试验的案例(换句话说就是研究和开发)。
一些可以尝试的事情:
根据Mac 地址规范,前 3 个字节是组织具体(OUI)。我怀疑如果您的手机来自同一制造商,则该部分应该相似(如果不相同)。无论如何,还是要看一下。
你想出一个网络测试来看看它是否是一部电话。因此,首先您需要获取设备的 IP 地址。然后打开一个端口并尝试发送相当于特定于协议的 ping(在 HTTP 中,这将是对端口 80 的
HEAD
请求),但使用特定于手机的协议。您所寻找的只是正确的响应格式(和连接)。祝你好运,玩得开心。在我看来,这样的项目是最好的,因为它们是一个挑战,可以让你思考和发现......
Honestly, I think this is going to be a case of trial and error (in other words Research and Development).
Some things to try:
According to The Mac Address Specification, the first 3 bytes are organization specific (The OUI). I would suspect that if your phones are from the same manufacturer, that section should be similar (if not identical). Something to look at anyway.
You figure out a network test to see if it's a phone. So, first you get the IP address of the device. Then open a port and try to send an equivalent of a protocol specific ping (in HTTP, it would be a
HEAD
request to port 80), but on a protocol specific to the phones. All you're looking for is a proper response format (and connection).Good luck, and have fun. Projects like these are the best ones in my opinion since they are a challenge and get you thinking and discovering...
首先,我不建议在 PHP 中这样做。用真实语言编写一些内容,然后将其发送到 PHP 脚本。无论如何,我会选择租赁文件。然后使用租用文件中的地址连接到新设备并确定它是否是电话。因此,您将连接到网络上的每个“新”设备。效率低下,但是可以用...
First off, I would not suggest doing this in PHP. Write something in a real language and then send it to a php script. Anyways, I would go with the lease file. Then use the addresses in the lease file to connect to the new device and determine if its a phone. So you would be connecting to every "new" device on the network. Inefficient but it could work...
这是一个用 PHP 编写的现有应用程序(无耻的插件,我写的),它查询 DHCP 租约文件并在网页中很好地格式化它:
http://rivetcode.com/software/phpdhcpd/
github上的代码:
https:/ /github.com/firefly2442/phpdhcpd
Here is an existing application (shameless plug, I wrote it) written in PHP that queries the DHCP leases file and formats it nicely in a webpage:
http://rivetcode.com/software/phpdhcpd/
Code on github:
https://github.com/firefly2442/phpdhcpd