[GH-ISSUE #689] [control.go:109] login to server failed: dial tcp XX.XX.XX.XX #538

Closed
opened 2026-05-05 12:21:04 -06:00 by gitea-mirror · 9 comments
Owner

Originally created by @bruce916 on GitHub (Apr 4, 2018).
Original GitHub issue: https://github.com/fatedier/frp/issues/689

frpc 客户端始终无法链接frps 服务器端,客户端报错。。[control.go:109] login to server failed: dial tcp XX.XX.XX.XX 。。。 connection failed because connected host has failed to respond

配置:阿里云服务器ubuntu/debian
frpc 配置内容:
[common]
server_addr = XX.XX.XX.XX
server_port = 7000
auth_token = 123
privilege_token = 12345678

[ssh]
privilege_mode = true
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000

frps配置内容:
[common]
bind_port = 7000
vhost_http_port = 80
vhost_https_port = 443
dashboard_port = 7500
privilege_mode = true
privilege_token = 12345678
privilege_allow_ports = 2000-3000,4000-50000
log_level= info

[ssh]
type = tcp
auth_token = 123
bind_addr = 0.0.0.0
listen_port = 6000

端口检查如下:
root@bruce:~# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 780/sshd
tcp6 0 0 :::443 :::* LISTEN 17442/frps
tcp6 0 0 :::7500 :::* LISTEN 17442/frps
tcp6 0 0 :::80 :::* LISTEN 17442/frps
tcp6 0 0 :::7000 :::* LISTEN 17442/frps
udp 0 0 172.31.62.13:123 0.0.0.0:* 710/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 710/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 710/ntpd
udp6 0 0 :::123 :::* 710/ntpd

端口对应防火墙均已打开:
root@bruce:~# ip6tables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all anywhere anywhere
ACCEPT tcp anywhere anywhere tcp dpt:ssh
ACCEPT tcp anywhere anywhere tcp dpt:https
ACCEPT tcp anywhere anywhere tcp dpt:http
ACCEPT all anywhere anywhere

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

但还是一直链接不上frps,怎么解决呢?

Originally created by @bruce916 on GitHub (Apr 4, 2018). Original GitHub issue: https://github.com/fatedier/frp/issues/689 frpc 客户端始终无法链接frps 服务器端,客户端报错。。[control.go:109] login to server failed: dial tcp XX.XX.XX.XX 。。。 connection failed because connected host has failed to respond 配置:阿里云服务器ubuntu/debian frpc 配置内容: [common] server_addr = XX.XX.XX.XX server_port = 7000 auth_token = 123 privilege_token = 12345678 [ssh] privilege_mode = true type = tcp local_ip = 127.0.0.1 local_port = 22 remote_port = 6000 frps配置内容: [common] bind_port = 7000 vhost_http_port = 80 vhost_https_port = 443 dashboard_port = 7500 privilege_mode = true privilege_token = 12345678 privilege_allow_ports = 2000-3000,4000-50000 log_level= info [ssh] type = tcp auth_token = 123 bind_addr = 0.0.0.0 listen_port = 6000 端口检查如下: root@bruce:~# netstat -tunlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 780/sshd tcp6 0 0 :::443 :::* LISTEN 17442/frps tcp6 0 0 :::7500 :::* LISTEN 17442/frps tcp6 0 0 :::80 :::* LISTEN 17442/frps tcp6 0 0 :::7000 :::* LISTEN 17442/frps udp 0 0 172.31.62.13:123 0.0.0.0:* 710/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 710/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 710/ntpd udp6 0 0 :::123 :::* 710/ntpd 端口对应防火墙均已打开: root@bruce:~# ip6tables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all anywhere anywhere ACCEPT tcp anywhere anywhere tcp dpt:ssh ACCEPT tcp anywhere anywhere tcp dpt:https ACCEPT tcp anywhere anywhere tcp dpt:http ACCEPT all anywhere anywhere Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination 但还是一直链接不上frps,怎么解决呢?
Author
Owner

@wxlg1117 commented on GitHub (Apr 4, 2018):

阿里云web管理页面有安全组设置,有可能默认block掉所有非22的流量了吧
你试试本地tcp ping你指定的端口试试通不通

<!-- gh-comment-id:378531983 --> @wxlg1117 commented on GitHub (Apr 4, 2018): 阿里云web管理页面有安全组设置,有可能默认block掉所有非22的流量了吧 你试试本地tcp ping你指定的端口试试通不通
Author
Owner

@poppingcode commented on GitHub (Apr 5, 2018):

ssh -oPort=6000 test@x.x.x.x
我想问问这个 test是哪里设置的用户名,以及这个x.x.x.x是什么东西?

<!-- gh-comment-id:378902561 --> @poppingcode commented on GitHub (Apr 5, 2018): ssh -oPort=6000 test@x.x.x.x 我想问问这个 test是哪里设置的用户名,以及这个x.x.x.x是什么东西?
Author
Owner

@nnfewl commented on GitHub (Apr 6, 2018):

test是你的公网VPS上的用户,后边那个是VPS的IP地址2333

<!-- gh-comment-id:379154003 --> @nnfewl commented on GitHub (Apr 6, 2018): test是你的公网VPS上的用户,后边那个是VPS的IP地址2333
Author
Owner

@poppingcode commented on GitHub (Apr 6, 2018):

不对啊,我是从公网连接到内网,怎么是VPS上的用户呢?

<!-- gh-comment-id:379176532 --> @poppingcode commented on GitHub (Apr 6, 2018): 不对啊,我是从公网连接到内网,怎么是VPS上的用户呢?
Author
Owner

@nnfewl commented on GitHub (Apr 6, 2018):

2333,我脑抽了,test应该是你内网机器的帐号,sorry

<!-- gh-comment-id:379186933 --> @nnfewl commented on GitHub (Apr 6, 2018): 2333,我脑抽了,test应该是你内网机器的帐号,sorry
Author
Owner

@fatedier commented on GitHub (Apr 9, 2018):

连接不上请仔细仔细再仔细地排查下自己的网络环境。

<!-- gh-comment-id:379813011 --> @fatedier commented on GitHub (Apr 9, 2018): 连接不上请仔细仔细再仔细地排查下自己的网络环境。
Author
Owner

@nyhpro commented on GitHub (Apr 12, 2018):

这个TCP 应该是VPS上的防火墙没有打开吧

<!-- gh-comment-id:380674795 --> @nyhpro commented on GitHub (Apr 12, 2018): 这个TCP 应该是VPS上的防火墙没有打开吧
Author
Owner

@ghwyf commented on GitHub (Sep 4, 2018):

This is because you haven't open port on the server side.
You should close firewall OR add bind_port and vhost_http_port into /etc/sysconfig/iptables.

这个问题是由于服务端的端口被防火墙拦截导致的,你可以关闭防火墙或者在防火墙中允许bind_portvhost_http_port的端口。

linux:
vi /etc/sysconfig/iptables
开放端口
-A INPUT -p tcp -m state --state NEW -m tcp --dport bind_port -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport vhost_http_port -j ACCEPT
注意,这两行必须加在以下代码之上,否则规则会被拦截。
-A INPUT -j REJECT --reject-with icmp-host-prohibited

重启防火墙service iptables restart, 可能会对shadowsock产生影响。

或者先关闭防火墙测试连接是否可行 service iptables stop

<!-- gh-comment-id:418255228 --> @ghwyf commented on GitHub (Sep 4, 2018): This is because you haven't open port on the server side. You should close firewall OR add `bind_port` and `vhost_http_port` into /etc/sysconfig/iptables. 这个问题是由于服务端的端口被防火墙拦截导致的,你可以关闭防火墙或者在防火墙中允许`bind_port` 和 `vhost_http_port`的端口。 linux: `vi /etc/sysconfig/iptables` 开放端口 `-A INPUT -p tcp -m state --state NEW -m tcp --dport bind_port -j ACCEPT` `-A INPUT -p tcp -m state --state NEW -m tcp --dport vhost_http_port -j ACCEPT` 注意,这两行必须加在以下代码之上,否则规则会被拦截。 `-A INPUT -j REJECT --reject-with icmp-host-prohibited` 重启防火墙`service iptables restart`, 可能会对shadowsock产生影响。 或者先关闭防火墙测试连接是否可行 `service iptables stop`
Author
Owner

@mlmk6698 commented on GitHub (Dec 17, 2023):

我发现了,校园网穿不出去

<!-- gh-comment-id:1859029572 --> @mlmk6698 commented on GitHub (Dec 17, 2023): 我发现了,校园网穿不出去
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#538
No description provided.