FRP内网穿透

1.7k words

frp 是一个专注于内网穿透的高性能的反向代理应用,支持 TCP、UDP、HTTP、HTTPS 等多种协议。可以将内网服务以安全、便捷的方式通过具有公网 IP 节点的中转暴露到公网。frp提供跨平台的客户端与服务端,开源免费,地址:frp (github.com)

根据系统版本,下载不同的文件并解压如下:

image-20220330172447439

文件包括:

名称 说明
frpc 客户端执行程序
frpc.ini 客户端配置
frps 服务端执行程序
frps.ini 服务端配置

服务端使用

手动安装与配置

  1. 修改配置文件,详细配置参数请参考服务端配置 | frp (gofrp.org)

    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
    28
    29
    30
    31
    32
    33
    34
    35
    [common]
    # 绑定的IP与端口
    bind_addr = 0.0.0.0
    bind_port = 5000
    #用于接收采用 KCP 连接的 frpc
    #kcp_bind_port = 0
    #用于接收采用 HTTP\HTTPS 连接的 frpc
    #vhost_http_port = 0
    #vhost_https_port = 0

    # http、https类型的二级域名后缀
    #subdomain_host = test.com

    # web仪表盘端口,可以查看服务详情与已连接的客户端
    dashboard_port = 5001
    # web仪表盘用户与密码
    dashboard_user = admin
    dashboard_pwd = admin

    # 日志级别 debug, info, warn, error | 日志最大天数
    log_file = ./frps.log
    log_level = info
    log_max_days = 3

    #服务端返回详细错误信息给客户端
    detailed_errors_to_client = true

    # 验证码
    token = xxxxxxxxxxxxxxx

    # 客户端可以绑定的端口
    #allow_ports = 1-65535

    # if tcp stream multiplexing is used, default is true
    tcp_mux = true
  2. 启动程序

    1
    ./frps -c ./frps.ini		

一键安装

1
2
3
wget https://code.aliyun.com/MvsCode/frps-onekey/raw/master/install-frps.sh -O ./install-frps.sh
chmod 700 ./install-frps.sh
./install-frps.sh install

管理与配置:

1
/etc/init.d/frps {start|stop|restart|status|config|version}	

客户端使用

  1. 修改配置文件,详细配置参数请参考客户端配置 | frp (gofrp.org)

    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
    28
    [common]
    #frps服务端地址与通讯端口
    server_addr = 192.168.0.1
    server_port = 5000

    # 验证码
    token = xxxxxxxxxxxxxxx

    #设置为false,frpc连接frps失败后重连,默认为true不重连
    login_fail_exit = false

    #KCP协议在弱网环境下传输效率提升明显,但是对frps会有一些额外的流量消耗。服务端须先设置kcp_bind_port = 7000,www.yourdomain.com服务端已设置支持

    #连接服务端的通信协议 tcp, kcp, websocket
    protocol = tcp

    [SSH]
    #代理类型 tcp, udp, http, https, stcp, sudp, xtcp, tcpmux
    type = tcp
    local_ip = 127.0.0.1
    local_port = 22

    #压缩传输 | 加密传输
    use_compression = true
    use_encryption = true

    #tcp\udp绑定的服务端口
    remote_port = 6453
  2. 启动程序

    1
    ./frpc -c ./frpc.ini		

    直接访问 192.168.0.1:6453即可

Comments