下面讲一下使用Frp做端口映射,云服务器的搭建这里就不多说了,这里主要是讲使用云服做为固定的IP穿透路由限制实现端口的映射,国内外的云服都可以用,一般用来0.4.5版本节点使用。
Frp必须使用一台VPS作为外网IP,我们要购买一台VPS来配置,本人使用的VPS推荐地址点击进入
VPS的系统可以用linux,也可以用windows
服务器端
1、使用SSH连接工具,连接云服务器,连接成功后,运行代码
下载frp:
cd /mnt
wget https://github.com/fatedier/frp/releases/download/v0.38.0/frp_0.38.0_linux_386.tar.gz
2、解压下载的frp文件,并重命名(个人习惯,大家可略过重命名):
解压:
tar -zxvf frp_0.38.0_linux_386.tar.gz
3、重命名:
mv frp_0.38.0_linux_386 frp
4、进入frp文件夹,删除客户端的文件:
cd frp/
rm -rf frpc*
5、打开配置文件,修改信息,保存并退出:(端口默认7000可以略过此步)
vim frps.ini
6、运行frps:
./frps -c frps.ini
出现以上信息说明frp服务端已经运行
注:云服务器的防火墙策略里要放行端口:7000,7500,31400-31409,如果修改了自定义端口,也要放行
Linux里要关闭系统防火墙,代码如下:
systemctl stop firewalld
不关闭系统防火墙,也可以单独开启端口,添加端口命令:
firewall-cmd --zone=public --add-port=7000/tcp --permanent
重新载入端口状态(添加端口后执行这个)
firewall-cmd --reload
查询指定端口是否已开
firewall-cmd --query-port=7000/tcp
查询所有开启的端口
netstat -anp
安装Screen,CentOS命令:
yum -y install screen
创建有名字的窗口(name随便改名字)
screen -S name
创建完窗口就可以在里面进行操作了;
然后执行上面第6步运行frp,关闭SHH连接工具,这样也会一直运行
有关于更多Screen的操作请自行搜索
在本地win10电脑上下载frp
下载解压,修改文件frpc.ini
[common] server_addr = 206.119.54.105 //此处填写云服务器的IP地址 server_port = 7000 //此处修改端口号,默认也可 [31400] type = tcp local_ip = 127.0.0.1 local_port = 31400 remote_port = 31400 [31401] type = tcp local_ip = 127.0.0.1 local_port = 31401 remote_port = 31401 [31402] type = tcp local_ip = 127.0.0.1 local_port = 31402 remote_port = 31402 [31403] type = tcp local_ip = 127.0.0.1 local_port = 31403 remote_port = 31403 [31404] type = tcp local_ip = 127.0.0.1 local_port = 31404 remote_port = 31404 [31405] type = tcp local_ip = 127.0.0.1 local_port = 31405 remote_port = 31405 [31406] type = tcp local_ip = 127.0.0.1 local_port = 31406 remote_port = 31406 [31407] type = tcp local_ip = 127.0.0.1 local_port = 31407 remote_port = 31407 [31408] type = tcp local_ip = 127.0.0.1 local_port = 31408 remote_port = 31408 [31409] type = tcp local_ip = 127.0.0.1 local_port = 31409 remote_port = 31409
压缩包的文件我都配置好了,只需要修改IP和端口号就能使用。
下面执行文件夹里的start.bat,为了方便,我做了一个批处理
如上图,客户端成功运行,如连接不成功或者闪退,基本原因是端口的问题,所以端口必须开放
我们以Win server2008r2为例,使用远程桌面连接云服务器后,下载frp
1、解压文件夹ftp放到D盘(当然也可以放别的盘符,需要修改start.bat的路径,用记事本打开此文件修改保存)
2、打开frps.ini修改端口号
[common] bind_port = 7000 dashboard_port=7500 dashboard_user=admin dashboard_pwd=admin
默认为7000,可以自己修改
3、运行批处理start.bat
如上图,服务器端成功运行。(服务器端请关闭防火墙)
Win10的客户端配置同上。
如闪退或者出错,请检查端口,大部分都是端口的问题,教程写的仓促,不足之处请在上方讨论区留言指正!
win客户端的CMD窗口不能关闭,一关闭就会失效,解决方法是可以设置后台运行
打开文件夹里的start.vbs,右键编辑
代码如下:
set wscriptObj = CreateObject("Wscript.Shell") wscriptObj.run "D:\frp\start.bat",0
其中D:路径修改为你所在盘符
然后按win+R键打开运行窗口,输入
shell:startup
打开启动项
在start.vbs文件上点鼠标右键别松,拖动此文件到新打开的启动窗口,松开右键,选择创建快捷方式,如图:
至此OK,你重新启动一下电脑,打开任务管理器,在后台进程里可以看见frpc.exe
然后测试一下端口,全通就对了!
2023/02附言:
很多Pi友说闪退的问题,在这里说明一下,闪退百分之八十是端口的问题,包括服务器面板的安全组要放行,Linux系统自带的防护墙要关闭(如果是WIN系统做服务器,防火墙也要关闭),服务器上的frps.ini和本地frpc.ini的端口号要一致(不修改默认为7000),服务器端保持运行后,再运行本地。
还有一种情况,frp客户端解压后,win10的安全中心会把文件夹里的frpc.exe作为病毒隔离,这样也会闪退!(有时候正常运行很多天后你突然发现端口不通了,一检查才发现是安全中心把frpc.exe给隔离了)
解决办法有2种:1、关闭安全中心。2、从安全中心设置里的“排除项”里添加上frp文件夹,这样就不会被删除文件了!
本站(Picn.cc)文章与教程皆为网络搜集和个人分享,并非代表Pi Network官方言论。如有误,望广大Pi友指正。
端口为什么不行
跟之前刀客的程序又多了一个虚拟机。不知道是什么意思 刚接触不太懂
tcp 127.0.0.1:31400: connectex: No connection could be made because the target machine actively refused it.
2023/04/12 14:32:22 [E] [proxy.go:803] [19a57d24b7cf0245] [31401] connect to local service [127.0.0.1:31401] error: dial tcp 127.0.0.1:31401: connectex: No connection could be made because the target machine actively refused it.
2023/04/12 14:32:22 [E] [proxy.go:803] [19a57d24b7cf0245] [31401] connect to local service [127.0.0.1:31401] error: dial tcp 127.0.0.1:31401: connectex: No connection could be made because the target machine actively refused it.
2023/04/12 14:32:24 [E] [proxy.go:803] [19a57d24b7cf0245] [31402] connect to local service [127.0.0.1:31402] error: dial tcp 127.0.0.1:31402: connectex: No connection could be made because the target machine actively refused it.
2023/04/12 14:32:24 [E] [proxy.go:803] [19a57d24b7cf0245] [31403] connect to local service [127.0.0.1:31403] error: dial tcp 127.0.0.1:31403: connectex: No connection could be made because the target
Protocol version: Latest
Latest block: a minute ago
Outgoing connections: 8
Incoming connections: 0
Supporting other nodes: No
这两天Incoming突然变成0并保持不动,且奖励跌落到0.2,原来是5,按照提示检查端口显示正常,怎么处理,谢谢
2023/04/07 20:35:27 [E] [proxy.go:797] [c795c24464ebe0c3] [31405] connect to local service [127.0.0.1:31405] error: dial tcp 127.0.0.1:31405: connectex: No connection could be made because the target machine actively refused it.
2023/04/07 20:35:28 [E] [proxy.go:797] [c795c24464ebe0c3] [31408] connect to local service [127.0.0.1:31408] error: dial tcp 127.0.0.1:31408: connectex: No connection could be made because the target machine actively refused it.
2023/04/07 20:35:28 [E] [proxy.go:797] [c795c24464ebe0c3] [31404] connect to local service [127.0.0.1:31404] error: dial tcp 127.0.0.1:31404: connectex: No connection could be made because the target machine actively refused it.
2023/04/07 20:35:28 [E] [proxy.go:797] [c795c24464ebe0c3] [31409] connect to local service [127.0.0.1:31409] error: dial tcp 127.0.0.1:31409: connectex: No connection could be made because the target mach
2023/04/01 11:52:23 I.png [tcp.go:63] c99dde4971c8d50f.png 31407.png tcp proxy listen port 31407.png
成功了 端口测试没有开。是不是要香港的服务器才行 ,大陆的都不行
2023/04/01 11:52:23 [I] [service.go:447] [c99dde4971c8d50f] client login info: ip [120.231.32.59:5441] version [0.36.2] hostname [] os [windows] arch [386]
2023/04/01 11:52:23 [I] [tcp.go:63] [c99dde4971c8d50f] [31407] tcp proxy listen port [31407]
2023/04/01 11:52:23 [I] [**:444] [c99dde4971c8d50f] new proxy [31407] success
2023/04/01 11:52:23 [I] [tcp.go:63] [c99dde4971c8d50f] [31409] tcp proxy listen port [31409]
2023/04/01 11:52:23 [I] [**:444] [c99dde4971c8d50f] new proxy [31409] success
2023/04/01 11:52:23 [I] [tcp.go:63] [c99dde4971c8d50f] [31406] tcp proxy listen port [31406]
2023/04/01 11:52:23 [I] [**:444] [c99dde4971c8d50f] new proxy [31406] success
2023/04/01 11:52:23 [I] [tcp.go:63] [c99dde4971c8d50f] [31405] tcp proxy listen port [31405]
2023/04/01 11:52:23 [I] [**:444] [c99dde4971c8d50f] new proxy [31405] success
2023/04/01 11:52:23 [I] [tcp.go:63] [c99dde4971c8d50f] [31401] tcp proxy listen port [31401]
2023/04/01 11:5
2023/03/28 13:09:06 [E] [proxy.go:797] [8f3b79bc31f3e53c] [31400] connect to local service [127.0.0.1:31400] error: dial tcp 127.0.0.1:31400: connectex: No connection could be made because the target machine actively refused it.
2023/03/28 13:09:06 [E] [proxy.go:797] [8f3b79bc31f3e53c] [31404] connect to local service [127.0.0.1:31404] error: dial tcp 127.0.0.1:31404: connectex: No connection could be made because the target machine actively refused it.
2023/03/28 13:09:06 [E] [proxy.go:797] [8f3b79bc31f3e53c] [31405] connect to local service [127.0.0.1:31405] error: dial tcp 127.0.0.1:31405: connectex: No connection could be made because the target machine actively refused it.
2023/03/28 13:09:06 [E] [proxy.go:797] [8f3b79bc31f3e53c] [31406] connect to local service [127.0.0.1:31406] error: dial tcp 127.0.0.1:31406: connectex: No connection could be made because the target machine actively refused it.
2023/03/2