Java 如何在本地局域网上找到“关闭”系统的 MAC 地址(可能吗?)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2536339/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to find the MAC address of a 'shutdown' system on local lan (is it possible?)
提问by user304017
How to find out the mac address of a system which is:
如何找出系统的mac地址,它是:
- Shutdown
- Power plugged in
- Connected to Lan
- Nic card ON.
- 关掉
- 电源已插入
- 连接到局域网
- 网卡开启。
UpdateI am asking how to find out the mac address of some other system which is already shutdown.... and which is on lan..
更新我在问如何找出其他一些已经关闭的系统的 mac 地址......并且是在局域网上......
I want to find out its mac from my system.... and to be clear... I want to tell that.. arp table can be populated by using ping .. i.e. if 172.16.3.12 is not in arp table then it can be added by just ping 172.16.3.12 but a system can be pinged only if its on... a shutdown system can't be pinged...
我想从我的系统中找出它的 mac ......并且要清楚......我想告诉......可以使用 ping 填充 arp 表 .. 即如果 172.16.3.12 不在 arp 表中,那么它可以通过 ping 172.16.3.12 来添加,但是只有当系统打开时才能 ping 系统……无法 ping 关机系统……
回答by lexu
Once the system is shutdown your best bet to finding the MAC address is looking for stickers somewhere on the case!
一旦系统关闭,找到 MAC 地址的最佳方法就是在机箱的某处寻找贴纸!
Seriously, I guess you arelooking for some way to "wake on lan" a computer on a local lan?
I'm not certain that the machine would respond (be supposed to respond) to anything unless you know the mac already and can the correct magic packet.
说真的,我猜您正在寻找某种方法来“唤醒局域网”本地局域网上的计算机?
我不确定机器是否会响应(应该响应)任何东西,除非你已经知道 mac 并且可以正确的魔术包。
From the wikipedia article I linked:
从我链接的维基百科文章中:
How it works
Wake-on-LAN is platform-independent, so any application on any platform that sends magic packets can wake up computers running on any platform. It is not restricted to LAN (Local area network) traffic.
The computer to be woken is shut down (sleeping, hibernating, or soft off; i.e., ACPI state G1 or G2), with power reserved for the network card, but not disconnected from its power source. The network card listens for a specific packet containing its MAC address, called the magic packet, broadcast on the broadcast address for that particular subnet (or an entire LAN, though this requires special hardware or configuration).
这个怎么运作
LAN 唤醒是独立于平台的,因此任何平台上的任何发送魔术数据包的应用程序都可以唤醒在任何平台上运行的计算机。它不限于 LAN(局域网)流量。
要唤醒的计算机关闭(睡眠、休眠或软关机;即 ACPI 状态 G1 或 G2),为网卡保留电源,但未断开与电源的连接。 网卡侦听包含其 MAC 地址的特定数据包,称为魔术数据包,在该特定子网(或整个 LAN,尽管这需要特殊硬件或配置)的广播地址上广播。
回答by hatem
try to use getmac command
尝试使用 getmac 命令
example: getmac /s [IP address] but i cannot know the mac address of computer turned off by this command
示例:getmac /s [IP 地址] 但我无法知道此命令关闭的计算机的 mac 地址
回答by Matthew
arp -a ip-address
if you know the IP address that the PC typically receives from DHCP, or if it has a static IP.
arp -a ip-address
如果您知道 PC 通常从 DHCP 接收的 IP 地址,或者它是否具有静态 IP。
The PC on which you run the arp
command may yet have this information in cache. I just did this from home by logging into a remote desktop session on one of my servers. The server I logged into still had my PCs infomation in the ARP cache even though my PC was not responding to ping.
您运行该arp
命令的 PC可能还在缓存中包含此信息。我只是在家里通过登录到我的一台服务器上的远程桌面会话来完成此操作。即使我的 PC 没有响应 ping,我登录的服务器的 ARP 缓存中仍然有我的 PC 信息。
Initially I logged into my DHCP server to see if my PC still had a lease because that will list your MAC address, and it will show your PC's name. Unfortunately for me, my PC has a very short lease and so it was not in the list.
最初,我登录到我的 DHCP 服务器以查看我的 PC 是否还有租约,因为它会列出您的 MAC 地址,并且会显示您的 PC 名称。对我来说不幸的是,我的电脑租期很短,所以它不在列表中。
Fortunately, I happen to know the IP address that my PC typically obtains from DHCP, so I was able to use the above arp
command.
幸运的是,我碰巧知道我的 PC 通常从 DHCP 获取的 IP 地址,因此我能够使用上述arp
命令。
Using this information I was able to send a magic packet to my PC and wake it up. This I did using a free utility I found after a brief Google search.
使用此信息,我能够向我的 PC 发送一个魔法数据包并将其唤醒。这是我使用我在谷歌简短搜索后找到的免费实用程序完成的。
回答by Edward Falk
Yes, I once tried to implement a data-center-wide power management system based on Wake On Lan technology. I had a number of solutions, but never got to implement them because the data center people decided that the reliability costs involved in shutting down and powering back up were higher than the energy savings.
是的,我曾经尝试过基于 Wake On Lan 技术实现数据中心范围的电源管理系统。我有许多解决方案,但从未实施它们,因为数据中心人员认为关闭和重新启动所涉及的可靠性成本高于节能成本。
A couple of random observations:
几个随机观察:
My experience was that the routers forgot the mac addresses after the machines had been shut down for more than 20 minutes. After that, the mac addresses were lost until the machines next powered up. Obviously, this will vary depending on the actual router used, but 20 minutes is probably pretty typical.
我的经验是,在机器关闭超过 20 分钟后,路由器忘记了 mac 地址。之后,mac 地址丢失,直到机器下一次通电。显然,这将根据所使用的实际路由器而有所不同,但 20 分钟可能是非常典型的。
This means that in practice, the only way to get the mac address is to obtain it BEFORE you shut the system down. I'm not sure what your application is, but I think you can probably find a way to do this one way or another.
这意味着在实践中,获取 mac 地址的唯一方法是在关闭系统之前获取它。我不确定您的应用程序是什么,但我认为您可能会找到一种方法来执行此操作。
Once the router has forgotten the mac address, there's no way to deliver the WOL packet to the machine to be woken from outside the network. From inside the network, you can still do it with a broadcast packet. Either way, you still need to know the mac address, since it's part of the WOL packet.
一旦路由器忘记了 mac 地址,就无法将 WOL 数据包传送到要从网络外部唤醒的机器。从网络内部,您仍然可以使用广播数据包来做到这一点。无论哪种方式,您仍然需要知道 mac 地址,因为它是 WOL 数据包的一部分。
Now theoretically, you could modify the firmware in the NIC chip to allow it to respond to ARP packets even when the machine itself is powered off. This may even be common practice -- I don't know. If so, what you want to do is do-able, but would be highly dependent on the exact network interface you have.
现在理论上,您可以修改网卡芯片中的固件,使其即使在机器本身断电的情况下也能响应 ARP 数据包。这甚至可能是常见的做法——我不知道。如果是这样,您想要做的是可行的,但高度依赖于您拥有的确切网络接口。