Normally i can ping an IP programmatically.But it does not return that IP is in internet or intranet.I want to find whether the pinging IP is in internet or intranet.is there any way to find it.
Asked
Active
Viewed 599 times
0
-
1You can specify a range for your intranet addresses, all those which do not fall in that range would be internet IP Addresses. – Zo Has Feb 06 '14 at 11:25
-
I am really interested what the code will be if there are many different network with different subnet mask. – pmverma Feb 06 '14 at 11:26
2 Answers
1
You can not simply ping in Java as it relies on ICMP, which is sadly not supported in Java
http://mindprod.com/jgloss/ping.html
Use sockets instead
Hope it helps
Thanks to aretai for java code to ping an IP address
But I find sthg like that https://gist.github.com/madan712/4509039

Community
- 1
- 1

Semih Eker
- 2,389
- 1
- 20
- 29
0
What you can tell is whether the IP address is a "private range" address, this is an address in a range which is not valid for use on the public internet and specifically meant for intranet use. For example any address in the range 192.168.* or 10.*.
You can do this using the InetAddress.isSiteLocal() method. Of course if your company doesn't use private range IP addresses for its intranet, this is not going to work.

Pepijn Schmitz
- 2,143
- 1
- 17
- 18