frp 配置过程排雷记录

# (code=exited, status=203/EXEC) (code=exited, status=1/FAILURE)

## 尝试ln -s,发现不行,后面可以试试ln -d ?

ln -s /root/frp_0.34.3_linux_arm64/systemd/frps.service /etc/systemd/system/frps.service
ln -s /root/frp_0.34.3_linux_arm64/frps /usr/bin/frps

(code=exited, status=203/EXEC)

ln -s /root/frp_0.34.3_linux_arm64/frps.ini /etc/frp/frps.ini

(code=exited, status=1/FAILURE)

解决方法,直接复制文件,而不是ln -s

root cause:

SELinux prevents you from running a system service where the binary is in a user’s home directory, or in your case, the root user’s home directory.

To fix the problem, copy the binary to a proper directory such as /usr/local/bin and call it from there.

ref: https://serverfault.com/questions/957084/failed-at-step-exec-spawning-permission-denied

## 然后还有(code=exited, status=1/FAILURE)

这次现象:

若执行如下comand,正常

systemctl daemon-reload && systemctl start frps.service && systemctl status frps.service

但继续执行如下cmd,异常

systemctl status frps.service

直接运行如下cmd 正常

/root/frp_0.34.3_linux_arm64/frps -c /root/frp_0.34.3_linux_arm64/frps.ini

如下cmd查看log

journalctl -xe
-- The start-up result is done.
Dec 14 10:08:58 server dhclient[5124]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11
Dec 14 10:08:58 server frps[8371]: Create server listener error, listen tcp 0.0.0.0:731: bind: permission deni
Dec 14 10:08:58 server systemd[1]: frps.service: Main process exited, code=exited, status=1/FAILURE
Dec 14 10:08:58 server systemd[1]: frps.service: Unit entered failed state.
Dec 14 10:08:58 server systemd[1]: frps.service: Failed with result 'exit-code'.

参考如下链接尝试:

https://blog.csdn.net/zhusheng258/article/details/83655941

bind_addr = 0.0.0.0

无效,垃圾csdn。

最后发现root cause:

部分系统限制了非 root 账户不能绑定 1024 以下的端口。

这样你的 frps 就可以绑定 1~1023 这些端口 (Privileged Ports) 了

解决方法:

配置文件增加这句

AmbientCapabilities=CAP_NET_BIND_SERVICE

完整配置如下

[Unit]
Description=Frp Server Service
After=network.target

[Service]
Type=simple
User=nobody
Restart=on-failure
RestartSec=5s
ExecStart=/usr/bin/frps -c /etc/frp/frps.ini
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

ref:  https://github.com/fatedier/frp/issues/1493

# client config

ln -s /root/frp_0.34.3_linux_amd64/systemd/frpc.service /etc/systemd/system/frpc.service
cp /root/frp_0.34.3_linux_amd64/frpc /usr/bin/frpc
mkdir -p /etc/frp && cp /root/frp_0.34.3_linux_amd64/frpc.ini /etc/frp/frpc.ini
systemctl daemon-reload && systemctl start frpc.service && systemctl status frpc.service

最后的配置:

图片[1]-frp 配置过程排雷记录-今天我都干啥了图片[2]-frp 配置过程排雷记录-今天我都干啥了图片[3]-frp 配置过程排雷记录-今天我都干啥了

官网docs

https://gofrp.org/docs/examples/stcp/

© 版权声明
THE END
在时间中留下我的脚印
分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情图片

    暂无评论内容