内网穿透!如何配置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。

相关推荐
SkyWalking中文站1 天前
认识 Horizon UI · 6/17:Trace 探索器
运维·监控·自动化运维
火车叼位1 天前
写给初级开发者:SSL、SSH、HTTPS 与证书体系全解析
运维
小猿姐2 天前
唯品会大规模数据库云原生实践:基于 KubeBlocks 管理数千实例的统一运维之路
运维·elasticsearch·云原生
SkyWalking中文站2 天前
认识 Horizon UI · 5/17:3D 基础设施地图
运维·监控·自动化运维
SkyWalking中文站3 天前
认识 Horizon UI · 1/17:SkyWalking 新一代可观测性控制台
运维·前端·监控
雪梨酱QAQ3 天前
Kubeneters HA Cluster部署
运维
江华森4 天前
Spring Cloud 微服务全栈实战:从 Eureka 到 Docker Compose 一文贯通
运维
江华森4 天前
Matplotlib 数据绘图基础入门
运维
江华森4 天前
NumPy 数值计算基础入门
运维
乘云数字DATABUFF8 天前
5分钟部署开源APM Databuff:OpenTelemetry全链路追踪入门实战
运维·后端