How to Determine The Ip of The Computer That Connects to Me

how to get IP address of a computers that is directly connected to my PC

If your software is running on both machines, you can have one (or both) machines send out a particular broadcast (or, if you prefer, multicast) UDP packet on a specific port. Your program should also be listening on that same port. When it receives that packet (using recvfrom()), recvfrom()'s fifth argument will contain the IP address of the machine that sent the packet, i.e. the IP address you want.

(If OTOH your software is not running on the remote machine, you'll need to use some more general-purpose discovery mechanism such as mDNS or LLDP -- hopefully you won't have to do that, though, as it's a good deal more complicated)

Find IP address of directly connected device

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.

List the IP Address of all computers connected to a single LAN

You're not really going to find anything more reliable than pinging or arpinging addresses on the same subset. I implemented this for a certain piece of software back in the day on my first internship and, last time I checked (to be fair it was several years ago), that is what they were still using for this functionality. I take that to mean that they haven't found anything better.

It is not hard to find the source code for these and translate them to C#. ping, arping. Alternatively, you just shell out to a command prompt and execute ping and then parse the results.

How to find the WAN ip for a connected computer

if the client is in your network you will probably stay in your LAN - therefore you will get the response from the private IP of course.
the WAN IP is only used when the client tries to access some IP on a public range.

one option is to ask the client to visit something like http://www.whatismyip.com/ and tell you the output or host a service yourself that is doing something similar.

How do I find through which local IP address I connect to another device based on its IP address?

Since Windows 10 and Server 2012 R2, Powershell has a Find-NetRoute commandlet that seems to do that.

$routeInfo = Find-NetRoute -RemoteIPAddress 192.168.0.101

On success, $routeInfo[0] is the interface through which the data will go, and $routeInfo[1] is the route that matched the remote IP address.



Related Topics



Leave a reply



Submit