说明

  • Linux搭建frp实现内网穿透

操作步骤

  • 安装步骤省略(下载解压拷贝到server服务器和client服务器完事)具体移步:github
    • 注意程序文件需要追加可执行权限!
    • 注意相关端口放行!
  • 服务端配置文件:frps.ini
[common]
bind_port = 7777
authentication_method = token
token = 12345678
tls_only = true
kcp_bind_port = 7777
max_pool_count = 10
log_file = /path/to/frp/frps.log
### trace, debug, info, warn, error
log_level = error
log_max_days = 3

# allow_ports = 1,4-5

vhost_http_port = 80
vhost_https_port = 443

dashboard_port = 10
dashboard_user = admin
dashboard_pwd = 12345678
  • 客户端配置文件:frpc.ini
[common]
server_addr = 8.8.8.8
server_port = 7777
tls_enable = true
token = 12345678
protocol = kcp
# pool_count = 5
log_file = /root/frp/frpc.log
log_level = trace
log_max_days = 3

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 1

[http:test]
type = http
local_ip = 127.0.0.1
local_port = 80
custom_domains = test.top
proxy_protocol_version = v2

[https:test]
type = https
local_port = 443
custom_domains = test.top
proxy_protocol_version = v2
use_encryption = true
use_compression = true
#plugin = https2http
#plugin_local_addr = 127.0.0.1:80
#plugin_crt_path = /path/to/test.pem
#plugin_key_path = /path/to/test.key
#plugin_host_header_rewrite = test.top
#plugin_header_X-From-Where = frp
  • 服务端开机自启动
# 添加系统服务
sudo vim /lib/systemd/system/frps.service

# 服务内容
[Unit]
Description=frps service
After=network.target syslog.target
Wants=network.target

[Service]
Type=simple
ExecStart=/path/to/frp/frps -c /path/to/frp/frps.ini

[Install]
WantedBy=multi-user.target

# 启动
sudo systemctl start frps

# 开机启动
sudo systemctl enable frps

# 其它命令
sudo systemctl restart frps
sudo systemctl stop frps
sudo systemctl status frps
  • 客户端开机自启动
# 添加系统服务
sudo vim /lib/systemd/system/frpc.service

# 服务内容
[Unit]
Description=frpc service
After=network.target syslog.target
Wants=network.target

[Service]
Type=simple
ExecStart=/path/to/frp/frpc -c /path/to/frp/frpc.ini

[Install]
WantedBy=multi-user.target

# 启动
sudo systemctl start frpc

# 开机启动
sudo systemctl enable frpc

# 其它命令
sudo systemctl restart frpc
sudo systemctl stop frpc
sudo systemctl status frpc
  • 定时任务,每天定时重启server和client
关于作者 · AdminI am Yasin, let's talk about these first!

文章评论

还没有评论,欢迎留下第一条回复。