windows 查找直连设备的IP地址
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6128598/
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
Find IP address of directly connected device
提问by pmf
Is there a way to find out the IP address of a device that is directly connected to a specific ethernet interface? I.e. given one host, one wired ethernet connection and one second host connected to this wired connection, which layer or protocol below IP could be used to find this out.
有没有办法找出直接连接到特定以太网接口的设备的 IP 地址?即给定一台主机、一个有线以太网连接和另一台连接到该有线连接的主机,IP 下的哪个层或协议可用于找出这一点。
I would also be comfortable with a Windows-only solution using some Windows-API function or callback.
我也会对使用一些 Windows-API 函数或回调的仅限 Windows 的解决方案感到满意。
(I know that the real way to do this would probably via DHCP, but this is about discovering a legacy device.)
(我知道真正的方法可能是通过 DHCP,但这是关于发现旧设备。)
采纳答案by Brian White
To use DHCP, you'd have to run a DHCP server on the primary and a client on the secondary; the primary could then query the server to find out what address it handed out. Probably overkill.
要使用 DHCP,您必须在主服务器上运行 DHCP 服务器,在辅助服务器上运行客户端;然后主服务器可以查询服务器以找出它分发的地址。大概是矫枉过正了。
I can't help you with Windows directly. On Unix, the "arp" command will tell you what IP addresses are known to be attached to the local ethernet segment. Windows will have this same information (since it's a core part of the IP/Ethernet interface) but I don't know how you get at it.
我无法直接帮助您使用 Windows。在 Unix 上,“arp”命令将告诉您已知哪些 IP 地址连接到本地以太网段。Windows 将具有相同的信息(因为它是 IP/以太网接口的核心部分),但我不知道您是如何获得它的。
Of course, the networking stack will only know about the other host if it has previously seen traffic from it. You may have to first send a broadcast packet on the interface to elicit some sort of response and thus populate the local ARP table.
当然,网络堆栈只有在之前看到过来自另一台主机的流量时才会知道它。您可能必须首先在接口上发送广播数据包以引起某种响应,从而填充本地 ARP 表。
回答by Massimo
Mmh ... there are many ways. I answer another network discovery question, and I write a little getting started.
嗯……有很多方法。我回答了另一个网络发现问题,我写了一点入门。
Some tcpip stacks reply to icmp broadcasts. So you can try a PING to your network broadcast address.
一些 tcpip 堆栈回复 icmp 广播。因此,您可以尝试 PING 到您的网络广播地址。
For example, you have ip 192.168.1.1 and subnet 255.255.255.0
例如,您有 ip 192.168.1.1 和子网 255.255.255.0
- ping 192.168.1.255
- stop the ping after 5 seconds
- watch the devices replies : arp -a
- 平 192.168.1.255
- 5 秒后停止 ping
- 观看设备回复:arp -a
Note : on step 3. you get the lists of the MAC-to-IP cached entries, so there are also the hosts in your subnet you exchange data to in the last minutes, even if they don't reply to icmp_get.
注意:在第 3 步中,您将获得 MAC-to-IP 缓存条目的列表,因此在您的子网中还有您在最后几分钟交换数据的主机,即使它们没有回复 icmp_get。
Note (2) : now I am on linux. I am not sure, but it can be windows doesn't reply to icm_get via broadcast.
注 (2) :现在我在 linux 上。我不确定,但可能是 windows 不通过广播回复 icm_get。
Is it the only one device attached to your pc ? Is it a router or another simple pc ?
它是唯一一个连接到您的 PC 的设备吗?它是路由器还是其他简单的电脑?
回答by Hani Yasin
Your Best Approach is to install Wireshark, reboot the device wait for the TCP/UDP stream , broadcasts will announce the IP address for both Ethernet ports This is especially useful when the device connected does not have DHCP Client enabled, then you can go from there.
你最好的方法是安装 Wireshark,重启设备等待 TCP/UDP 流,广播将宣布两个以太网端口的 IP 地址这在连接的设备没有启用 DHCP 客户端时特别有用,然后你可以从那里开始.
回答by Sachin Kalakeri
Windows 7 has the arp command within it. arp -a should show you the static and dynamic type interfaces connected to your system.
Windows 7 中包含 arp 命令。arp -a 应该显示连接到系统的静态和动态类型接口。
回答by Vincent Vega
You can also get information from directly connected networking devices, such as network switches with LDWin, a portable and free Windows program published on github:
您还可以从直接连接的网络设备获取信息,例如使用 LDWin 的网络交换机,这是一个在 github 上发布的可移植且免费的 Windows 程序:
http://www.sysadmit.com/2016/11/windows-como-saber-la-ip-del-switch-al-que-estoy-conectado.html
http://www.sysadmit.com/2016/11/windows-como-saber-la-ip-del-switch-al-que-estoy-conectado.html
LDWin supports the following methods of link discovery: CDP (Cisco Discovery Protocol) and LLDP (Link Layer Discovery Protocol).
LDWin 支持以下链路发现方法:CDP(思科发现协议)和 LLDP(链路层发现协议)。
You can obtain the model, management IP, VLAN identifier, Port identifier, firmware version, etc.
可以获取型号、管理IP、VLAN标识、端口标识、固件版本等信息。