wget https://github.com/fatedier/frp/releases/download/v0.59.0/frp_0.59.0_linux_amd64.tar.gz
tar zxvf frp_0.59.0_linux_amd64.tar.gz && chown -R root:root frp_0.59.0_linux_amd64 && mv frp_0.59.0_linux_amd64 /opt/frp
编辑配置文件frps.toml
cat>/opt/frp/frps.toml<<EOF
#端口
bindPort = 10086
#验证方式
auth.method = "token"
auth.token = "xxxx-1111"
#后台管理端口、用户以及密码
webServer.addr = "0.0.0.0"
webServer.port = 10010
webServer.user = "admin"
webServer.password = "admin"
EOF
创建SystemD文件
cat>/lib/systemd/system/frps.service<<EOF
[Unit]
Description=frp is a fast reverse proxy that allows you to expose a local server located behind a NAT or firewall to the Internet.
ConditionFileIsExecutable=/opt/frp/frps
[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/opt/frp/frps -c /opt/frp/frps.toml
Restart=always
RestartSec=120
[Install]
WantedBy=multi-user.target
EOF
防火墙设置、启动并设置开机自启
systemctl daemon-reload && systemctl enable --now frps
firewall-cmd --zone=public --permanent --add-port=10086/tcp --add-port=10010/tcp && firewall-cmd --reload
编辑配置文件frpc.toml
cat>/opt/frp/frpc.toml<<EOF
#服务端地址以及端口
serverAddr = "123.123.123.123"
serverPort = 10086
#验证方式需与服务端一致
auth.method = "token"
auth.token = "xxxx-1111"
#需要的转发的服务,以openVPN为例
[[proxies]]
name = "ovpn"
type = "udp"
localIP = "127.0.0.1"
localPort = 1194
#服务端需开启对应的端口
remotePort = 1194
EOF
创建SystemD文件
cat>/lib/systemd/system/frpc.service<<EOF
[Unit]
Description=frp is a fast reverse proxy that allows you to expose a local server located behind a NAT or firewall to the Internet.
ConditionFileIsExecutable=/opt/frp/frpc
[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/opt/frp/frpc -c /opt/frp/frpc.toml
Restart=always
RestartSec=120
[Install]
WantedBy=multi-user.target
EOF
开机启动
systemctl daemon-reload && systemctl enable --now frpc