用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开机启动(win就不说了)
新建/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 frpc
看到如下即成功
● 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
标签:frps,etc,外网,systemctl,ini,frpc,FRP,port,端口映射 来源: https://blog.csdn.net/impish0/article/details/122412485