static void pingTestAndUpdate(String ip) throws UnknownHostException, IOException {
//Check if pingable
boolean reachable = false;
reachable = InetAddress.getByName(ip).isReachable(200);
String status;
if (reachable == true) {
status = "Responding";
}
else if (reachable == false) {
status = "Not responding";
}
else {
status = "Error";
}
System.out.println(ip + " is: " + status);
}
The output is:
10.130.72.247 is: Not responding
If I ping the same IP address from the command line, I get:
Pinging 10.130.72.247 with 32 bytes of data:
Reply from 10.130.72.247 bytes=32 time=1ms TTL=128
Reply from 10.130.72.247 bytes=32 time=1ms TTL=128
Reply from 10.130.72.247 bytes=32 time=1ms TTL=128
Reply from 10.130.72.247 bytes=32 time=1ms TTL=128
Ping statistics for 10.130.72.247:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss).
Approximate round trip times in milliseconds:
Minimum = 1ms, Maximum = 1ms, Average = 1ms
I think this is a issue to do with the subnet 255.255.252.0 we have but I can't find an easy way to solve this, can anyone help me?
static void pingTestAndUpdate(String ip) throws UnknownHostException, IOException {
//To Check if pingable
boolean reachable;
reachable = InetAddress.getByName(ip).isReachable(200);
System.out.println(ip + " is: " + reachable);
}
This returns false but a ping from cmd to the same address is successful. The result should be true but is currently false even though the address is reachable.