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?
Asked
Active
Viewed 8,032 times
1 Answers
4
- Get your LAN IP address,
- Build IP addresses starting from your LAN IP as 192.168.0.1
- Go through all 192.168.0.X (0-255) possibilities.
- Ping (Java's
isReachable
) the possible IP address and print it if it's reachable.

Anton Antonov
- 1,217
- 2
- 14
- 21
-
1Your answer depends on the user's subnet being a /24 which may be a bad assumption. It would be better to determine the subnet size, first and last host address, and try from first to last host address. Also, don't even attempt this with IPv6 which uses /64 subnets; the universe will have ended in heat death long before you are through scanning the subnet. – Ron Maupin Mar 03 '15 at 23:12
-
Minus 1. The code does not return any results, unlike "Angry IP Scanner" or "Advanced IP Scanner" – BullyWiiPlaza Sep 17 '15 at 15:50
-
I was able to write my own scanner and I found 2 computers in my network :) I based on the description, not the included link. – Fenio Jan 10 '17 at 20:33