Linux FRP新版内网穿透配置

### 1. 下载安装
cd /root
mkdir frp
wget https://github.com/fatedier/frp/releases/download/v0.61.0/frp_0.61.0_linux_amd64.tar.gz
tar -zxvf frp_0.61.0_linux_amd64.tar.gz --strip-components 1 -C /root/frp

2. frp后台服务自动启动

进入 /etc/systemd/system/ 目录建立新的文件 frps.service 配置成Systemd服务

[collapse title="服务端frps:nano /lib/systemd/system/frps.service" status="false"]

[Unit] 
Description=frps service 
After=network.target 

[Service] Restart=on-failure RestartSec=5s ExecStart=/root/frp/frps -c /root/frp/frps.toml

[Install] WantedBy=multi-user.target

[/collapse]

[collapse title="客户端frpc:nano /lib/systemd/system/frpc.service" status="false"]

[Unit] 
Description=frpc service 
After=network.target syslog.target
Wants=network.target

[Service] type=simple ExecStart=/root/frp/frpc -c /root/frp/frpc.toml

[Install] WantedBy=multi-user.target

[/collapse]

3. 配置

[collapse title="服务端frps配置,删除文字,不然出错" status="false"]

端口
bindAddr = "0.0.0.0"
bindPort = 7000

验证方式 auth.method = “token” auth.token = “123456”

Web 界面 webServer.addr = “0.0.0.0” webServer.port = 7500 webServer.user = “admin” webServer.password = “admin” webServer.tls.certFile = “qjfyx.crt” webServer.tls.keyFile = “qjfyx.key”

日志 log.to = “/root/frp/frps.log”
log.level = “info”
log.maxDays = 3
log.disablePrintColor = false

端口白名单 allowPorts = [ { start = 4000, end = 5000 }, { single = 5000 }, { single = 5001 } ]

[/collapse]

[collapse title="客户端frpc配置" status="false"]

serverAddr = "1.2.3.4"
serverPort = 7000
auth.token = "123456"

webServer.addr = “0.0.0.0” webServer.port = 8000 webServer.user = “admin” webServer.password = “admin”

[[proxies]] name = “web01”
type = “https” customDomains = [“nas.qjfyx.com”] localIP = “192.168.1.6” localPort = 5001

[[proxies]] name = “tcp” type = “tcp” localIP = “192.168.1.6” localPort = 5000

[/collapse]

4. 管理命令

  • frps启动:systemctl start frps
  • frps重启自启动:systemctl enable frps
  • frps重启应用:systemctl restart frps
  • frps停止应用:systemctl stop frps
  • frps查看应用的日志:systemctl status frps
  • frpc启动:systemctl start frpc
  • frpc重启自启动:systemctl enable frpc
  • frpc重启应用:systemctl restart frpc
  • frpc停止应用:systemctl stop frpc
  • frpc查看应用的日志:systemctl status frpc