前言

给家里的电脑装了双系统 默认CentOS的启动 寻思着给它来了个每天自启的任务 顺便给它用frp进行内网穿透 知道以前有过这样的文章 但写的太乱 今天再操手一遍流程

环境

服务端:CentOS7(腾讯云)
客户端:CentOS7(家里的台式机)

开始

今天的配置都不错 都是8G的运存

服务端

先下载frp服务端

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
yum update -y

yum install -y wget unzip

wget https://github.com/fatedier/frp/releases/download/v0.36.0/frp_0.36.0_linux_amd64.tar.gz

tar -xvf frp_0.36.0_linux_amd64.tar.gz

rm -f frp_0.36.0_linux_amd64.tar.gz

cd frp_0.36.0_linux_amd64

rm -f frc

rm -f frc.ini

rm -f frc.ini.full

配置配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
vim frps.ini


输入以下内容

[common]
bind_port = 7000
vhost_http_port = 7001
vhost_https_port = 7002
vhost_http_timeout = 60
heartbeat_timeout = 90
token = 123456
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = admin

:wq!

使用配置自启

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

使用systemd配置开机自启
yum install systemd

vim /etc/systemd/system/frps.service


写入以下内容
[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

使用 systemd 命令,管理 frps

# 启动frp
systemctl start frps
# 停止frp
systemctl stop frps
# 重启frp
systemctl restart frps
# 查看frp状态
systemctl status frps


配置 frps 开机自启。

systemctl enable frps

客户端

下载frp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
yum update -y

yum install -y wget unzip

wget https://github.com/fatedier/frp/releases/download/v0.36.0/frp_0.36.0_linux_amd64.tar.gz

tar -xvf frp_0.36.0_linux_amd64.tar.gz

rm -f frp_0.36.0_linux_amd64.tar.gz

cd frp_0.36.0_linux_amd64

rm -f frs

rm -f frs.ini

rm -f frs.ini.full

配置配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
vim frps.ini


输入以下内容

[common]
server_addr = 你的服务器ip地址
server_port = 7000
token = 123456
heartbeat_interval = 30
heartbeat_timeout = 90

[ssh]
type = tcp
local_ip = 你的局域网IP地址
local_port = 22
remote_port = 2222


:wq!

使用配置自启

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

使用systemd配置开机自启
yum install systemd

vim /etc/systemd/system/frpc.service


写入以下内容
[Unit]
# 服务名称,可自定义
Description = frp server
After = network.target syslog.target
Wants = network.target

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

[Install]
WantedBy = multi-user.target

使用 systemd 命令,管理 frpc

# 启动frp
systemctl start frpc
# 停止frp
systemctl stop frpc
# 重启frp
systemctl restart frpc
# 查看frp状态
systemctl status frpc

systemctl daemon-reload

参考:https://gofrp.org/docs/examples/ssh/