一.在公网上的ubuntu系统
1.配置文件:
frps.toml
bindPort = 7000 # The default value is 127.0.0.1. Change it to 0.0.0.0 when you want to access it from a public network. webServer.addr = "0.0.0.0" webServer.port = 7500 # dashboard's username and password are both optional webServer.user = "admin" webServer.password = "admin" vhostHTTPPort = 8080
2.启动脚本
serverstart.sh
#!/bin/bash FRP_DIR=`pwd` docker stop frps docker rm frps docker run -d \ --restart always \ --network host \ --name frps \ -v ${FRP_DIR}/frps.toml:/etc/frp/frps.toml \ snowdreamtech/frps
3.运行
./serverstart.sh
之后可以在浏览器查看状态: ip:7500
二.内网ubuntu系统
1.配置文件
frpc.toml
# frpc.toml serverAddr = "192.168.1.132" serverPort = 7000 [[proxies]] name = "ssh" type = "tcp" localPort = 22 remotePort = 6022
注:serverAddr指向公网ip;即用公网ip替换192.168.1.132
2.启动脚本
clientstart.sh
#!/bin/bash FRP_DIR=`pwd` docker stop frpc docker rm frpc docker run -d \ --restart always \ --network host \ --name frpc \ -v ${FRP_DIR}/frpc.toml:/etc/frp/frpc.toml \ snowdreamtech/frpc
3.运行
./clientstart.sh
4.测试
上述配置是一个把内网ssh服务的22号端口映射到公网的6022端口,执行命令
ssh -p 6022 192.168.1.132
即可从外网访问内网ssh服务
注:用公网ip替换192.168.1.132