6

Ok, so I am trying to write an application which works with a piece of hardware (a router). The first part of my application is to obviously detect if the device is on the network (either on the WAN side or the LAN side as the router can be accessed from both sides, whether you are connected to a down stream router or a directly to the router I am trying to access through the application) - I hope this is making sense.

The two options I have thought of to detect if the device is on the network are:

  1. Because I know the name of the device on the Network, could I get the application to compile a list of all the deices connected to the network and the check to see if the name of the device I am looking for is any of them?
  2. The second option would mean that the application could only connect automatically if the application was connected to the LAN side of the router, and therefore is not as favourable as the user would have to enter the IP of the router id they were trying to access from the WAN side. The way I would do it is simply get the default gateway of the router through the allocation somehow and then just send an API request to it and see if it replies (if it replies I can assume I have connected to the correct device).

So to sum up is that I either need a way to get the names + IPs of all the devices connected to the network I am on (that is the preferable solution) or a way to get the default gateway (router IP address).

I am very new to this, so please be over informative for me so that I understand. I would appreciate it if you could really explain how to implement this, maybe so that I can just have it print it out in the console - then I can implement it into my program and do what I need to do.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
cross
  • 363
  • 1
  • 4
  • 15

1 Answers1

0

Getting the router's IP is easy if you got IP from DHCP because your default router is the IP address of your router.

route print | find " 0.0.0.0"
Gábor
  • 371
  • 3
  • 8