内网穿透!如何配置frp新版0.56.0的配置文件.toml:提供web、samba、ssh远程连接示例

发布于:2024-04-19 ⋅ 阅读:(87) ⋅ 点赞:(0)

最新版本的frp在配置上与之前有很大不同,需要使用.toml文件进行配置。其中主要问题出现在toml文件内部。因此,本文将专门讨论这个问题。

一、服务端配置

下载并解压(以debian系统为例):

sudo apt update
sudo apt install wget
wget https://github.com/fatedier/frp/releases/download/v0.56.0/frp_0.56.0_linux_amd64.tar.gz
tar -xvf frp_0.56.0_linux_amd64.tar.gz
cd frp_0.56.0_linux_amd64

注意版本:服务系统版本(linux、windows)、硬件CPU版本(arm、amd等)对应的不是相同的文件。

配置文件frps.toml:

bindPort = 7000
vhostHTTPPort = 8080

其中vhostHTTPPort为http的监听,如果要使用https要设置vhostHTTPSPort

运行:

./frps -c ./frps.toml

随机自动启动:

  1. 创建服务文件: 在/etc/systemd/system/目录下创建一个名为frps.service的文件。

  2. 编辑服务文件: 编辑frps.service文件,内容如下:
     

    [Unit]
    Description=frps service
    After=network.target
    
    [Service]
    Type=simple
    ExecStart=/你的frps地址/frps -c /你的frps地址/frps.toml
    Restart=on-failure
    RestartSec=5s
    
    [Install]
    WantedBy=multi-user.target
    

    注意替换你的实际frps所在的路径

  3. 启动服务:

    systemctl enable frps.service
    systemctl start frps.service

  4. 检查服务状态:
     

    systemctl status frps.service

二、客户端配置:

        客户端安装同服务端,配置frpc.toml文件内容为:

serverAddr = "IP地址或域名"
serverPort = 7000

[[proxies]]
name = "web"
type = "http"
localPort = 80
customDomains = ["域名"]


[[proxies]]
name = "samba"
type = "tcp"
localIP = "127.0.0.1"
localPort = 445
remotePort = 4450

[[proxies]]
name = "ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 6000

运行及加入自动启动也参考服务端,唯一不同的是客户端运行需要使用frpc -c frpc.toml

配置文件中,samba和ssh指定的服务器端口remotePort记得一定要在服务器端放行!!

至此配置完成,远程打开ssh记得将22端口修改为6000,samba连接需要修改端口为4450。