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

最新版本的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。

相关推荐
悟空空心22 分钟前
服务器长ping,traceroute
linux·服务器·网络·ssh·ip·ping++
Ghost Face...24 分钟前
Docker实战:从安装到多容器编排指南
运维·docker·容器
此生只爱蛋1 小时前
【Linux】正/反向代理
linux·运维·服务器
qq_5470261791 小时前
Linux 基础
linux·运维·arm开发
zfj3211 小时前
sshd除了远程shell外还有哪些功能
linux·ssh·sftp·shell
废春啊1 小时前
前端工程化
运维·服务器·前端
我只会发热1 小时前
Ubuntu 20.04.6 根目录扩容(图文详解)
linux·运维·ubuntu
爱潜水的小L1 小时前
自学嵌入式day34,ipc进程间通信
linux·运维·服务器
zhuzewennamoamtf2 小时前
Linux I2C设备驱动
linux·运维·服务器
梅尔文.古2 小时前
RaspberryPi-如何启用看门狗
linux·运维·服务器