欢迎报读宜宾电大本科专科
张老师咨询电话:18096239786

使用 FRP 内网穿透| 适用于Linux Windows服务端

使用 FRP 内网穿透| 适用于Linux Windows服务端
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.16.1/frp_0.16.1_linux_386.tar.gz
https://github.com/fatedier/frp/releases/download/v0.16.1/frp_0.16.1_linux_amd64.tar.gz
tar -zxvf frp_0.16.1_linux_amd64.tar.gz
mv frp_0.16.1_linux_amd64 frp
vi /etc/rc.local
su – root -c “/root/frp/frps -c /root/frp/frps.ini -L /root/frp/frps.log”

https://github.com/fatedier/frp/releases/download/v0.21.0/frp_0.21.0_linux_amd64.tar.gz
tar -zxvf frp_0.21.0_linux_amd64.tar.gz
mv frp_0.21.0_linux_amd64 frp
vi /etc/rc.local
su – root -c “/root/frp/frps -c /root/frp/frps.ini” #这样日志会在/root目录下

4、Windows服务端安装
https://github.com/fatedier/frp/releases
https://github.com/fatedier/frp/releases/download/v0.16.1/frp_0.16.1_windows_386.zip
https://github.com/fatedier/frp/releases/download/v0.16.1/frp_0.16.1_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

# set dashboard_addr and dashboard_port to view dashboard of frps
# dashboard_addr’s default value is same with bind_addr
# dashboard is available only if dashboard_port is set
dashboard_addr = 0.0.0.0
dashboard_port = 7500

# dashboard user and pwd for basic auth protect, if not set, both default value is admin
dashboard_user = admin
dashboard_pwd = admin

# 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
# heartbeat configure, it’s not recommended to modify the default value
# the default value of heartbeat_timeout is 90
# heartbeat_timeout = 90

# 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

# authentication_timeout means the timeout interval (seconds) when the frpc connects frps
# if authentication_timeout is zero, the time is not verified, default is 900s
authentication_timeout = 900

# if subdomain_host is not empty, you can set subdomain when type is http or https in frpc’s configure file
# when subdomain is test, the host used by routing is test.frps.com
subdomain_host = frps.com

# if tcp stream multiplexing is used, default is true
tcp_mux = true

服务端简洁配置
[common]
bind_addr = 0.0.0.0
bind_port = 55443
kcp_bind_port = 55443
log_file = ./frps.log
log_level = info
log_max_days = 30
privilege_token = hLzzySjVo1kMJgaz
max_pool_count = 50
tcp_mux = true
authentication_timeout = 900
#frp_0.21会出现下面的错误,FRP 客户端所在机器和 FRP 服务端所在机器的时间相差不能超过 15 分钟
login to server failed: authorization faile
2018/09/27 14:31:15 [W] [service.go:262] authorization failed
——————-
6、Windows 启动frp服务器
frps.exe -c frps.ini
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

Windows 开机自启动frp服务器
控制面板 —> 管理工具 —> 任务计划程序

或者运行框输入下面代码,添加启动项 #这样必须登录系统才开始运行服务
%programdata%\Microsoft\Windows\Start Menu\Programs\Startup
——————-
7、linux 启动frp服务器
frps -c frps.ini

Linux 开机自启动frp服务器
vi /etc/rc.d/rc.local #centos7 chmod +x /etc/rc.d/rc.local
su – root -c “/root/frp/frps -c /root/frp/frps.ini”

vi /etc/rc.local
su – root -c “/root/frp/frps -c /root/frp/frps.ini”
iptables -I INPUT -p tcp -m multiport –dports 55443,55446,55448 -j ACCEPT;service iptables save;service iptables restart
—————————————————————————————————
8、客户端配置文件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
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

验证登录远程桌面122.114.xx.xx:23689

[ssh]
# tcp | udp | http | https | stcp | xtcp, default is tcp
type = tcp
local_ip = 127.0.0.1
local_port = 22
# true or false, if true, messages between frps and frpc will be encrypted, default is false
use_encryption = false
# if true, message will be compressed
use_compression = false
# remote port listen by frps
remote_port = 6001
# frps will load balancing connections for proxies in same group
group = test_group
# group should have same group key
group_key = 123456
————–
9、客户端配置文件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
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
——————-
启动客户端
frpc.exe -c frpc.ini

赞(0) 打赏
未经允许不得转载:逐渐学法的博客 » 使用 FRP 内网穿透| 适用于Linux Windows服务端
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

逐渐学法的博客

逐渐学法的博客-这是宜宾电大张老师的博客,分享法学和计算机的文章。一起学习交流可以联系 18096239786,谢谢!——by 逐渐学法宜宾电大最新招生简章点这里