当前位置:首页 > 系统 > 使用frp进行内网穿透

使用frp进行内网穿透

系统4年前 (2019-11-12)

使用frp进行内网穿透

frp用来做穿透内网,将内网或防火墙之后的机器,对外网环境提供服务


实验环境

外网环境: Windows Server 2019服务器

内网环境1: CentOS 7.7服务器   应用nginx环境 端口33605

内网环境2: Windows Server2016  应用RDP 端口3389

内网环境3: Windows Server2012  应用RDP 端口3389


下载地址https://github.com/fatedier/frp/releases


Windows服务端

解压后只保留frps.exe和frps.ini,其余文件删除

编辑frps.ini

[common]
bind_addr = 0.0.0.0   #绑定所有地址
bind_port = 6001      #与客户端进行通信的端口
bind_udp_port = 7001
kcp_bind_port = 7000
#proxy_bind_addr = 127.0.0.1
#vhost_http_port = 33605
#vhost_https_port = 4430
#vhost_http_timeout = 60
#tcpmux_httpconnect_port = 1337
#dashboard_addr = 0.0.0.0
#dashboard_port = 7500
#dashboard_user = admin
#dashboard_pwd = admin
#enable_prometheus = true
log_file = ./frps.log
log_level = error
log_max_days = 1
disable_log_color = false
detailed_errors_to_client = true
authentication_method = token
authenticate_heartbeats = false
authenticate_new_work_conns = false
privilege_token = 1234567890
oidc_client_id =
oidc_client_secret = 
oidc_audience = 
oidc_token_endpoint_url = 
#heartbeat_timeout = 90
#allow_ports = 33605
max_pool_count = 50
max_ports_per_client = 0
tls_only = false
#subdomain_host = frps.com
tcp_mux = true
#custom_404_page = /path/to/404.html
udp_packet_size = 1500


cmd下运行

d:\tool\frp\frps.exe -c d:\tool\frp\frps.ini


或者注册为系统服务

使用frp进行内网穿透

cd到frp所在目录
安装 winsw install
开启 winsw start

如果需要拆卸
停止 winsw stop
拆卸 winsw uninstall

使用frp进行内网穿透 frp server.zip


Linux客户端

解压后只保留frpc和frpc.ini,其余文件删除

cd /root
wget https://github.com/fatedier/frp/releases/download/v0.29.1/frp_0.29.1_linux_amd64.tar.gz
tar xzvf frp_0.29.1_linux_amd64.tar.gz
mv frp_0.29.1_linux_amd64 frp
chmod +x /root/frp/frpc

vim /root/frp/frpc.ini
修改为
[common]
server_addr = 222.222.222.222   #服务端公网IP
server_port = 6001                      #与服务端通信的端口
#log_file = ./frpc.log                      
#log_level = info                            
#log_max_days = 1                        
privilege_token = 1234567890    #连接密码

[web]
type = tcp
local_ip = 127.0.0.1
local_port = 33605
remote_port = 33605

这里没有使用vhost方式,因为type配置为http,必须要设置域名解析


设置为系统服务

vim /usr/lib/systemd/system/frpc.service
增加
[Unit]
Description=Frp Client Service
After=network.target

[Service]
Type=simple
User=root
Restart=on-failure
RestartSec=5s
ExecStart=/root/frp/frpc -c /root/frp/frpc.ini
ExecReload=/root/frp/frpc reload -c /root/frp/frpc.ini

[Install]
WantedBy=multi-user.target

执行

systemctl enable frpc.service && systemctl start frpc.service
systemctl status frpc.service
systemctl is-active frpc.service
systemctl list-units  --type=service


Windows客户端

使用frp进行内网穿透 frp client.zip

解压后只保留frpc.exe和frpc.ini,其余文件删除

编辑frpc.ini

[common]
server_addr = 222.222.222.222
server_port = 6001
privilege_token = 1234567890
#http_proxy = http://user:passwd@192.168.1.128:8080
#http_proxy = socks5://user:passwd@192.168.1.128:1080
#http_proxy = ntlm://user:passwd@192.168.1.128:2080
disable_log_color = false
log_file = ./frpc.log
log_level = error
log_max_days = 1
disable_log_color = false
#admin_addr = 127.0.0.1
#admin_port = 7400
#admin_user = admin
#admin_pwd = admin
#assets_dir = ./static
pool_count = 5
tcp_mux = true
#user = your_name
login_fail_exit = true
protocol = tcp
tls_enable = true
#tls_cert_file = client.crt
#tls_key_file = client.key
#tls_trusted_ca_file = ca.crt
#dns_server = 8.8.8.8
#start = ssh,dns
#heartbeat_interval = 30
#heartbeat_timeout = 90
#meta_var1 = 123
#meta_var2 = 234
udp_packet_size = 1500

[RDP]
type = tcp
local_ip = 127.0.0.1
local_port = 3389
remote_port = 5000

其他计算机如果还要穿透RDP,配置文件需要改为

[common]
server_addr = 222.222.222.222
server_port = 6001
privilege_token = 1234567890

[RDP2]
type = tcp
local_ip = 127.0.0.1
local_port = 3389
remote_port = 6000


测试方法

浏览器访问

http://222.222.222.222:33605  就可以看到内网的nginx默认页面


mstsc连接

222.222.222.222:6000 可以远程管理


本站所有文章均可随意转载,转载时请保留原文链接及作者。

本文链接:https://www.vos.cn/os/368.html

相关文章

修复升级EVE-NG后无法正常打开问题

修复升级EVE-NG后无法正常打开问题

升级流程Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.9.40-eve-ng-ukms+ x86_64) * Documentation:  ...

CentOS7 Samba配置

CentOS7 Samba配置

在RAID的基础上搭建samba服务提供文件共享参数介绍[global] workgroup = 工作组名称 server string = 服务...

CentOS7 NFS配置

CentOS7 NFS配置

网络文件系统(Network File System)是一种将远程主机上的分区(目录)经网络挂载到本地的一种机制,通过对网络文件系统的支持,用户可以在本地系统上像操作本地分区一样来对远程主机的共享分区...

CentOS6 安装Oracle11gR2

CentOS6 安装Oracle11gR2

使用oracle-rdbms-server-11gR2-preinstall工具,自动安装oracle所需的RPM包,自动创建oracle用户和dba、oinstall组,自动配置/etc/sysct...

RHEL6.5 + Oracle11g + RAC + ASM

RHEL6.5 + Oracle11g + RAC + ASM

实验环境操作系统:RedHat Enterprise Linux 6.5虚拟机:VMware-workstation 14.1.1数据库:Oracle Database11g 11.2.0.4存储:O...

CentOS 7转换为OEL 7

CentOS 7转换为OEL 7

参考官方提供的脚本,支持将CentOS 5, 6, 7转换为使用UEK(Unbreakable Enterprise Kernel)的Oracle Enterprise Linux转换系统curl&n...