用FRP,内网端口映射到外网,记录

https://ghproxy.com/github.com/fatedier/frp/releases/download/v0.38.0/frp_0.38.0_windows_amd64.zip
https://ghproxy.com/github.com/fatedier/frp/releases/download/v0.38.0/frp_0.38.0_linux_amd64.tar.gz

frps,公网机用

frpc,内网机用

公网机,PC1,开放6999,6888,7500端口(其它地方都是7000,我特地改个端口自用)

frps.ini(bind_port与frpc.ini的server_port一致)

[common]
bind_port = 6999
dashboard_user = admin
dashboard_pwd = admin
dashboard_port = 7500

启动 公网机,PC1 上的frps,我这是linux 的公网服务器,先给权限再运行

chmod +x /etc/frps/frps
/etc/frps/frps -c /etc/frps/frps.ini

启动后,通过站长工具,检查端口7000是否开放。

http://tool.chinaz.com/port/

http://tool.chinaz.com/port/http://tool.chinaz.com/port/



内网机,PC2(ip为172.16.9.10,也可设置为内网的其它pc及对应端口)

frpc.ini

[common]
server_addr = 1.1.1.1
server_port = 6999
 
#[]内可随便写
[RDP]
type = tcp
local_ip = 172.16.9.10
local_port = 3389
remote_port = 6888

启动内网机PC2,我这是win7内网机

frpc -c frpc.ini

内网机PC2显示如下即成功:

C:\xxxx>frpc -c frpc.ini
2021/05/13 16:03:35 [I] [service.go:301] [c0cc7be5df9dbebc] login to server succ
ess, get run id [c0cc7be5df9dbebc], server udp port [0]
2021/05/13 16:03:35 [I] [proxy_manager.go:144] [c0cc7be5df9dbebc] proxy added: [
RDP]
2021/05/13 16:03:35 [I] [control.go:180] [c0cc7be5df9dbebc] [RDP] start proxy su
ccess



此时公网机PC1也有显示,我这已不方便截图,就不放了。 

那么任意一台PCn连接内网机PC2(或自己设定的内网其它pc)的远程桌面地址为

1.1.1.1:6888


linux上,设置公网机pc1开机启动

新建/etc/systemd/system/frps.service,内容如下:

[Unit]
Description=Frp Client
After=network.target
Wants=network.target

[Service]
Restart=on-failure
RestartSec=5
ExecStart=/etc/frps/frps -c /etc/frps/frps.ini

[Install]
WantedBy=multi-user.target
#刷新服务列表:
systemctl daemon-reload

#设置开机自启
systemctl enable frps
#关闭开机自启
systemctl disable frps

#启动服务
systemctl start frps
#停止服务
systemctl stop frps
#服务状态
systemctl status frps

依次运行

systemctl daemon-reload
systemctl enable frps
systemctl start frps
systemctl status frps

看到如下即成功 

● frps.service - Frp Client
   Loaded: loaded (/etc/systemd/system/frps.service; enabled; vendor preset: disabled)
   Active: active (running) since 一 2022-01-10 15:33:18 CST; 7s ago
 Main PID: xxxx (frps)
   CGroup: /system.slice/frps.service
           └─29316 /etc/frps/frps -c /etc/frps/frps.ini

win上设置开机启动,闪一下cmd窗口就没了

@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
:begin
REM
cd C:\xxxx\frpc1
frpc -c frpc.ini
exit

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值