穿透工具frp
下载安装
按照官网压缩包解压后的文件列表如下
frpc
frpc.ini
frpc_min.ini
frps
frps.ini
frps_min.ini
LICENSE
首先明晰一下哪个是服务端,哪个是客户端。处于公网的计算机是服务端,处于内网的计算机是服务端。服务端的配置较为简单,只需要指定与客户端通信的端口号和密码即可,客户端除了需要设置与服务端相同的端口号和密码以外,还需要针对不同的服务设定不同的端口号。
服务端只用到frps、frps.ini、frps_min.ini三个文件。
客户端只用到frpc、frpc.ini、frpc_min.ini三个文件。
服务端配置
# [common] is integral section
[common]
# A literal address or host name for IPv6 must be enclosed
# in square brackets, as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80"
bind_addr = 0.0.0.0
bind_port = 7000
# if you want to support virtual host, you must set the http port for listening (optional)
vhost_http_port = 4060
vhost_https_port = 4441
# if you want to configure or reload frps by dashboard, dashboard_port must be set
dashboard_port = 7500
# dashboard user and pwd for basic auth protect, if not set, both default value is admin
dashboard_user = admin
dashboard_pwd = admin
# dashboard assets directory(only for debug mode)
# assets_dir = ./static
# console or real logFile path like ./frps.log
log_file = ./frps.log
# trace, debug, info, warn, error
log_level = info
log_max_days = 3
# privilege mode is the only supported mode since v0.10.0
privilege_token = your password
# heartbeat configure, it's not recommended to modify the default value
# the default value of heartbeat_timeout is 90
# heartbeat_timeout = 90
# only allow frpc to bind ports you list, if you set nothing, there won't be any limit
privilege_allow_ports = 2000-3000,3001,3003,4000-50000
# pool_count in each proxy will change to max_pool_count if they exceed the maximum value
max_pool_count = 5
# authentication_timeout means the timeout interval (seconds) when the frpc connects frps
# if authentication_timeout is zero, the time is not verified, default is 900s
authentication_timeout = 900
# if subdomain_host is not empty, you can set subdomain when type is http or https in frpc's configure file
# when subdomain is test, the host used by routing is test.frps.com
subdomain_host = frps.com
# if tcp stream multiplexing is used, default is true
tcp_mux = true
其中bind_port = 7000为服务器与server通信的端口,这个用户用不到。
privilege_token = your password,这个密码配合7000端口,需要server和client一致。
dashboard_port = 7500是控制面板的端口,可以在浏览器内输入:服务器ip:7500。来访问frp的控制面板。dashboard_user = admin,dashboard_pwd = admin,像登陆路由器一样,访问控制面板是要输入密码的,默认用户名和密码都是admin。
客户端配置
客户端分为两个部分配置,首先是common部分,端口、密码需要和服务端配置相同。服务端的common中bind_addr = 0.0.0.0指的是对所有地址都进行监听,服务端的server_addr需要设置成服务器的IP。
[common]
sserver_addr = 服务器的IP
server_port = 7000
privilege_token = your password
其次需要设置的是每个任务的转发方式,以ssh为例
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
local_ip设置为127.0.0.1是指将来自远程计算机的转发请求转给自己。如果内网可以看到其他计算机完全可以转发到其他计算机上。
remote_port=6000是指用户访问服务端计算机的6000端口即相当于访问local_ip的local_port。