安装步骤
- 购买阿里云
学生云服务器购买网站 https://promotion.aliyun.com/ntms/act/campus2018.html
得到公网ip,如:1.2.3.4
- 下载frp
在frp服务端(阿里云)和frp客户端(打算访问的内网的机器)都要下载1
2
3wget https://github.com/fatedier/frp/releases/download/v0.29.1/frp_0.29.1_linux_amd64.tar.gz
tar -xzvf frp_0.29.1_linux_amd64.tar.gz
mv frp_0.29.1_linux_amd64 frp - frp服务端配置
在frp服务器上配置简版的frps.ini文件(完整版是frps_full.ini)启动服务器1
2
3
4[common]
bind_port = 7000 #frp服务端端口(可以修改)
bind_addr = 0.0.0.0
token = 12345678或者后台启动运行服务器1
./frps -c frps.ini
1
2
3nohup ./frps -c frps.ini &
tail -f nohup.out(查看信息) - frp客户端配置
在frp客户端上配置简版的frpc.ini文件(完整版是frpc_full.ini)启动客户端1
2
3
4
5
6
7
8
9
10[common]
server_addr = 4.3.2.1 #frp服务端地址,必须是公网ip或者域名
server_port = 7000 #frp服务端端口,即填写服务端配置中的 bind_port
token = 12345678
[ssh]
type = tcp #连接类型,填tcp或udp
local_ip = 127.0.0.1 #填127.0.0.1或内网ip都可以
local_port = 22 #需要转发到的端口,ssh端口是22
remote_port = 6000 #frp服务端的远程监听端口,即你访问服务端的remote_port就相当于访问客户端的 local_port,可以修改或者后台启动运行客户端1
./frpc -c frpc.ini
1
2
3nohup ./frpc -c frpc.ini &
tail -f nohup.out(查看信息) - 使用
xxx是frp客户端的用户名1
ssh -oPort=6000 XXX@4.3.2.1
- 后台停止
1
2ps -aux|grep frp| grep -v grep
kill -9 进程号 - connection timed out问题
如果出现以下问题在阿里云的云服务器的管理控制台下找到本实例安全组->配置规则->添加两条安全组规则1
2018/09/17 22:02:23 [W] [control.go:113] login to server failed: dial tcp xxx.xxx.xxx.xxx:7000: connect: connection timed out dial tcp xxx.xxx.xxx.xxx:7000: connect: connection timed out
规则1规则21
2端口范围: server_port/server_port 这里是7000/7000
授权对象: 0.0.0.0/01
2端口范围: remote_port/remote_port 这里是6000/6000
授权对象: 0.0.0.0/0 - 参考
https://cao0507.github.io/2018/09/18/阿里云服务器实现frp内网穿透/
https://www.jianshu.com/p/00c79df1aaf0
一个云服务器端连接多个客户端
- 服务器端配置
新建多个frps.ini,名字不一样如frps1.ini
配置不同端口启动服务器1
2
3
4[common]
bind_port = 7001 #frp服务端端口(可以修改)
bind_addr = 0.0.0.0
token = 123456781
2./frps -c frps1.ini\
nohup ./frps -c frps1.ini & - 客户端配置启动客户端
1
2
3
4
5
6
7
8
9
10[common]
server_addr = 4.3.2.1
server_port = 7001 #!!!!注意修改为新开的服务器端口
token = 12345678
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6001 #!!!!注意修改1
2./frpc -c frpc.ini
nohup ./frpc -c frpc.ini & - 参考
https://blog.csdn.net/dqf009/article/details/85042435
无域名配置http服务
- 服务器端配置
1
2
3
4[common]
bind_port = 7000
bind_addr = 0.0.0.0
privilege_token = 12345678 #好像其实不需要 - 客户端配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15[common]
server_addr = 4.3.2.1
server_port = 7000
token = 12345678
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
[range:tcp_port]
local_ip = 127.0.0.1
local_port = 9994-9995
remote_port = 9994-9995 - 测试
1
2python -m SimpleHTTPServer 9994
http://4.3.2.1:9994 - 其他方法
参考:https://www.cnblogs.com/sanduzxcvbnm/p/8509150.html