Java ARP Scanner

2.2k views Asked by At

I need to write a java program, that gets all the computer network interfaces and scans for IP addresses and MAC addresses within the subnet.

I'm not exactly sure how to do that, but I found there's a method called:

Arping.scan(deviceName, network, mask, timeout);

Is it what I'm looking for? What does it return? There aren't a lot of comments, and I'm new to this, so I can't figure out myself. Please help!

1

There are 1 answers

3
Evan Sanderson On

public void checkHosts(String subnet){
   int timeout=1000;
   for (int i=1;i<254;i++){
       String host=subnet + "." + i;
       if (InetAddress.getByName(host).isReachable(timeout)){
           System.out.println(host + " is reachable");
       }
   }
}