Java simple Network IP-Adress Scanner

Broadwell picture Broadwell · Feb 28, 2015 · Viewed 7.4k times · Source

I want to make my own ip scanner, that scans available ips on the local network, like Angry IP Scanner would do it. I also want to get some basic device info, like the hostname. How would I solve that in Java? I don't want to use any libraries to do that. Should I just try to ping every available ip using a loop and see it it answers?

Answer

Anton Antonov picture Anton Antonov · Feb 28, 2015
  1. Get your LAN IP address,
  2. Build IP addresses starting from your LAN IP as 192.168.0.1
  3. Go through all 192.168.0.X (0-255) possibilities.
  4. Ping (Java's isReachable) the possible IP address and print it if it's reachable.

In code: https://github.com/syndbg/HackBulgaria/blob/master/Core-Java-1/13-Networking1/src/InternetUtils.java#L56