| 因为工作的原因,需要国外国内来回跑,回国了上不了外网很不方便,尤其是跟客户沟通的社交工具用不了,出国了因为地域限制听不了国内的歌曲也很不方便,连优酷等视频都看不了,所以现在通过FRP+S*S解决两边的问题。       原先是想在梅林系统的路由里搭建FRP,弄好后发现路由CPU温度飙升,很吃力,放弃,改用威联通,为什么要用威联通而不用群晖,外观是第一因素,另外,这是习惯问题,并没有说哪个系统更好用,还有,如果哪一天群晖出个四个盘位左右的i3 cpu以上的话我会果断买一个。 
 国外端,我有个qnap253b充当VPS,50M的当地电信网络,有动态公网IP,相当稳定,很适合做FRPS服务器,省了租VPS的钱。DDNS我是用威联通自带的。
 国内端,我有个qnap251,2M的移动宽带,无公网IP,打过几次移动电话求公网IP,都被拒绝了,说现在已经分配不了公网IP了,无语。无公网DDNS就是摆设,花生壳之类的又收费,所以就通过穿透实现。
 安装frp我用docker实现,为什么用docker,因为方便实时看到调试状态,而不用每次都打开log查看异常状况。按照方法我在另一篇文章里已经写的很详细。
 这里发下配置文件:
 
 
 
  
 
 服务端:
 
 其他的基本上清楚,有几个讲下。复制代码[common]
bind_port = 7000 
kcp_bind_port = 7000
bind_udp_port = 7001                          
vhost_http_port = 7500 
vhost_https_port = 7600                 
dashboard_port = 5500                       
dashboard_user = admin 
dashboard_pwd = admin
privilege_mode = true                      
privilege_token = 123456       
privilege_allow_ports = 2000-3000,3001,3003,4000-50000,50000-60000        
#max_pool_count = 50
tcp_mux=true
authentication_timeout = 0
heartbeat_timeout = 30
#log_file = ./frps.log
#log_level = info
#log_max_days = 7
bind_port = 7000  是用于和客户端内网穿透传输数据的端口
 authentication_timeout = 900       假如客户端设备的时间和服务端的时间相差大于设定值,那么拒绝客户端连接。如果设置为0,则不验证时间,默认值为900秒,可自定义。
 heartbeat_timeout = 30   心跳包配置,默认30秒,超时应该就断开连接了,用来看调试结果。
 max_pool_count = 50  每个内网穿透可以创建的连接池上限,为什么注释掉,因为打开后发现一定几率的断网。
 开启服务端后frps处于等待链接状态:
 
   
 
 
 
  
 
 客户端
 
 
 稍微解释下:
 
 
 7000是用于和服务端传输数据的端口,ts253b.myqnapcloud.com是国外的那台qnap的自带DDNS,7500是用http访问内外的端口,https是7600,我也加入了心跳包检测,用于调试。复制代码server_addr =ts253b.myqnapcloud.com
server_port = 7000
privilege_token = 123456 
host_http_port = 7500
host_https_port = 7600
#protocol=kcp
heartbeat_interval = 10
heartbeat_timeout = 30
 
 
 ts253b.myqnapcloud.com是国外的那台qnap的自带DDNS,以后将用http以7500端口来访问国内的qnap,国内的qnap的局域网地址和端口是:192.168.1.111:8080.复制代码[web]
type = http
custom_domains = ts253b.myqnapcloud.com
privilege_mode = true
use_gzip = true
use_encryption = true
local_ip = 192.168.1.111
local_port = 8080
#pool_count = 100
   
 
 
 
 SSH登陆端口,以后将用6222作为登陆内外qnap的SSH端口。复制代码[ssh]
type = tcp
local_ip = 192.168.1.111
local_port = 22
remote_port = 6222
   
 
 
 用5555端口实现路由穿透访问。复制代码[router] 
type = tcp
local_ip = 192.168.1.1 
local_port = 80
remote_port = 5555
subdomain = router
   
 
 
 
 
 用55000实现简单的文件访问,比如我要访问docker的跟目录,需要配置qnap的登陆账号。复制代码[test_static_file]
type = tcp
remote_port = 55000
plugin = static_file
plugin_local_path = /
plugin_strip_prefix = static
plugin_http_user = admin
plugin_http_passwd = admin
   
 
 http proxy 或 socks5 插件, 浏览器设置 http 或 socks5 代理地址和端口为 ts253b.myqnapcloud.com:6000,通过客户端网络访问互联网,此时国外的IP已经变成了国内的移动IP。这里用了加密与压缩,否则数据流会被拦截,客户端会出现work connection closed, EOF提示。复制代码[http_proxy]
type = tcp
remote_port = 6000
plugin = http_proxy
plugin_http_user = admin
plugin_http_passwd = admin
use_encryption = true
use_compression = true
[socks5]
type = tcp
remote_port = 6001
plugin = socks5
plugin_user = admin        
plugin_passwd = admin
use_encryption = true
use_compression = true
配置文件里还打通了另外几个常用的歪屁恩端口,比如open歪屁恩:
 
 这里用51194作为open歪屁恩端口,国内的qnap只要开启open歪屁恩即可,下载配置文件后导入到其他机子客户端,改下域名即可。复制代码[open歪屁恩_port]
type = udp
local_port = 1194
remote_port = 51194
   
 
 
 开启S*S,如何安装及开启S*S具体看另一篇文章。这里用58388来穿透配置好的8388端口。复制代码[ss_port]
type = tcp
local_port = 8388
remote_port = 58388
 
   
 因为现在是国外翻到国内,所以我选择仅代理中国大陆IP,另外定义了只有酷我音乐等几个需要验证地域的app通过S*S,其他的app绕过,这样一点都不影响速度。
 
 配置好客户端文件后开启客户端:
 
   
 再来看看服务端调试记录:
 
   通过浏览器查看 frp 的状态以及代理统计信息展示:
 
   
   
   
 
 
 
 
 
 |