内网穿透工具 FRP Linux 环境搭建安装

公网服务端设置

1、先确定公网服务端linux系统版本

通过 getconf LONG_BIT Linux查看系统位数命令:返回的结果如果是64,说明linux系统属于64位;返回32,系统属于32位。

[root@VM_0_6_centos ~]# getconf LONG_BIT
64

由此我们可以看出我们的公网服务端系统属于LINUX的64位操作系统,接下来进行第二步到FRP项目软件包处下载相对于的安装包即可。

2、下载相匹配FRP版本

通过 FRP 项目软件包下载地址:Releases · fatedier/frp · GitHub

通过上面的操作,最终我们选择 frp_0.30.0_linux_amd64.tar.gz (说明:FRP V0.30.0 版本 linux 系统 ADM64位操作系统)

wget https://github.com/fatedier/frp/releases/download/v0.30.0/frp_0.30.0_linux_amd64.tar.gz && tar xzvf frp_0.30.0_linux_amd64.tar.gz && mv frp_0.30.0_linux_amd64 frp

上面命令包含直接通过GitHub下载后,解压后将目录重命名为 frp

自动解压完输入 【cd ./frp】 进入FRP目录

3、设置公网服务端配置文件 frps.ini

[common]
bind_port = 7000

# vhost_http_port 参数来设置 HTTP 访问端口,此处示例:8090
vhost_http_port = 8090

# subdomain_host 参数来设置  Web 服务增加自定义二级域名
# 将泛域名 *.frp.xxx.com 解析到 frps 所在公网服务器的 IP 地址
subdomain_host = frp.xxx.com

# FRP 身份验证
token = xxx

# 指定 Dashboard 的监听的 IP 地址 0.0.0.0
dashboard_addr = 0.0.0.0

# FRPS 服务端 仪表盘 dashboard 登陆端口
dashboard_port = 7500

# FRPS 服务端 仪表盘 dashboard 登陆用户名、密码
dashboard_user = admin
dashboard_pwd = admin123


# 设置日志显示级别{debug, info, warn, error)
log_level = info

# 设置日志最大天数
log_max_days = 999

[root@VM_0_6_centos frp]# 

之后我们就可以运行frps的服务端了

./frps -c frps.ini

如果看到屏幕输出这样一段内容,即表示运行正常,如果出现错误提示,请检查上面的步骤。

[root@VM_0_6_centos frp]# ./frps -c ./frps.ini
2021/10/20 09:31:56 [I] [service.go:141] frps tcp listen on 0.0.0.0:7000
2021/10/20 09:31:56 [I] [service.go:183] http service listen on 0.0.0.0:8090
2021/10/20 09:31:56 [I] [service.go:240] Dashboard listen on 0.0.0.0:7500
2021/10/20 09:31:56 [I] [root.go:205] start frps success

出现【Start frps success】代表运行成功

此时访问 x.x.x.x:7500 并使用自己设置的用户名密码登录,即可看到仪表板界面

服务端后台运行

至此,我们的服务端仅运行在前台,如果Ctrl+C停止或者关闭SSH窗口后,frps 均会停止运行,因而我们使用 nohup命令将其运行在后台。

nohup后台程序管理或关闭相关命令可自行查询资料,上面这个连接中也有所提及。

[root@VM_0_6_centos frp]# nohup ./frps -c frps.ini &
[1] 446
[root@VM_0_6_centos frp]# nohup: ignoring input and appending output to ‘nohup.out’

显示【nohup: ignoring input and appending output to 'nohup.out'】内容即表示正常运行。

此时可先使用 Ctrl+C 关闭nohup,frps依然会在后台运行,使用 jobs 命令查看后台运行的程序

root@U-NAS:~/frp#  jobs
[1]+  Running                 nohup ./frpc -c frpc.ini &

在结果中我们可以看到 frpc 正在后台正常运行

此时访问 x.x.x.x:7500 依然可以打开仪表板界面,至此,服务端即设置完成,你可以关闭SSH窗口了。

其他服务端命令

##  停止 frps 

root@U-NAS:~/frp# ps -ef |grep frpc|grep -v grep |awk '{print $2}'|xargs kill -9

内网客户端设置

1、先确定内网客户端linux系统版本

通过 getconf LONG_BIT Linux查看系统位数命令:返回的结果如果是64,说明linux系统属于64位;返回32,系统属于32位。

root@U-NAS:~/frp# getconf LONG_BIT
64

由此我们可以看出我们的公网服务端系统属于LINUX的64位操作系统,接下来进行第二步到FRP项目软件包处下载相对于的安装包即可。

2、下载相匹配FRP版本

通过 FRP 项目软件包下载地址:Releases · fatedier/frp · GitHub

通过上面的操作,最终我们选择 frp_0.30.0_linux_amd64.tar.gz (说明:FRP V0.30.0 版本 linux 系统 ADM64位操作系统)

wget https://github.com/fatedier/frp/releases/download/v0.30.0/frp_0.30.0_linux_amd64.tar.gz && tar xzvf frp_0.30.0_linux_amd64.tar.gz && mv frp_0.30.0_linux_amd64 frp

上面命令包含直接通过GitHub下载后,解压后将目录重命名为 frp

自动解压完输入 【cd ./frp】 进入FRP目录

3、设置内网服务端配置文件 frpc.ini

假设服务器地址: frp.xxx.com

token = xxx (实际token请参考 frps.ini 中 token 对应参数)

自定义域名前缀为 :abc

http端口为 8090

内网客户端配置文件:frpc.ini

[common]
# 公网服务端 ip 或 域名
server_addr = frp.xxx.com

# 公网服务端 设置的端口
server_port = 7000

# FRP 身份验证 与 服务端一致
token = xxx

# frpc.ini 管理界面 //127.0.0.1 地址为仅限本地,0.0.0.0为不限。
admin_addr = 127.0.0.1
admin_port = 7400
admin_user = admin
admin_pwd = admin123

# 
# ------------------- 以下为内网端口穿透应用 -------------------
# 


# [ssh]示例中 链接ssh 使用 root@frp.xxx.com -p 6090
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6090


# [web_abc] 示例中 访问本地web:abc.frp.xxx.com:8090
# 8090端口,服务端 frps.ini 配置文件,中 vhost_http_port 参数

[web_abc]
type = http
local_ip = 127.0.0.1
local_port = 80
subdomain = abc



# 自定义域名,将 custom_domains = www.666.com 配置的域名解析至 server_addr = frp.xxx.com
# [web_www.666.com]假设自己有完整域名 www.666.com ,www.666.com 做CNAME到 frp.xxx.com 后可以直接访问 www.666.com:888

[web_www.666.com]
type = http
local_ip = 127.0.0.1
local_port = 80
custom_domains = www.666.com

[root@VM_0_6_centos frp]# 

特别提示

# FRP 身份验证
token = xxx

服务端与客户端要设置一致,否则无法链接FRP

之后我们就可以运行 frpc 的客户端

./frpc -c frpc.ini

如果看到屏幕输出这样一段内容,即表示运行正常,如果出现错误提示,请检查上面的步骤。

root@U-NAS:~/frp# ./frpc -c frpc.ini
2021/10/20 12:45:17 [I] [service.go:249] [c83f619b7e259508] login to server success, get run id [c83f619b7e259508], server udp port [0]
2021/10/20 12:45:17 [I] [proxy_manager.go:144] [c83f619b7e259508] proxy added: [web_7888 web_abc ssh]
2021/10/20 12:45:17 [I] [service.go:130] admin server listen on 127.0.0.1:7400
2021/10/20 12:45:17 [I] [control.go:164] [c83f619b7e259508] [web_7888] start proxy success
2021/10/20 12:45:17 [I] [control.go:164] [c83f619b7e259508] [web_abc] start proxy success
2021/10/20 12:45:17 [I] [control.go:164] [c83f619b7e259508] [ssh] start proxy success

出现【Start frps success】代表运行成功

此时访问 x.x.x.x:7400 并使用自己设置的用户名密码登录,即可看到仪表板界面

客户端后台运行

至此,我们的服务端仅运行在前台,如果Ctrl+C停止或者关闭SSH窗口后,frps 均会停止运行,因而我们使用 nohup命令 将其运行在后台。

nohup后台程序管理或关闭相关命令可自行查询资料,上面这个连接中也有所提及。

root@U-NAS:~/frp# nohup ./frpc -c frpc.ini &
[1] 17465
root@U-NAS:~/frp# nohup: ignoring input and appending output to 'nohup.out'

显示【nohup: ignoring input and appending output to 'nohup.out'】内容即表示正常运行。

此时可先使用 Ctrl+C 关闭nohup,frps依然会在后台运行,使用 jobs 命令查看后台运行的程序

[root@VM_0_6_centos frp]# jobs
[1]+  Running                 nohup ./frpc -c frpc.ini &

在结果中我们可以看到frps正在后台正常运行

此时访问 x.x.x.x:7400 依然可以打开仪表板界面,至此,客户端即设置完成,你可以关闭SSH窗口了。

其他服务端命令

## 停止 frpc

root@U-NAS:~/frp# ps -ef |grep frpc|grep -v grep |awk '{print $2}'|xargs kill -9
本处高能:因Frp作者更换新的模块,导致Frp v0.18.0与之前的版本不兼容,如果升级请服务器端同步升级。升级命令: wget --no-check-certificate https://raw.githubusercontent.com/clangcn/onekey-install-shell/master/frps/install-frps.sh -O ./install-frps.sh bash install-frps.sh update 首先感谢@sadoneli S大的帮助完成了frp插件web页面的制作。 WARNING:请仔细阅读完本教程1楼和2楼后再动手安装frp 是一个高性能的反向代理应用,可以帮助您轻松地进行内网穿透,对外网提供服务,支持 tcp, http, https 等协议类型,并且 web 服务支持根据域名进行路由转发。 *因为frp是go语言写的,所以在路由器上使用的时候,请使用虚拟内存,请使用虚拟内存,请使用虚拟内存。 脚本是业余爱好,英文属于文盲,写的不好,欢迎您批评指正。 安装平台:CentOS、Debian、Ubuntu。 已测试过的平台: CentOS 6 32/64bit CentOS 7 32/64bit Debian 6 32/64bit Debian 7 32/64bit Debian 8 32/64bit Ubuntu 14 32/64bit 一、安装命令这个命令是在你自己的服务器上运行的!是在你自己的服务器上运行的!是在你自己的服务器上运行的!不是在路由器里运行的!不是在路由器里运行的!不是在路由器里运行的! wget --no-check-certificate https://raw.githubusercontent.com/clangcn/onekey-install-shell/master/frps/install-frps.sh -O ./install-frps.sh chmod 700 ./install-frps.sh ./install-frps.sh install 二、安装步骤 Loading network version for frps, please wait... frps Latest release file frp_0.8.1_linux_amd64.tar.gz #此步骤会自动获取frp最新版本,自动操作,无需理会 Loading You Server IP, please wait... You Server IP:12.12.12.12 #自动获取你服务器的IP地址 Please input your server setting: Please input frps bind_port [1-65535](Default Server Port: 5443): #输入frp提供服务的端口,用于服务器端和客户端通信 Please input frps dashboard_port [1-65535](Default dashboard_port: 6443): #输入frp的控制台服务端口,用于查看frp工作状态 Please input frps vhost_http_port [1-65535](Default vhost_http_port: 80): #输入frp进行http穿透的http服务端口 Please input frps vhost_https_port [1-65535](Default vhost_https_port: 443): #输入frp进行https穿透的https服务端口 Please input privilege_token (Default: WEWLRgwRjIJVPx2kuqzkGnvuftPLQniq): #输入frp服务器和客户端通信的密码,默认是随机生成的 Please input frps max_pool_count [1-200](Default max_pool_count: 50): #设置每个代理可以创建的连接池上限,默认50 ##### Please select log_level ##### 1: info 2: warn 3: error 4: debug ##################################################### Enter your choice (1, 2, 3, 4 or exit. default [1]): #设置日志等级,4个选项,默认是info Please input frps log_max_days [1-30] (Default log_max_days: 3 day): #设置日志保留天数,范围是1到30天,默认保留3天。 ##### Please select log_file ##### 1: enable 2: disable ##################################################### Enter your choice (1, 2 or exit. default [1]): #设置是否开启日志记录,默认开启,开启后日志等级及保留天数生效,否则等级和保留天数无效 设置完成后检查你的输入,如果没有问题按任意键继续安装 ============== Check your input ============== You Server IP : 12.12.12.12 Bind port : 5443 Dashboard port : 6443 vhost http port : 80 vhost https port: 443 Privilege token : WEWLRgwRjIJVPx2kuqzkGnvuftPLQniq Max Pool count : 50 Log level : info Log max days : 3 Log file : enable ============================================== 安装结束后显示: Congratulations, frps install completed! ============================================== You Server IP : 12.12.12.12 Bind port : 5443 Dashboard port : 6443 vhost http port : 80 vhost https port: 443 Privilege token : WEWLRgwRjIJVPx2kuqzkGnvuftPLQniq Max Pool count : 50 Log level : info Log max days : 3 Log file : enable # 将上面信息添加到你的路由器frp穿透插件中吧 ============================================== frps Dashboard: http://12.12.12.12:6443/ # 这个是frp控制台访问地址 ============================================== 三、更新命令 ./install-frps.sh update 四、卸载命令 ./install-frps.sh uninstall 五、服务器端管理命令 /etc/init.d/frps start /etc/init.d/frps stop /etc/init.d/frps restart /etc/init.d/frps status /etc/init.d/frps config /etc/init.d/frps version 七、更多帮助请移步官方帮助文件 https://github.com/fatedier/frp/blob/master/README_zh.md
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值