环境:
- 具有公网IP的服务器
- Centos7
- 需要内网穿透的客户端
https://github.com/fatedier/frp/blob/master/README_zh.md
-
将 frps、frps.ini 及 frps.service 放到具有公网 IP 的机器上。
-
将 frpc 、frpc.ini 及 frpc.service 放到处于内网环境的机器上。
frps
/usr/bin/frpsfrps.ini
/etc/frp/frps.inifrps.service
/lib/systemd/system/frps.service
frpc
/usr/bin/frpcfrpc.ini
/etc/frp/frpc.inifrpc.service
/lib/systemd/system/frpc.service
关闭防火墙
systemctl disable firewalld <span class="token function">chkconfig</span> iptables offsystemctl disable firewalld <span class="token function">chkconfig</span> iptables offsystemctl disable firewalld chkconfig iptables off
https://github.com/fatedier/frp/releaseshttps://github.com/fatedier/frp/releaseshttps://github.com/fatedier/frp/releases
<span class="token function">tar</span> -zxvf frp_0.28.2_linux_amd64.tar.gz<span class="token function">tar</span> -zxvf frp_0.28.2_linux_amd64.tar.gztar -zxvf frp_0.28.2_linux_amd64.tar.gz
进入目录
<span class="token function">cd</span> frp_0.28.2_linux_amd64<span class="token function">cd</span> frp_0.28.2_linux_amd64cd frp_0.28.2_linux_amd64
移动位置
<span class="token function">mv</span> frps /usr/bin/frps<span class="token function">mv</span> frps /usr/bin/frpsmv frps /usr/bin/frps
修改配置
- frps.ini
<span class="token punctuation">[</span>common<span class="token punctuation">]</span> bind_addr <span class="token operator">=</span> 0.0.0.0 bind_port <span class="token operator">=</span> 9800 vhost_http_port <span class="token operator">=</span> 8080<span class="token punctuation">[</span>common<span class="token punctuation">]</span> bind_addr <span class="token operator">=</span> 0.0.0.0 bind_port <span class="token operator">=</span> 9800 vhost_http_port <span class="token operator">=</span> 8080[common] bind_addr = 0.0.0.0 bind_port = 9800 vhost_http_port = 8080
移动位置
<span class="token function">mkdir</span> -p /etc/frp <span class="token operator">&&</span> <span class="token function">mv</span> frps.ini /etc/frp/frps.ini<span class="token function">mkdir</span> -p /etc/frp <span class="token operator">&&</span> <span class="token function">mv</span> frps.ini /etc/frp/frps.inimkdir -p /etc/frp && mv frps.ini /etc/frp/frps.ini
- systemd/frps.service
主要修改
ExecStart
,也就是脚本位置, 如果你是按照我的步骤走,可不用改此文件
<span class="token punctuation">[</span>Unit<span class="token punctuation">]</span> Description<span class="token operator">=</span>Frp Server Service After<span class="token operator">=</span>network.target <span class="token punctuation">[</span>Service<span class="token punctuation">]</span> Type<span class="token operator">=</span>simple User<span class="token operator">=</span>nobody Restart<span class="token operator">=</span>on-failure RestartSec<span class="token operator">=</span>5s ExecStart<span class="token operator">=</span>/usr/bin/frps -c /etc/frp/frps.ini <span class="token punctuation">[</span>Install<span class="token punctuation">]</span> WantedBy<span class="token operator">=</span>multi-user.target<span class="token punctuation">[</span>Unit<span class="token punctuation">]</span> Description<span class="token operator">=</span>Frp Server Service After<span class="token operator">=</span>network.target <span class="token punctuation">[</span>Service<span class="token punctuation">]</span> Type<span class="token operator">=</span>simple User<span class="token operator">=</span>nobody Restart<span class="token operator">=</span>on-failure RestartSec<span class="token operator">=</span>5s ExecStart<span class="token operator">=</span>/usr/bin/frps -c /etc/frp/frps.ini <span class="token punctuation">[</span>Install<span class="token punctuation">]</span> WantedBy<span class="token operator">=</span>multi-user.target[Unit] Description=Frp Server Service After=network.target [Service] Type=simple User=nobody Restart=on-failure RestartSec=5s ExecStart=/usr/bin/frps -c /etc/frp/frps.ini [Install] WantedBy=multi-user.target
移动位置
<span class="token function">mv</span> systemd/frps.service /lib/systemd/system/frps.service<span class="token function">mv</span> systemd/frps.service /lib/systemd/system/frps.servicemv systemd/frps.service /lib/systemd/system/frps.service
systemctl <span class="token function">enable</span> frps.service systemctl start frps.service systemctl status frps.service systemctl stop frps.servicesystemctl <span class="token function">enable</span> frps.service systemctl start frps.service systemctl status frps.service systemctl stop frps.servicesystemctl enable frps.service systemctl start frps.service systemctl status frps.service systemctl stop frps.service
https://github.com/fatedier/frp/releaseshttps://github.com/fatedier/frp/releaseshttps://github.com/fatedier/frp/releases
<span class="token function">tar</span> -zxvf frp_0.28.2_linux_amd64.tar.gz<span class="token function">tar</span> -zxvf frp_0.28.2_linux_amd64.tar.gztar -zxvf frp_0.28.2_linux_amd64.tar.gz
进入目录
<span class="token function">cd</span> frp_0.28.2_linux_amd64<span class="token function">cd</span> frp_0.28.2_linux_amd64cd frp_0.28.2_linux_amd64
移动文件
<span class="token function">mv</span> frpc /usr/bin/frpc<span class="token function">mv</span> frpc /usr/bin/frpcmv frpc /usr/bin/frpc
修改配置文件
- frpc.ini
<span class="token punctuation">[</span>common<span class="token punctuation">]</span> server_addr <span class="token operator">=</span> 139.189.64.253 server_port <span class="token operator">=</span> 9800 <span class="token punctuation">[</span>ssh<span class="token punctuation">]</span> <span class="token function">type</span> <span class="token operator">=</span> tcp local_ip <span class="token operator">=</span> 127.0.0.1 local_port <span class="token operator">=</span> 22 remote_port <span class="token operator">=</span> 6000 <span class="token punctuation">[</span>web<span class="token punctuation">]</span> <span class="token function">type</span> <span class="token operator">=</span> http local_port <span class="token operator">=</span> 80 custom_domains <span class="token operator">=</span> blog.pibigstar.com<span class="token punctuation">[</span>common<span class="token punctuation">]</span> server_addr <span class="token operator">=</span> 139.189.64.253 server_port <span class="token operator">=</span> 9800 <span class="token punctuation">[</span>ssh<span class="token punctuation">]</span> <span class="token function">type</span> <span class="token operator">=</span> tcp local_ip <span class="token operator">=</span> 127.0.0.1 local_port <span class="token operator">=</span> 22 remote_port <span class="token operator">=</span> 6000 <span class="token punctuation">[</span>web<span class="token punctuation">]</span> <span class="token function">type</span> <span class="token operator">=</span> http local_port <span class="token operator">=</span> 80 custom_domains <span class="token operator">=</span> blog.pibigstar.com[common] server_addr = 139.189.64.253 server_port = 9800 [ssh] type = tcp local_ip = 127.0.0.1 local_port = 22 remote_port = 6000 [web] type = http local_port = 80 custom_domains = blog.pibigstar.com
将 blog.pibigstar.com的域名 A 记录解析到 我们公网IP地址: x.x.x.x
通过浏览器访问 http://blog.pibigstar.com:8080 即可访问到处于内网机器上的 web 服务。
ssh连接
ssh -oPort=6000 root@139.189.65.203
移动位置
<span class="token function">mkdir</span> -p /etc/frp <span class="token operator">&&</span> <span class="token function">mv</span> frpc.ini /etc/frp/frpc.ini<span class="token function">mkdir</span> -p /etc/frp <span class="token operator">&&</span> <span class="token function">mv</span> frpc.ini /etc/frp/frpc.inimkdir -p /etc/frp && mv frpc.ini /etc/frp/frpc.ini
- systemd/frpc.service
主要修改
ExecStart
,也就是脚本位置, 如果你是按照我的步骤走,可不用改此文件
<span class="token punctuation">[</span>Unit<span class="token punctuation">]</span> Description<span class="token operator">=</span>Frp Client Service After<span class="token operator">=</span>network.target <span class="token punctuation">[</span>Service<span class="token punctuation">]</span> Type<span class="token operator">=</span>simple User<span class="token operator">=</span>nobody Restart<span class="token operator">=</span>on-failure RestartSec<span class="token operator">=</span>5s ExecStart<span class="token operator">=</span>/usr/bin/frpc -c /etc/frp/frpc.ini ExecReload<span class="token operator">=</span>/usr/bin/frpc reload -c /etc/frp/frpc.ini <span class="token punctuation">[</span>Install<span class="token punctuation">]</span> WantedBy<span class="token operator">=</span>multi-user.target<span class="token punctuation">[</span>Unit<span class="token punctuation">]</span> Description<span class="token operator">=</span>Frp Client Service After<span class="token operator">=</span>network.target <span class="token punctuation">[</span>Service<span class="token punctuation">]</span> Type<span class="token operator">=</span>simple User<span class="token operator">=</span>nobody Restart<span class="token operator">=</span>on-failure RestartSec<span class="token operator">=</span>5s ExecStart<span class="token operator">=</span>/usr/bin/frpc -c /etc/frp/frpc.ini ExecReload<span class="token operator">=</span>/usr/bin/frpc reload -c /etc/frp/frpc.ini <span class="token punctuation">[</span>Install<span class="token punctuation">]</span> WantedBy<span class="token operator">=</span>multi-user.target[Unit] Description=Frp Client Service After=network.target [Service] Type=simple User=nobody Restart=on-failure RestartSec=5s ExecStart=/usr/bin/frpc -c /etc/frp/frpc.ini ExecReload=/usr/bin/frpc reload -c /etc/frp/frpc.ini [Install] WantedBy=multi-user.target
移动位置
<span class="token function">mv</span> systemd/frpc.service /lib/systemd/system/frpc.service<span class="token function">mv</span> systemd/frpc.service /lib/systemd/system/frpc.servicemv systemd/frpc.service /lib/systemd/system/frpc.service
systemctl <span class="token function">enable</span> frpc.service systemctl start frpc.service systemctl status frpc.service systemctl stop frpc.servicesystemctl <span class="token function">enable</span> frpc.service systemctl start frpc.service systemctl status frpc.service systemctl stop frpc.servicesystemctl enable frpc.service systemctl start frpc.service systemctl status frpc.service systemctl stop frpc.service
原文链接:https://blog.csdn.net/junmoxi/article/details/101434642
© 版权声明
声明📢本站内容均来自互联网,归原创作者所有,如有侵权必删除。
本站文章皆由CC-4.0协议发布,如无来源则为原创,转载请注明出处。
THE END