[GH-ISSUE #1789] 通过systemd无法穿透成功,但直接启动可以正常工作 #1415

Closed
opened 2026-05-05 12:53:41 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @KatyushaScarlet on GitHub (May 2, 2020).
Original GitHub issue: https://github.com/fatedier/frp/issues/1789

Issue is only used for submiting bug report and documents typo. If there are same issues or answers can be found in documents, we will close it directly.

Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST

What version of frp are you using (./frpc -v or ./frps -v)?
0.33.0

What operating system and processor architecture are you using (go env)?
frpc: Debian GNU/Linux 10 x86_64
frps: Debian GNU/Linux 10 x86_64

Configures you used:
frpc.ini:
[common]
server_addr = x.x.x.x
server_port = 10000

tcp_mux = true
tls_enable = true

authentication_method = token
auto_token = xxxxxxxx

[poste-25]
type = tcp
local_ip = 127.0.0.1
local_port = 10025
remote_port = 25

frps.ini:
[common]
bind_port = 10000

tcp_mux = true
tls_enable = true
tls_only = true

authentication_method = token
auto_token = xxxxxxxx

Steps to reproduce the issue:
1.systemctl start frpc
2.systemctl start frps or /usr/bin/frps -c /etc/frp/frps.ini

Describe the results you received:
通过systemctl start frps启动时,提示port unavaliable

May 02 12:41:41 xxxxx systemd[1]: Started Frp Server Service.
May 02 12:41:41 xxxxx frps[13407]: 2020/05/02 12:41:41 [I] [service.go:178] frps tcp listen on 0.0.0.0:10000
May 02 12:41:41 xxxxx frps[13407]: 2020/05/02 12:41:41 [I] [root.go:209] start frps success
May 02 12:41:48 xxxxx frps[13407]: 2020/05/02 12:41:48 [I] [service.go:432] [a466bccfd73973a0] client login info: ip [x.x.x.x:58818] version [0.33.0] host
May 02 12:41:48 xxxxx frps[13407]: 2020/05/02 12:41:48 [W] [control.go:441] [a466bccfd73973a0] new proxy [poste-25] error: port unavailable

Describe the results you expected:
通过/usr/bin/frps -c /etc/frp/frps.ini手动启动frps时,穿透正常

2020/05/02 12:42:08 [I] [service.go:178] frps tcp listen on 0.0.0.0:10000
2020/05/02 12:42:08 [I] [root.go:209] start frps success
2020/05/02 12:42:14 [I] [service.go:432] [487b86fa5db05c0b] client login info: ip [x.x.x.x:58852] version [0.33.0] hostname [] os [linux] arch [amd64]
2020/05/02 12:42:14 [I] [tcp.go:63] [487b86fa5db05c0b] [poste-25] tcp proxy listen port [25]
2020/05/02 12:42:14 [I] [control.go:445] [487b86fa5db05c0b] new proxy [poste-25] success

Additional information you deem important (e.g. issue happens only occasionally):
使用lsof或netstat查看,服务端与客户端相关端口均未被占用

Originally created by @KatyushaScarlet on GitHub (May 2, 2020). Original GitHub issue: https://github.com/fatedier/frp/issues/1789 Issue is only used for submiting bug report and documents typo. If there are same issues or answers can be found in documents, we will close it directly. Use the commands below to provide key information from your environment: You do NOT have to include this information if this is a FEATURE REQUEST **What version of frp are you using (./frpc -v or ./frps -v)?** 0.33.0 **What operating system and processor architecture are you using (`go env`)?** frpc: Debian GNU/Linux 10 x86_64 frps: Debian GNU/Linux 10 x86_64 **Configures you used:** frpc.ini: [common] server_addr = x.x.x.x server_port = 10000 tcp_mux = true tls_enable = true authentication_method = token auto_token = xxxxxxxx [poste-25] type = tcp local_ip = 127.0.0.1 local_port = 10025 remote_port = 25 frps.ini: [common] bind_port = 10000 tcp_mux = true tls_enable = true tls_only = true authentication_method = token auto_token = xxxxxxxx **Steps to reproduce the issue:** 1.systemctl start frpc 2.systemctl start frps or /usr/bin/frps -c /etc/frp/frps.ini **Describe the results you received:** 通过systemctl start frps启动时,提示port unavaliable May 02 12:41:41 xxxxx systemd[1]: Started Frp Server Service. May 02 12:41:41 xxxxx frps[13407]: 2020/05/02 12:41:41 [I] [service.go:178] frps tcp listen on 0.0.0.0:10000 May 02 12:41:41 xxxxx frps[13407]: 2020/05/02 12:41:41 [I] [root.go:209] start frps success May 02 12:41:48 xxxxx frps[13407]: 2020/05/02 12:41:48 [I] [service.go:432] [a466bccfd73973a0] client login info: ip [x.x.x.x:58818] version [0.33.0] host May 02 12:41:48 xxxxx frps[13407]: 2020/05/02 12:41:48 [W] [control.go:441] [a466bccfd73973a0] new proxy [poste-25] error: port unavailable **Describe the results you expected:** 通过/usr/bin/frps -c /etc/frp/frps.ini手动启动frps时,穿透正常 2020/05/02 12:42:08 [I] [service.go:178] frps tcp listen on 0.0.0.0:10000 2020/05/02 12:42:08 [I] [root.go:209] start frps success 2020/05/02 12:42:14 [I] [service.go:432] [487b86fa5db05c0b] client login info: ip [x.x.x.x:58852] version [0.33.0] hostname [] os [linux] arch [amd64] 2020/05/02 12:42:14 [I] [tcp.go:63] [487b86fa5db05c0b] [poste-25] tcp proxy listen port [25] 2020/05/02 12:42:14 [I] [control.go:445] [487b86fa5db05c0b] new proxy [poste-25] success **Additional information you deem important (e.g. issue happens only occasionally):** 使用lsof或netstat查看,服务端与客户端相关端口均未被占用
Author
Owner

@xqzr commented on GitHub (May 2, 2020):

根据frp的systemd配置默认使用nobody用户运行,而非root是不允许监听1024以下的端口。
所以,把frp的systemd配置里面的“User=nobody”和下面那行“G....=nobody”注释或者删除。
也可以把“remote_port”改成1024以上的端口。

<!-- gh-comment-id:622852682 --> @xqzr commented on GitHub (May 2, 2020): 根据frp的systemd配置默认使用nobody用户运行,而非root是不允许监听1024以下的端口。 所以,把frp的systemd配置里面的“User=nobody”和下面那行“G....=nobody”注释或者删除。 也可以把“remote_port”改成1024以上的端口。
Author
Owner

@KatyushaScarlet commented on GitHub (May 2, 2020):

根据frp的systemd配置默认使用nobody用户运行,而非root是不允许监听1024以下的端口。
所以,把frp的systemd配置里面的“User=nobody”和下面那行“G....=nobody”注释或者删除。
也可以把“remote_port”改成1024以上的端口。

已解决,感谢!

<!-- gh-comment-id:622862742 --> @KatyushaScarlet commented on GitHub (May 2, 2020): > 根据frp的systemd配置默认使用nobody用户运行,而非root是不允许监听1024以下的端口。 > 所以,把frp的systemd配置里面的“User=nobody”和下面那行“G....=nobody”注释或者删除。 > 也可以把“remote_port”改成1024以上的端口。 已解决,感谢!
Author
Owner

@kgggggb commented on GitHub (Aug 16, 2021):

根据frp的systemd配置默认使用nobody用户运行,而非root是不允许监听1024以下的端口。
所以,把frp的systemd配置里面的“User=nobody”和下面那行“G....=nobody”注释或者删除。
也可以把“remote_port”改成1024以上的端口。

systemctl遇到同样的问题,查了一下,setcap cap_net_bind_service=+eip 程序路径 example:
setcap cap_net_bind_service=+eip /etc/frps/frps
就可以了。
https://cwiki.apache.org/confluence/display/httpd/NonRootPortBinding

<!-- gh-comment-id:899838273 --> @kgggggb commented on GitHub (Aug 16, 2021): > 根据frp的systemd配置默认使用nobody用户运行,而非root是不允许监听1024以下的端口。 > 所以,把frp的systemd配置里面的“User=nobody”和下面那行“G....=nobody”注释或者删除。 > 也可以把“remote_port”改成1024以上的端口。 systemctl遇到同样的问题,查了一下,setcap cap_net_bind_service=+eip 程序路径 example: `setcap cap_net_bind_service=+eip /etc/frps/frps ` 就可以了。 [https://cwiki.apache.org/confluence/display/httpd/NonRootPortBinding](https://cwiki.apache.org/confluence/display/httpd/NonRootPortBinding)
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#1415
No description provided.