如果没有公网IP,又想做端口映射?
那我建议你去拉条专线,又快又稳 !
不不不,自建FRP就可以做到!
教程开始:
准备一台带公网IP的VPS(没有公网IP的VPS那你还是去拉专线吧!)
FRP分为客户的和服务端,客户端叫frpc,服务端叫frps。这里以debian 9为例:
服务端配置
先去Github下载frp找到自己合适的版本 https://github.com/fatedier/frp/releases/
我的是debian9,就直接用命令下载了
wget https://github.com/fatedier/frp/releases/download/v0.34.0/frp_0.34.0_linux_amd64.tar.gz
解压到目录
tar zxf frp_0.34.0_linux_amd64.tar.gz
放到新建frp目录放置该目录并删除下载的文件
rm -rf frp_0.34.0_linux_amd64.tar.gz && mv frp_0.34.0_linux_amd64/ frp/
修改配置
nano frps_full.ini
[common] bind_addr = 0.0.0.0 # 监听地址 bind_port = 7000 # 监听端口 host_https_port = 433 # 外网 HTTPS 访问端口 vhost_http_port = 80 # 外网 HTTP 访问端口 token = 12345678 # 访问的token密码 subdomain_host = chen-dong.cn # 绑定域名
运行服务
./frps -c ./frps.ini
这样服务器就启动成功了。
客户端配置
同样服务端连接下载解压,
修改frpc.ini文件,假设frps所在服务器的公网 IP 为 x.x.x.x;
# frpc.ini [common] server_addr = x.x.x.x # 服务器IP server_port = 7000 # 服务器的端口 [RDP] type = tcp local_ip = 127.0.0.1 # 本地IP local_port = 3389 # 本地端口 remote_port = 3389 # 远程端口
启动客户端,必须用CMD命令启动。
这里以windows为例,我的frp放在D盘frp目录下
d: cd frp frpc.exe
如果是linux
./frps -c ./frps.ini
衍生部分
服务端开机自启:
nano /etc/systemd/system/frps.service
添加以下代码。frpc.exe和frpc.ini根据实际路径修改
[Unit] Description=frps After=network.target [Service] TimeoutStartSec=30 ExecStart=/root/frp/frps -c /root/frp/frps.ini ExecStop=/bin/kill $MAINPID [Install] WantedBy=multi-user.target
Winodw客户端后台一键启动:
新建一个vbs文件,frpc.exe和frpc.ini根据实际路径修改
set ws=wscript.createobject("wscript.shell") ws.run"D:\frp\frpc.exe -c D:\frp\frpc.ini",0
WINDOWS客户端需要开机自启
win+R调出运行窗口,并输入“shell:startup”,进入开机启动文件夹。拖入文件或者快捷方式。
也可以在计划任务里面添加。
Github作者原教程:https://github.com/fatedier/frp
如果是个小白,不知道怎么用,github上也有一个一键脚本
服务端一键脚本
wget https://raw.githubusercontent.com/MvsCode/frps-onekey/master/install-frps.sh -O ./install-frps.sh chmod 700 ./install-frps.sh ./install-frps.sh install
作者github:https://github.com/MvsCode/frps-onekey
客户端
同样修改frpc.ini文件,假设frps所在服务器的公网 IP 为 x.x.x.x;
# frpc.ini [common] server_addr = x.x.x.x # 服务器IP server_port = 7000 # 服务器的端口 [RDP] type = tcp local_ip = 127.0.0.1 # 本地IP local_port = 3389 # 本地端口 remote_port = 3389 # 远程端口