使用frp实现内网数据转发[ssh,web,tcp]
程序员文章站
2022-07-01 13:49:44
...
1.安装golang
wget https://studygolang.com/dl/golang/go1.15.linux-amd64.tar.gz
tar -xvf go1.15.linux-amd64.tar.gz
2.配置gopath,goroot
添加到~/.bashrc
export GOROOT=/home/laoliu/go
export GOPATH=/home/laoliu/gopath
export GOBIN=/home/laoliu/go/bin
export PATH=$GOBIN:$PATH
source ~/.bashrc
3.配置国内源加速
https://github.com/goproxy/goproxy.cn
4.下载编译安装frp
go get github.com/fatedier/frp
cd /home/laoliu/gopath/pkg/mod/github.com/fatadier/frp
make
5.配置服务端frps.ini
# frps.ini
[common]
bind_port = 7000
vhost_http_port=6081
运行
frps -c frps.ini
6.配置客户端frpc.ini(找一台内网机器配置)编译安装frp
# frpc.ini
[common]
server_addr = 180.18.13.15
server_port = 7000
[web]
type = http
local_port = 9090
custom_domains = www.xxx.com
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
[stream] #普通tcp代理可以直接远程访问端口转发任何数据,名字随便起,可以区分开就行
type = tcp
local_ip = 127.0.0.1
local_port = 8800
remote_port = 6600
custom_domains = www.xxx.com
运行
frpc -c frpc.ini
7.测试
ssh连接
ssh [email protected] -p 6000
web连接,运行一台服务器在内网主机9090端口监听
www.xxx.com:6081
普通tcp连接
内网运行netcat监听
netcat -l 8800
外网访问
netcat 180.18.13.15 6600
如果没问题的话应该可以点对点文字聊天