frps和frps的使用

66f56a38-22fe-47b5-9ced-73f85d471107
要使用 systemd 来控制 frps,需要先安装 systemd,然后在 /etc/systemd/system 目录下创建一个 frps.service 文件

  1. 安装systemd
# yum
yum install systemd
# apt
apt install systemd
  1. 创建并编辑 frps.service 文件, 例如:
[Unit]
Description=Frp Server Service		#服务的描述信息
After=network.target				#其中network.target代表有网路,network-online.target代表一个连通着的网络。

[Service]
Type=simple
User=nobody
Restart=1 			# 如果这个服务停止了,那么就重启
RestartSec=5s
ExecStart=/usr/bin/frps -c /etc/frp/frps.ini #服务的启动命令

[Install]
WantedBy=multi-user.target

这里我写入的是如下内容:

[Unit]
# 服务名称,可自定义
Description = frp server
After = network.target syslog.target
Wants = network.target

[Service]
Type = simple
# 启动frps的命令,需修改为您的frps的安装路径
ExecStart = /path/to/frps -c /path/to/frps.ini

[Install]
WantedBy = multi-user.target
  1. 使用 systemd 命令,管理 frps
    systemctl start frps
    systemctl stop frps
    systemctl restart frps
    systemctl status frps

  2. 配置 frps 开机自启
    systemctl enable frps

  3. frpc同理也如此配置
    编辑/etc/systemd/system/frpc.service

[Unit]
# 服务名称,可自定义
Description = frp client
After = network-online.target syslog.target
Wants = network-online.target

[Service]
Type = simple
# 启动frps的命令,需修改为您的frps的安装路径
ExecStart = /home/going/frp_0.45.0_linux_amd64/frpc -c /home/going/frp_0.45.0_linux_amd64/frpc.ini

[Install]
WantedBy = multi-user.target

然后systemctl start frpc
systemctl stop frpc
systemctl restart frpc
systemctl status frpc
systemctl enable frpc

通过 SSH 访问内网机器

1 配置frp server的对外暴露端口, 编辑frps.ini:

[common]
bind_port = 7000
  1. 配置frp client要访问的server的ip和端口, 编辑frpc.ini:
[common]
server_addr = xxx.xxx.xxx.xxx
server_port = 7000
  1. 配置frp client要暴露的端口,每个名称不重复, 编辑frpc.ini,比如22端口,则增加:
[company_ubuntu_master_ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 18001
  1. 重启两个服务
    systemctl restart frps
    systemctl restart frpc

var code = “66f56a38-22fe-47b5-9ced-73f85d471107”

posted @   影随风动91  阅读(260)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示