一.服务器端安装frp
wget https:<span class="token operator">/</span><span class="token operator">/</span>code<span class="token punctuation">.</span>aliyun<span class="token punctuation">.</span>com<span class="token operator">/</span>MvsCode<span class="token operator">/</span>frps<span class="token operator">-</span>onekey<span class="token operator">/</span>raw<span class="token operator">/</span>master<span class="token operator">/</span><span class="token function">install-frps</span><span class="token punctuation">.</span>sh <span class="token operator">-</span>O <span class="token punctuation">.</span><span class="token operator">/</span><span class="token function">install-frps</span><span class="token punctuation">.</span>sh chmod 700 <span class="token punctuation">.</span><span class="token operator">/</span><span class="token function">install-frps</span><span class="token punctuation">.</span>sh <span class="token punctuation">.</span><span class="token operator">/</span><span class="token function">install-frps</span><span class="token punctuation">.</span>sh installwget https:<span class="token operator">/</span><span class="token operator">/</span>code<span class="token punctuation">.</span>aliyun<span class="token punctuation">.</span>com<span class="token operator">/</span>MvsCode<span class="token operator">/</span>frps<span class="token operator">-</span>onekey<span class="token operator">/</span>raw<span class="token operator">/</span>master<span class="token operator">/</span><span class="token function">install-frps</span><span class="token punctuation">.</span>sh <span class="token operator">-</span>O <span class="token punctuation">.</span><span class="token operator">/</span><span class="token function">install-frps</span><span class="token punctuation">.</span>sh chmod 700 <span class="token punctuation">.</span><span class="token operator">/</span><span class="token function">install-frps</span><span class="token punctuation">.</span>sh <span class="token punctuation">.</span><span class="token operator">/</span><span class="token function">install-frps</span><span class="token punctuation">.</span>sh installwget https://code.aliyun.com/MvsCode/frps-onekey/raw/master/install-frps.sh -O ./install-frps.sh chmod 700 ./install-frps.sh ./install-frps.sh install
接下来按此选择
如果使用的是类似阿里云的云服务器,需要在防火墙里添加端口规则来开放端口(tcp协议,需要开哪几个端口看下面)
1、选择源,默认是阿里云,直接回车
2、选择服务端口,默认是5443,可以随便改,别重就行。注意他这里虽然说这个这个值叫bind_port,但后面跟的括号表明,在客户端这个值叫server_port。
3、设置http连接的端口。默认80,可以随便改,别重就行。
设置https连接的端口。默认443,可以随便改,别重就行。
4、设置面板的端口。默认6443,可以随便改,记得住就行。
5、设置管理员账户,密码改一下,这随机密码不好记。
6、设置token,这个在客户端的配置还真叫token,可以随便改,记得住就行。
7、设置公网IP,既然你应该买了服务器,应该自带公网ip,直接回车。
之后一路回车
8、启动服务端
frps <span class="token function">start</span>frps <span class="token function">start</span>frps start
9、输入你服务器的公网ip+6443端口,如123.123.123.123:6443
能成功打开就服务器端就配置完了。
二.客户端安装frp
这个我没找到脚本,直接去github下安装安装吧
https://github.com/fatedier/frp/releases
注意是amd64 linux不是arm64 linux
下载解压到本地需要被穿透的主机上
然后终端进入该文件夹,照以下执行
<span class="token function">rm</span> <span class="token operator">-</span>rf frps<span class="token operator">*</span> chmod 777 frpc vim frpc<span class="token punctuation">.</span>ini<span class="token function">rm</span> <span class="token operator">-</span>rf frps<span class="token operator">*</span> chmod 777 frpc vim frpc<span class="token punctuation">.</span>inirm -rf frps* chmod 777 frpc vim frpc.ini
复制以下(只保留了必要部分,部分需要自己替换)
<span class="token punctuation">[</span>common<span class="token punctuation">]</span> server_addr <span class="token operator">=</span> <span class="token number">123.123</span>.123.123 server_port <span class="token operator">=</span> <span class="token number">5443</span> <span class="token assign-left variable">token</span><span class="token operator">=</span><span class="token number">123456</span> <span class="token punctuation">[</span>ssh<span class="token punctuation">]</span> <span class="token builtin class-name">type</span> <span class="token operator">=</span> tcp local_ip <span class="token operator">=</span> <span class="token number">192.168</span>.1.192 local_port <span class="token operator">=</span> <span class="token number">22</span> remote_port <span class="token operator">=</span> <span class="token number">6000</span> <span class="token punctuation">[</span>web<span class="token punctuation">]</span> <span class="token builtin class-name">type</span> <span class="token operator">=</span> http local_port <span class="token operator">=</span> <span class="token number">80</span> custom_domains <span class="token operator">=</span> <span class="token number">123.123</span>.123.123<span class="token punctuation">[</span>common<span class="token punctuation">]</span> server_addr <span class="token operator">=</span> <span class="token number">123.123</span>.123.123 server_port <span class="token operator">=</span> <span class="token number">5443</span> <span class="token assign-left variable">token</span><span class="token operator">=</span><span class="token number">123456</span> <span class="token punctuation">[</span>ssh<span class="token punctuation">]</span> <span class="token builtin class-name">type</span> <span class="token operator">=</span> tcp local_ip <span class="token operator">=</span> <span class="token number">192.168</span>.1.192 local_port <span class="token operator">=</span> <span class="token number">22</span> remote_port <span class="token operator">=</span> <span class="token number">6000</span> <span class="token punctuation">[</span>web<span class="token punctuation">]</span> <span class="token builtin class-name">type</span> <span class="token operator">=</span> http local_port <span class="token operator">=</span> <span class="token number">80</span> custom_domains <span class="token operator">=</span> <span class="token number">123.123</span>.123.123[common] server_addr = 123.123.123.123 server_port = 5443 token=123456 [ssh] type = tcp local_ip = 192.168.1.192 local_port = 22 remote_port = 6000 [web] type = http local_port = 80 custom_domains = 123.123.123.123
配置完后,就可以:wq保存退出
然后执行./frpc -c ./frpc.ini
完成连接。
原文链接:https://blog.csdn.net/qq_26122439/article/details/120575078