Frp内网穿透教程记录

Lan
Lan
2021-02-10 / 0 评论 / 623 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2021年02月10日,已超过1170天没有更新,若内容或图片失效,请留言反馈。

没啥用的前言

很久很久以前从学校那嫖了台服务器,可惜是内网的,但是总比没有好啦,那时候一直觉得内网映射很麻烦,遥不可及,然后也就一直没有去弄。

这两天看了一个帖子《利用腾讯轻量服务器搭建FRP服务》然后试了一下。

需要准备的东西

  1. 带公网IP的服务器一台:https://gitlab.com/Vastsa/lanpicbed/-/raw/master/post/443.html

  2. Frp安装包:https://github.com/fatedier/frp/releases/tag/v0.35.1(根据自己的系统选择下载)

步骤

服务器下载FRP,并解压,因为我用了宝塔,所以不需要使用指令了,但还是演示一下指令的吧

  1. 先新建一个目录:
    mkdir /FRP
    cd /FRP

  2. 远程下载压缩包,我是centos
    wget https://github.com/fatedier/frp/releases/download/v0.35.1/frp_0.35.1_linux_amd64.tar.gz

  3. 解压然后cd过去
    tar -zxvf frp_0.35.1_linux_amd64.tar.gz

    cd frp_0.35.1_linux_amd64/

  4. 编写配置文件
    vim frps.ini
    vim使用方法:https://gitlab.com/Vastsa/lanpicbed/-/raw/master/post/178.html

[common]
#frp服务器监听地址,如果是IPV6地址必须用中括号包围
bind_addr = 0.0.0.0
#frp服务器监听端口
bind_port = 7000
 
#kcp的udp监听端口,如果不设那就不启用
#kcp_bind_port = 7000
#指定使用的协议,默认tcp,可选kcp
#protocol = kcp
 
#如果要使用vitual host,就必须设置
#vhost_http_port = 80
#vhost_https_port = 443
 
#Web后台监听端口
dashboard_port = 1500
 
#Web后台的用户名和密码
dashboard_user = lan
dashboard_pwd = lanol
 
#Web后台的静态资源目录,调试用的,一般不设
#assets_dir = ./static
 
#日志输出,可以设置为具体的日志文件或者console
log_file = /var/log/frps.log
 
#日志记录等级,有trace, debug, info, warn, error
log_level = info
#日志保留时间
log_max_days = 3
 
#启用特权模式,从v0.10.0版本开始默认启用特权模式,且目前只能使用特权模式
privilege_mode = true
 
#特权模式Token,请尽量长点且复杂
privilege_token = lanol

#客户端连接需要的token,很重要
token = lanol

#特权模式允许分配的端口范围
privilege_allow_ports = 9000-10000
 
#心跳超时,不用改
#heartbeat_timeout = 90
 
#每个代理可以设置的连接池上限
#max_pool_count = 5
 
#认证超时时间,一般不用改
#authentication_timeout = 900
 
#如果配置了这个,当你的模式为http或https时,就能设置子域名subdomain
#subdomain_host = frps.com
 
#是否启用tcp多路复用,默认就是true,不用管
#tcp_mux = true

    5.设置开机启动
        vim /usr/lib/systemd/system/frp.service

[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
ExecStart=/你的Frp路径/frps -c /你的Frp路径/frps.ini
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
StandardOutput=syslog
StandardError=inherit

[Install]
WantedBy=multi-user.target

        systemctl daemon-reload
        systemctl enable frp
        systemctl start frp

    6.客户端配置就是修改那个frpc.ini文件,启动也是启动frpc

[common]
server_addr = 服务端IP
server_port = 服务端口
token = 服务端token

[任务名称]
type = tcp
local_ip = 本地IP(127.0.0.1)
local_port = 本地端口(20)
remote_port = 远程端口(9000)


1

评论 (0)

取消