I want to ping an IP via Java. When I ping from command line and track the network packages I see ICMP requests. When I ping from my application and track the network packages I see TCP requests at port 7.
I've checked the documentation of InetAddress.isReachable()
:
Best effort is made by the implementation to try to reach the host, but firewalls and server configuration may block requests resulting in a unreachable status while some specific ports may be accessible.
A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host.
I can run sudo needed commands with the user that I run my Java application.
Which privilege should be obtained for my purpose? What should I check?
PS: I've asked this question at stackoverflow.com because of it is more related to Java problem(which Java source code requires to run) than a system problem.