可以ping通,而InetAddress isReachable却返回false
来源:互联网 发布:软件售后维保 编辑:程序博客网 时间:2024/05/03 16:09
程序:
package xxx.xxx;
import org.junit.Test;
import java.io.IOException;
import java.net.InetAddress;
public class InetAddressTest {
@Test
public void testIsReachable() {
try {
System.out.println("testing................................");
System.out.println(InetAddress.getByName("xxx.xxx.xxx.xxx").isReachable(10));
} catch (IOException e) {
e.printStackTrace();
}
}
}
原因:
查看启动程序的账户为user,非root,而isReachable使用icmp实现此功能,需要root权限
参考:
http://stackoverflow.com/questions/4779367/problem-with-isreachable-in-inetaddress-class
(read the javadoc, it requires such privileges. Basically to use ICMP (raw socket), it does take 'root'. And if you ask why ping from bash doesn't, actually it does need as well. Do that ls -l /bin/ping)
0 0
- 可以ping通,而InetAddress isReachable却返回false
- Investigation of Why InetAddress.isReachable() Returning false
- ping域名ping不通,pingIP却可以
- 虚拟机可上外网,可ping通网关,但是ping不通主机,主机却可以ping通虚拟机
- 可以ping通本机,可以上网却ping不通同局域网别的机器解决方法
- Linux下可以PING通IP却PING不通域名怎么办?
- host-only模式下虚拟机ping不通主机 主机却可以ping通虚拟机 解决方案
- 在Extjs提交表单时,后端可以成功地执行操作,但返回给前端的却是false
- 加了DNS后,可以ping通外网,但是用浏览器却没办法打开这个可以ping通的网页
- 实体机可以ping通虚拟机,而虚拟机不可以ping通实体机
- 关于可以Ping通网站 却不能上网的一些解决办法
- 可以Ping通,却无法使用IE上网的几种可能性
- os.path.isdir() 判断文件夹却返回false
- PreparedStatement execute执行插入成功却返回false
- PreparedStatement execute执行插入成功却返回false
- 为什么PreparedStatement execute执行插入成功却返回false
- conn.excute()插入数据库成功,但却返回false原因
- 远程桌面连接可以,但却ping不通,怎么回事?
- HTML中上传与读取图片或文件(input file)----在路上(25)
- Mybatis判断的问题Integer
- Java动态编译执行
- The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
- 每天一个 Linux 命令(14):head 命令
- 可以ping通,而InetAddress isReachable却返回false
- 【Video】主流视频网站流媒体技术
- 使用Docker运行tensorflow进行隔离式的深度学习
- Android开发-自定义View-AndroidStudio(二十四)数独(1)
- 【数据结构与算法】ArrayList和LinkedList
- GIT 第一次 clone 异常
- spring常用注解
- java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
- BZOJ 3130 二分+网络流