Java InetAddress isReachable ICMP (Ping)

It doesn't do ICMP on Windows, it opens TCP echo on port 7.

On linux/unix you have to set the suid bit on Java executables to allow it to use ICMP.


So that article didn't clearly explain the whole story.

When the executable bit is set if a user has permissions to run the program the executable runs at permissions of the owner. If like mine, your java was owned by account with non-root privileges, it still won't be able to access ICMP. You have to set suid bit after changing ownership as the latter clears the suid bit.

sudo chown -R root:root
sudo chmod 4755 /bin/java

Never did get this to work because once the suid bit was set, encountered the following error: libjli.so file not found. I believe this might have to do with suid bit not being set on LD_LIBRARY_PATH references and/or shared libs because it might present a security issue.

After discussing with associates realized going this route is probably a bad idea. This would cause all Java programs to run as root presenting a large security risk. It is a far better idea to run any program that requires this with sudo which works BTW.

Comments

Popular posts from this blog

Oracle JDBC ReadTimeout QueryTimeout

ActiveMQ https

Generically load enum mapping via properties file