25

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.

I would also be comfortable with a Windows-only solution using some Windows-API function or callback.

(I know that the real way to do this would probably via DHCP, but this is about discovering a legacy device.)

pmf
  • 7,619
  • 4
  • 47
  • 77
  • If both devices can connect to internet then do that, then check the default gateway to see all connected devices? – Ryhan May 19 '13 at 11:21

5 Answers5

21

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.

For example, you have ip 192.168.1.1 and subnet 255.255.255.0

  1. ping 192.168.1.255
  2. stop the ping after 5 seconds
  3. watch the devices replies : 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.

Note (2) : now I am on linux. I am not sure, but it can be windows doesn't reply to icmp_get via broadcast.

Is it the only one device attached to your pc ? Is it a router or another simple pc ?

Massimo
  • 3,171
  • 3
  • 28
  • 41
  • 2
    What about if the address isn't in the 192.168.1.0/24 subnet? – user2284570 Nov 13 '14 at 14:36
  • @user2284570 if it isn't in the same ip subnet, this method doesn't work. the only other method I know will work is snmp-get, try to read the remote device interfaces tables, but it requires 1) snmp daemon on the remote host 2) a community with read access to that host – Massimo Nov 06 '15 at 06:08
  • 1
    Oh I forgot my case was for the posix environment. – user2284570 Nov 06 '15 at 10:43
10

Windows 7 has the arp command within it. arp -a should show you the static and dynamic type interfaces connected to your system.

Sachin Kalakeri
  • 111
  • 1
  • 3
10

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.

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.

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.

Brian White
  • 8,332
  • 2
  • 43
  • 67
6

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.

Hani Yasin
  • 61
  • 1
  • 1
1

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:

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).

You can obtain the model, management IP, VLAN identifier, Port identifier, firmware version, etc.