FRPS内网穿透搭建

469 阅读3分钟

服务端搭建

可以使用一键服务端安装命令 Github地址

#下载一键安装脚本
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

连接主机...
连接主机成功
Last login: Fri May  6 13:03:51 2022 from 218.108.32.98
        
        Welcome to Huawei Cloud Service


[root@ecs-x-large-4-linux-20200316122328 /]# wget wget https://code.aliyun.com/MvsCode/frps-onekey/raw/master/install-frps.sh -O ./install-frps.sh
Resolving code.aliyun.com (code.aliyun.com)... 47.98.49.44
Connecting to code.aliyun.com (code.aliyun.com)|47.98.49.44|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: ‘./install-frps.sh’

    [ <=>                                                                                                                                                                            ] 38,090      --.-K/s   in 0.01s   

2022-05-07 13:18:46 (2.64 MB/s) - ‘./install-frps.sh’ saved [38090]

+------------------------------------------------------------+
|   frps for Linux Server, Author Clang ,Mender MvsCode     |
|      A tool to auto-compile & install frps on Linux        |
+------------------------------------------------------------+

Check updates for shell...

+------------------------------------------------------------+

+------------------------------------------------------------+
|   frps for Linux Server, Author Clang ,Mender MvsCode     |
|      A tool to auto-compile & install frps on Linux        |
+------------------------------------------------------------+


Please select frps download url:
[1].aliyun (default)
[2].github 
Enter your choice (1, 2 or exit. default [aliyun]): 1
-----------------------------------
       Your select: 1    
-----------------------------------
Loading network version for frps, please wait...
frps Latest release file frp_0.42.0_linux_amd64.tar.gz
Loading You Server IP, please wait...
You Server IP:xxxxx
————————————————————————————————————————————
     Please input your server setting:
————————————————————————————————————————————

Please input frps bind_port [1-65535](Default Server Port: 5443):
frps bind_port: 5443


Please input frps vhost_http_port [1-65535](Default : 80):8001
frps vhost_http_port: 8001


Please input frps vhost_https_port [1-65535](Default : 443):8453
frps vhost_https_port: 8453


Please input frps dashboard_port [1-65535](Default : 6443):
frps dashboard_port: 6443


Please input frps dashboard_user(Default : admin):
frps dashboard_user: admin


Please input frps dashboard_pwd(Default : T6PuHRDZ):
frps dashboard_pwd: T6PuHRDZ


Please input frps token(Default : mPegcSmAFcn8nwuw):
frps token: mPegcSmAFcn8nwuw


Please input frps subdomain_host(Default : 服务器IP ):
frps subdomain_host: 服务器IP


Please input frps max_pool_count [1-200]
(Default : 50):200
frps max_pool_count: 200

Please select log_level
1: info (default)
2: warn
3: error
4: debug
-------------------------
Enter your choice (1, 2, 3, 4 or exit. default [1]): 1
log_level: info


Please input frps log_max_days [1-30]
(Default : 3 day):
frps log_max_days: 3

Please select log_file
1: enable (default)
2: disable
-------------------------
Enter your choice (1, 2 or exit. default [1]): 
log_file: enable

Please select tcp_mux
1: enable (default)
2: disable
-------------------------
Enter your choice (1, 2 or exit. default [1]): 
tcp_mux: true

Please select kcp support
1: enable (default)
2: disable
-------------------------
Enter your choice (1, 2 or exit. default [1]): 
kcp support: true

============== Check your input ==============
You Server IP      : 服务器IP
Bind port          : 5443
kcp support        : true
vhost http port    : 8001
vhost https port   : 8453
Dashboard port     : 6443
Dashboard user     : admin
Dashboard password : T6PuHRDZ
token              : mPegcSmAFcn8nwuw
subdomain_host     : 服务器IP
tcp_mux            : true
Max Pool count     : 200
Log level          : info
Log max days       : 3
Log file           : enable
==============================================

Press any key to start...or Press Ctrl+c to cancel
frps install path:/usr/local/frps
config file for frps ... done
download frps ... done
download /etc/init.d/frps... done
setting frps boot... done

+---------------------------------------------------------+
|     Manager for Frps, Author Clang, Mender MvsCode      |
+---------------------------------------------------------+

Starting Frps(0.42.0)... done
Frps (pid 31594)is running.

+------------------------------------------------------------+
|   frps for Linux Server, Author Clang ,Mender MvsCode     |
|      A tool to auto-compile & install frps on Linux        |
+------------------------------------------------------------+


Congratulations, frps install completed!
================================================
You Server IP      : xxxxxxx
Bind port          : 5443
KCP support        : true
vhost http port    : 8001
vhost https port   : 8453
Dashboard port     : 6443
token              : mPegcSmAFcn8nwuw
subdomain_host     : xxxxxxx
tcp_mux            : true
Max Pool count     : 200
Log level          : info
Log max days       : 3
Log file           : enable
================================================
frps Dashboard     : http://xxxxxxxx:6443/
Dashboard user     : admin
Dashboard password : T6PuHRDZxxxx
================================================

frps status manage : frps {start|stop|restart|status|config|version}
Example:
  start: frps start
   stop: frps stop
restart: frps restart
You have new mail in /var/spool/mail/root

一般都选择默认就行,端口不要和服务器已有端口冲突,比如http的80,https的443等

一般到这里服务端就搭建好了

验证搭建

如果没做过改动的话,控制面板端口一般是6443 (Please input frps dashboard_port 前面一键安装的时候会展示这个,默认就是6443,也可以自己改)

访问地址 http://ip:6443

输入账户密码就是前面生成的

客户端配置

客户端下载地址

解压以后的文件

HTTP模式(修改frpc.ini)

[common]
server_addr = 服务器IP
server_port = 5443
token = mPegcSmAFcn8nwuw

[webdisc]
#访问协议
type = http
#内网服务器Ip         
local_ip = 192.168.100.100
#内网web服务的端口号
local_port = 8080
#所绑定的公网服务器域名,一级、二级域名都可以   
custom_domains = disc.xxxxxxx.xyz


[webjava]
#访问协议
type = http
#内网服务器Ip         
local_ip = 192.168.100.100
#内网web服务的端口号
local_port = 8012
#所绑定的公网服务器域名,一级、二级域名都可以   
custom_domains = server.xxxxxx.xyz

如果公网没有这么多域名的话,可以使用IP,但是内网需要Nginx做代理

TCP模式

[common]
server_addr = 服务器IP
server_port = 5443
token = mPegcSmAFcn8nwuw

[web8080]
type = http
local_ip = 127.0.0.1
local_port = 8080
remote_port = 6000

frpc.exe -c frpc.ini