telnet: connect to address xx: No route to host

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/xyjincan/article/details/78517289

telnet: connect to address xx: No route to host

可以ping通
telnet: connect to address xx: No route to host
以及
mysql 连不上,navicat报错
是因为被默认的防火墙拦截了

[xx@centos7 ~]telnetcompute13306Trying192.168.126.35telnet:connecttoaddress192.168.126.35:Noroutetohost[xx@centos7 ] telnet compute1 22
Trying 192.168.126.35…
Connected to compute1.
Escape character is ‘^]’.
SSH-2.0-OpenSSH_7.4
^C^C
Connection closed by foreign host.

2、CentOS 7 用firewall-cmd来开放端口
如:
firewall-cmd - -permanent - -add-port=3306/tcp

重新加载
firewall-cmd - -reload

确认是否开放
firewall-cmd - -list-all


http://blog.csdn.net/zhouygjp/article/details/50592699

展开阅读全文

java.net.NoRouteToHostException: No route to host: connect

06-25

项目之前好好的,今天突然报错,2台电脑,一台是我电脑,一台是数据库,ping也ping的通,防火墙什么的也关了,可还是不行,我电脑要说有什么改动也就是中间重做系统了,跟这个难道有关系?rn[code=java]java.net.NoRouteToHostException: No route to host: connect rn at java.net.PlainSocketImpl.socketConnect(Native Method) rn at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) rn at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) rn at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) rn at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) rn at java.net.Socket.connect(Socket.java:519) rn at java.net.Socket.connect(Socket.java:469) rn at java.net.Socket.(Socket.java:366) rn at java.net.Socket.(Socket.java:240) rn at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:79) rn at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:121) rn at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:706) rn at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1321) rn at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:386) rn at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170) rn at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396) rn at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324) rn at cn.com.jit.assp.ias.http.HttpServerStatusChecker.isAlive(HttpServerStatusChecker.java:81) rn at cn.com.jit.assp.ias.sp.saml11.config.util.GatewayList.syncGateway(GatewayList.java:78) rn at cn.com.jit.assp.ias.sp.saml11.config.util.GatewayTimerTask.run(GatewayTimerTask.java:41) rn at java.util.TimerThread.mainLoop(Timer.java:512) rn at java.util.TimerThread.run(Timer.java:462) rn[/code] 论坛

sendto的问题(no route to host)

07-24

本人写了段网络程序,其中在无限循环中调用了函数sendto,在向对方发送udp包的过程中,有时能够发送成功,有时却失败,错误号为113,错误原因为no route to host,下面是具体代码,向大侠请教错误原因rnrnrn/*rn * 在向对方的g_rport端口发送udp包的同时,还要不断监听本机的g_rport端口rn */rnvoid send_hb_udp_msg()rnrn int ret;rn int sockfd;rn int servfd;rn char msg[512];rn struct sockaddr_in toaddr, servaddr;rnrn sockfd = socket(AF_INET, SOCK_DGRAM, 0); //发送socketrn if (sockfd < 0)rn rn wlog(log_die, "%s(%d)[%s], errno %d, %s",__FILE__, __LINE__, __FUNCTION__, errno, strerror(errno));rn rn rn bzero(&toaddr, sizeof(toaddr));rn toaddr.sin_family = AF_INET;rn toaddr.sin_addr.s_addr = htonl(inet_addr(slave_ip)); //对方iprn toaddr.sin_port = htons(g_rport);rnrn rn servfd = socket(AF_INET, SOCK_DGRAM, 0); //接收socketrn if (servfd < 0)rn rn wlog(log_die, "%s(%d)[%s], errno %d, %s",__FILE__, __LINE__, __FUNCTION__, errno, strerror(errno));rn rnrn bzero(&servaddr, sizeof(servaddr));rn servaddr.sin_family = AF_INET;rn servaddr.sin_addr.s_addr = htonl(INADDR_ANY);rn servaddr.sin_port = htons(g_rport);rn rn rn ret = bind(servfd, (struct sockaddr *)&servaddr, sizeof(servaddr)); //接收socket绑定本地地址对rn if (ret == -1)rn rn wlog(log_die, "%s(%d)[%s], errno %d, %s",__FILE__, __LINE__, __FUNCTION__, errno, strerror(errno));rn rn rn //get host name;rn char hostname[32];rn gethostname(hostname, sizeof(hostname));rnrn fd_set rset;rn FD_ZERO(&rset);rn FD_SET(servfd, &rset);rnrn while(1)rn rn snprintf(msg, sizeof(msg), "%s,%d,%d", hostname, server_status, random_num);rn rn ret = sendto(sockfd, msg, strlen(msg), 0,(struct sockaddr *)&toaddr, sizeof(toaddr));[color=#FF0000][/color]rn rn if (ret == -1)rn rn wlog(log_info, "errno:%d, %s", errno, strerror(errno));rn continue;rn rn rn struct timeval tv;rn tv.tv_sec = 1;rn tv.tv_usec = 0; rnrn ret = select(1, &rset, NULL, NULL, &tv);rn if (ret == -1)rn rn wlog(log_die, "errno %d, %s", errno, strerror(errno));rn rn else if (FD_ISSET(servfd, &rset)) rn rn // 省略rn rn rn 论坛

java.net.SocketException: No route to host报错

07-09

新手求教,报错LOG如下:rnjava.net.SocketException: No route to hostrnat org.apache.harmony.luni.platform.OSNetworkSystem.connect(Native Method)rnat dalvik.system.BlockGuard$WrappedNetworkSystem.connect(BlockGuard.java:357)rnat org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:207)rnat org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:440)rnat java.net.Socket.connect(Socket.java:1013)rnat org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.(HttpConnection.java:75)rnat org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.(HttpConnection.java:48)rnat org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322)rnat org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)rnat org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285)rnat org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)rnat org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:205)rnrn报错的代码段:rn[code=java]URL url = new URL(validateUrl);rnconn = (HttpURLConnection) url.openConnection();rnconn.setConnectTimeout(5000);rnconn.setRequestMethod("GET"); // 请求格式rnconn.connect();//在这报错[/code]rn手机移动网开着呢, 也加上了。rn[b]出现这种情况一般是什么问题啊?[/b] 论坛

没有更多推荐了,返回首页