实战:FRP内网穿透部署-支持ssh、web访问

打印 上一主题 下一主题

主题 1596|帖子 1596|积分 4788

1 准备工作



  • linux系统
  • frp 0.48版本,下载链接
  • 1台具有公网IP访问的服务器
  • 2台内网服务器
2 公网服务器部署server端



  • 目录 /opt/frp

2.1 frps.ini配置

  1. [common]
  2. # FRP 服务端监听的端口,用于与客户端通信
  3. bind_port = 7070
  4. # 启用状态监控(可选)
  5. dashboard_port = 7550
  6. dashboard_user = admin
  7. dashboard_pwd = admin
复制代码
3 内网客户端部署client端



  • 目录 /opt/frp
  • 同一个frp压缩包解压后的东西,与server端一样

3.1 frpc.ini配置(内网服务器01)

  1. [common]
  2. #server地址,公网地址
  3. server_addr = xxx.xxx.xxx.xxx
  4. #server端口
  5. server_port = 7070
  6. [服务器01]
  7. #一般tcp就行了
  8. type = tcp
  9. #绑定的ip,通常是本机,也可以是局域网的地址
  10. local_ip = 127.0.0.1
  11. #ssh的服务就22端口,也可以转发到其他端口,实现远程访问mysql、web之类的
  12. local_port = 22
  13. #要绑定的远程机器的端口,有防火墙的记得放行
  14. remote_port = 21001
  15. [web01]
  16. #一般tcp就行了
  17. type = tcp
  18. #绑定的ip,通常是本机,也可以是局域网的地址
  19. local_ip = 127.0.0.1
  20. #web
  21. local_port = 7777
  22. #要绑定的远程机器的端口,有防火墙的记得放行
  23. remote_port = 27777
复制代码
3.2 frpc.ini配置(内网服务器02)

  1. [common]
  2. #server地址,公网地址
  3. server_addr = xxx.xxx.xxx.xxx
  4. #server端口
  5. server_port = 7070
  6. [服务器01]
  7. #一般tcp就行了
  8. type = tcp
  9. #绑定的ip,通常是本机,也可以是局域网的地址
  10. local_ip = 127.0.0.1
  11. #ssh的服务就22端口,也可以转发到其他端口,实现远程访问mysql、web之类的
  12. local_port = 22
  13. #要绑定的远程机器的端口,有防火墙的记得放行
  14. remote_port = 21002
复制代码
4 服务启动脚本



  • 为了让 FRP 服务端和客户端在系统重启后自动启动,可以将其配置为系统服务。
4.1 公网服务器 server



  • 创建系统服务文件
  1. sudo nano /etc/systemd/system/frps.service
复制代码


  • 添加以下内容
  1. [Unit]
  2. # 服务名称,可自定义
  3. Description = frp server
  4. After = network.target syslog.target
  5. Wants = network.target
  6. [Service]
  7. Type = simple
  8. # 启动frps的命令,需修改为您的frps的安装路径
  9. ExecStart = /opt/frp/frps -c /opt/frps.ini
  10. Restart=always
  11. RestartSec=5
  12. StartLimitInterval=0
  13. [Install]
  14. WantedBy = multi-user.target
复制代码


  • 启动服务
  1. sudo systemctl enable frps
  2. sudo systemctl start frps
复制代码
4.2 内网服务器 client



  • 两台服务器操纵一样
  • 创建系统服务文件
  1. sudo nano /etc/systemd/system/frpc.service
复制代码


  • 添加以下内容
  1. [Unit]
  2. # 服务名称,可自定义
  3. Description = frp server
  4. After = network.target syslog.target
  5. Wants = network.target
  6. [Service]
  7. Type = simple
  8. # 启动frps的命令,需修改为您的frps的安装路径
  9. ExecStart = /opt/frp/frpc -c /opt/frpc.ini
  10. Restart=always
  11. RestartSec=5
  12. StartLimitInterval=0
  13. [Install]
  14. WantedBy = multi-user.target
复制代码


  • 启动服务
  1. sudo systemctl enable frpc
  2. sudo systemctl start frpc
复制代码
2 systemctl常见命令

  1. # 重新加载 systemd 管理的服务配置文件
  2. sudo systemctl daemon-reload
  3. # 启动 FRP 客户端服务
  4. sudo systemctl start frpc
  5. # 启用 FRP 客户端的开机自启动。
  6. sudo systemctl enable frpc
  7. # 停止 FRP 客户端服务。
  8. sudo systemctl stop frpc
  9. # 重启 FRP 客户端服务。
  10. sudo systemctl restart frpc
  11. # 查看 FRP 客户端状态
  12. sudo systemctl status frpc
  13. # 查看 FRP 客户端日志
  14. sudo journalctl -u frpc
复制代码
3 FRP监控页面查看



免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

风雨同行

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表