1、很多情况下处于NAT网络环境中没有公网IP,这个时候可疑通过FRP服务器的转发进行内网穿透。frp内网穿透服务器搭建和frp使用方法。
本教程是使用TCP模式(连接内网Windows的远程桌面),frp客户端和frp服务端以Windows服务的方式在后台默默运行,还可以使用UDP、HTTP、HTTPS模式。
2、为什么不再使用ngork
ngork2.0不再开源
3、Linux服务端安装
wget --no-check-certificate https://raw.githubusercontent.com/clangcn/onekey-install-shell/master/frps/install-frps.sh -O ./install-frps.sh
chmod 700 ./install-frps.sh
./install-frps.sh install
或者手动安装
https://github.com/fatedier/frp/releases/download/v0.13.0/frp_0.13.0_linux_AMD64.tar.gz
4、Windows服务端安装
https://github.com/fatedier/frp/releases
https://github.com/fatedier/frp/releases/download/v0.13.0/frp_0.13.0_windows_amd64.zip
5、frp服务端配置文件,基本包含frps_full.ini全部的配置了
frps.ini
---------------------------------------------------------------------------------------------------
[common]
bind_addr = 0.0.0.0
bind_port = 5443
# udp port used for kcp protocol, it can be same with 'bind_port'
# if not set, kcp is disabled in frps
kcp_bind_port = 5443
dashboard_port = 6443
dashboard_user = 用户
dashboard_pwd = 密码
# assets_dir = ./static
vhost_http_port = 8080
vhost_https_port = 4443
log_file = ./frps.log
# debug, info, warn, error
log_level = info
log_max_days = 30
# privilege mode is the only supported mode since v0.10.0
privilege_token = hLzzySjVo1kMJgaz
# only allow frpc to bind ports you list, if you set nothing, there won't be any limit
#privilege_allow_ports = 1-65535
# pool_count in each proxy will change to max_pool_count if they exceed the maximum value
max_pool_count = 50
# if tcp stream multiplexing is used, default is true
tcp_mux = true
authentication_timeout = 900
subdomAIn_host = frp.asuhu.com
-------------------
Windows 启动服务器
frps.exe -c frps.ini
linux 启动服务器
frps -c frps.ini
vi /etc/rc.d/rc.local #centos7 chmod +x /etc/rc.d/rc.local
su - root -c "/root/frp/frps -c frps.ini"
---------------------------------------------------------------------------------------------------
6、客户端配置文件tcp_model
frps.ini
----------
[common]
server_addr = 122.114.xx.xx
server_port = 5443
log_file = ./frpc.log
log_level = info
log_max_days = 30
privilege_token = hLzzySjVo1kMJgaz
pool_count = 50
tcp_mux = true
user = 用户
login_fail_exit = true
protocol = tcp
[tcp_mode]
privilege_mode = true
type = tcp
local_ip = 127.0.0.1
local_port = 3389
remote_port = 23689
--------------
客户端配置文件http_model
[common]
server_addr = 122.114.xx.xx
server_port = 5443
log_file = ./frpc.log
log_level = info
log_max_days = 30
privilege_token = hLzzySjVo1kMJgaz
pool_count = 50
tcp_mux = true
user = 用户
login_fail_exit = true
protocol = http
[web]
type = http
local_ip = 127.0.0.1
local_port = 80
use_encryption = false
use_compression = false
subdomain = frp.asuhu.com
custom_domains = frp2.asuhu.com
-------------------
启动客户端
frpc.exe -c frpc.ini
---------------------------------------------------------------------------------------------------
7、Windows快速添加通过防火墙规则
netsh advfirewall firewall add rule name="Open Port 5443" dir=in action=allow protocol=TCP localport=5443
netsh advfirewall firewall add rule name="Open Port 5443" dir=in action=allow protocol=TCP localport=6443
netsh advfirewall firewall add rule name="Open Port 4443" dir=in action=allow protocol=TCP localport=4443
netsh advfirewall firewall add rule name="Open Port 23689" dir=in action=allow protocol=TCP localport=23689
netsh advfirewall firewall add rule name="Open Port 8080" dir=in action=allow protocol=TCP localport=8080
---------------------------------------------------------------------------------------------------
8、Windows 设置后台运行
创建一个frpc.cmd
frpc.cmd
cd
cd frp
frpc.exe -c frpc.ini
创建一个frpc.vbs,用于在后台执行frpc
frpc.vbs
Set ws = CreateObject("Wscript.Shell")
ws.run "cmd /c frpc",vbhide
frpc客户端 frps服务端 创建步骤一样
这样能开机后台运行
---------------------------------------------------------------------------------------------------
9、Windows 设置开机启动
运行框输入下面代码,添加启动项
%programdata%MicrosoftWindowsStart MenuProgramsStartup
---------------------------------------------------------------------------------------------------
10、验证登录远程桌面122.114.xx.xx:23689
---------------------------------------------------------------------------------------------------
11、frp面板http://122.114.xx.xx:6443/static/