• frp:开源内网穿透工具


    前言

    frp 是一个专注于内网穿透的高性能的反向代理应用,支持 TCP、UDP、HTTP、HTTPS 等多种协议。可以将内网服务以安全、便捷的方式通过具有公网 IP 节点的中转暴露到公网。

    官网GitHub:https://github.com/fatedier/frp
    官网文档:https://gofrp.org/docs/

    下载与安装

    安装包:https://github.com/fatedier/frp/releases
    以Ubuntu为例,执行命令下载:

    wget https://github.com/fatedier/frp/releases/download/v0.44.0/frp_0.44.0_linux_amd64.tar.gz
    
    • 1

    执行命令解压:

    tar -zxvf frp_0.44.0_linux_amd64.tar.gz
    
    • 1

    客户端(公网IP设备):保留文件 frpsfrps.ini
    服务端(局域网设备):保留文件 frpcfrpc.ini

    服务端配置

    [common]
    bind_port = 8888
    token = this_is_your_token
    
    dashboard_port = 10000
    dashboard_user = username
    dashboard_pwd = password
    
    vhost_http_port = 12888
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    配置完成后,服务端完成了这些事情:

    • 配置了 frp 服务监听端口 8888
    • 配置了访问秘钥为 “this_is_your_token”
    • 配置了 dashboard 的 port、用户名、密码,访问公网IP:10000,输入用户名密码即可登陆后台
    • 配置了监听 12888 端口代理 http 请求

    快速启动服务端,执行:

    ./frps -c ./frps.ini
    
    • 1

    更多配置,详见:https://gofrp.org/docs/reference/server-configures/

    客户端配置

    [common]
    # 公网IP和服务端监听端口,以及连接秘钥
    server_addr = 188.188.188.188 
    server_port = 8888
    token = this_is_your_token
    
    [ssh_local]
    type = tcp
    local_ip = 127.0.0.1
    local_port = 22
    remote_port = 10099
    
    [static_file]
    type = tcp
    remote_port = 11099
    plugin = static_file
    # 要对外暴露的文件目录
    plugin_local_path = /home/xxxx/xxx/share
    # 用户访问 URL 中会被去除的前缀,保留的内容即为要访问的文件路径
    plugin_strip_prefix = static
    plugin_http_user = uuuuuuusername
    plugin_http_passwd = ppppppppassword
    
    [web_01]
    type = http
    local_port = 12888
    custom_domains = www.fuck.cn
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    配置完成后,服务端完成了这些事情:

    • common:把服务端的IP、监听端口告诉客户端,然后配置好秘钥以顺利连接
    • ssh_local:ssh连接,访问公网IP:10099 即可转发到内网机器22端口
    • static_file:公开文件,访问公网IP:11099 输入user和password就可访问共享文件
    • web_01:http映射,访问www.fuck.cn:12888 即可发起内网IP:12888 的HTTP请求

    快速启动客户端,执行:

    ./frpc -c ./frpc.ini
    
    • 1

    注意:应配置防火墙放通上述端口。

    开机自启

    使用 systemd 来控制 frps,需要先安装 systemd,然后在 /etc/systemd/system 目录下创建一个 frps.service 文件,写入以下内容:

    [Unit]
    # 服务名称,可自定义
    Description = frp server
    After = network.target syslog.target
    Wants = network.target
    
    [Service]
    Type = simple
    # 启动frps的命令,需修改为您的frps的安装路径
    ExecStart = /path/to/frps -c /path/to/frps.ini
    
    [Install]
    WantedBy = multi-user.target
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    管理frp服务:

    # 启动frp
    systemctl start frps
    # 停止frp
    systemctl stop frps
    # 重启frp
    systemctl restart frps
    # 查看frp状态
    systemctl status frps
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    配置 frps 开机自启:

    systemctl enable frps
    
    • 1
  • 相关阅读:
    asp.net课程设计司库管理系统-金融理财管理系统
    expect自动化交互应用程序工具
    四旋翼无人机的飞行原理--【其利天下分享】
    JVM垃圾回收算法
    Kubesphere之部署MySQL
    面试算法29:排序的循环链表
    Flink Window&Time 原理
    如何封装安全的go
    C语言 位操作
    搭建HBase分布式集群
  • 原文地址:https://blog.csdn.net/muyao987/article/details/125996811