├── frpc ├── images ├── 1.jpg ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── fw1.png └── fw2.png ├── frps.ini ├── frpc.ini └── README.md /frpc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pqguanyinli/frpc/HEAD/frpc -------------------------------------------------------------------------------- /images/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pqguanyinli/frpc/HEAD/images/1.jpg -------------------------------------------------------------------------------- /images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pqguanyinli/frpc/HEAD/images/2.png -------------------------------------------------------------------------------- /images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pqguanyinli/frpc/HEAD/images/3.png -------------------------------------------------------------------------------- /images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pqguanyinli/frpc/HEAD/images/4.png -------------------------------------------------------------------------------- /images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pqguanyinli/frpc/HEAD/images/5.png -------------------------------------------------------------------------------- /images/fw1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pqguanyinli/frpc/HEAD/images/fw1.png -------------------------------------------------------------------------------- /images/fw2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pqguanyinli/frpc/HEAD/images/fw2.png -------------------------------------------------------------------------------- /frps.ini: -------------------------------------------------------------------------------- 1 | [common] 2 | bind_port = 7000 #与客户端绑定的进行通信的端口 3 | vhost_http_port = 80 #服务器开放的用于客户端访问web服务的端口号,可修改 4 | vhost_https_port = 443 5 | dashboard_port = 7500 #用于客户端浏览器查看 frp 的状态的开放端口 方式:http://[server_addr]:7500 6 | dashboard_user = admin #用户名密码默认为 admin 7 | dashboard_pwd = admin 8 | token = 12345678 #身份验证 服务端和客户端的 common 配置中的 token 参数一致则身份验证通过 9 | -------------------------------------------------------------------------------- /frpc.ini: -------------------------------------------------------------------------------- 1 | [common] 2 | server_addr = xx.xx.xx.xx #公网服务器ip 3 | server_port = 7000 #与服务端bind_port一致 4 | token = 12345678 #身份验证 服务端和客户端的 common 配置中的 token 参数一致则身份验证通过 5 | 6 | [ssh] 7 | type = tcp #连接协议 8 | local_ip = 127.0.0.1 #内网服务器ip 9 | local_port = 22 #ssh默认端口号 10 | remote_port = 6000 #自定义的访问内部ssh端口号 11 | 12 | [router] 13 | type = http #访问协议 14 | local_ip = 192.168.10.1 #内网服务器ip 15 | local_port = 80 #内网web服务的端口号 16 | custom_domains = abc.yourdomain.com #所绑定的公网服务器域名,一级、二级域名都可以,绑定多个域名时用英文“,”分开 17 | 18 | [web] 19 | type = http #访问协议 20 | local_ip = 192.168.10.188 #内网服务器ip 21 | local_port = 80 #内网web服务的端口号 22 | custom_domains = def.yourdomain.com #所绑定的公网服务器域名,一级、二级域名都可以,绑定多个域名时用英文“,”分开 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## k2p启用frp客户端: 2 | 3 | 由于无灯版自带FRP是Xfrp版本,配置后无法使用,后发现网上小伙伴已经有解决办法。frpc frps.ini和frpc.ini 为本人自用。 4 | 5 | ### 1、将配置好的frpc.ini上传到K2P目录“/etc/storage” 6 | 7 | ### 2、高级设置-自定义设置-脚本-在 WAN 上行/下行启动后执行: 中加上以下代码 8 | ``` 9 | sleep 10 && wget -P /tmp http://opt.cn2qq.com/opt-file/frpc && chmod 777 /tmp/frpc 10 | 11 | /tmp/frpc -c /etc/storage/frpc.ini >/dev/null 2>&1 & 12 | ``` 13 | 或 14 | ``` 15 | sleep 10 && wget -P /tmp https://raw.githubusercontent.com/pqguanyinli/frpc/master/frpc && chmod 777 /tmp/frpc 16 | 17 | /tmp/frpc -c /etc/storage/frpc.ini >/dev/null 2>&1 & 18 | ``` 19 | ### 3、重启路由 20 | 21 | ## FRP内网穿透不到两分钟就学会及扩展运用,轻松实现外网访问esxi后台管理界面、lede软路由后台、群晖NAS及ds photo登录 22 | 23 | frp内网穿透比ngrok要简单的多,无需多复杂的配置就可以达到比较好的穿透效果,扩展性也很强。 24 | 25 | 注意:用国内服务器搭建,需要域名备案才能使用 26 | 27 | ### 一、frp的作用 28 | 29 | 利用处于内网或防火墙后的机器,对外网环境提供 http 或 https 服务。 30 | 31 | 对于 http, https 服务支持基于域名的虚拟主机,支持自定义域名绑定,使多个域名可以共用一个80端口。 32 | 33 | 利用处于内网或防火墙后的机器,对外网环境提供 tcp 和 udp 服务,例如在家里通过 ssh 访问处于公司内网环境内的主机 34 | 35 | ### 二、配置说明 36 | 37 | 1、实现功能 38 | 39 | (1)外网通过ssh访问内网机器 40 | 41 | (2)自定义绑定域名访问内网web服务 42 | 43 | 2、配置前准备 44 | 45 | (1)公网服务器1台 46 | 47 | (2)内网服务器1台 48 | 49 | (3)公网服务器绑定域名1个 50 | 51 | (4)内网服务器部署一个web服务 52 | 53 | ### 三、安装frp 54 | 1、公网服务器与内网服务器都需要下载frp进行安装 55 | 56 | 2、下载地址是https://github.com/fatedier/frp/releases 57 | 58 | 也可以通过命令下载: 59 | ``` 60 | wget https://github.com/fatedier/frp/releases/download/v0.33.0/frp_0.33.0_linux_amd64.tar.gz 61 | ``` 62 | 3.在WINDOWS下用winscp软件登录,上传frp_0.33.0_linux_amd64.tar.gz至root目录 63 | 64 | 4.解压文件: 65 | ``` 66 | tar -zxvf frp_0.33.0_linux_amd64.tar.gz 67 | ``` 68 | 5.进入解压目录: 69 | ``` 70 | cd frp_0.33.0_linux_amd64 71 | ``` 72 | frps、frps.ini这个两个是服务端文件,frpc、frpc.ini这两个是客户端文件 73 | 74 | 6.配置服务端: 75 | ``` 76 | vi ./frps.ini 77 | ``` 78 | ``` 79 | [common] 80 | bind_port = 7000 #与客户端绑定的进行通信的端口 81 | vhost_http_port = 80 #访问客户端web服务自定义的端口号 82 | vhost_https_port = 443 83 | ``` 84 | 按”i”键进行编辑,按“esc”退出编辑状态,输入“:wq”退出 85 | 86 | ### 四、启动服务端 87 | 88 | 首先设置frps可执行权限 89 | 90 | chmod +x ./frps 91 | 92 | 临时启动 93 | ``` 94 | ./frps -c ./frps.ini 95 | ``` 96 | 后台保持启动 97 | ``` 98 | nohup ./frps -c ./frps.ini & 99 | ``` 100 | ### 五、配置客户端 101 | ``` 102 | vi ./frpc.ini 103 | ``` 104 | ``` 105 | [common] 106 | server_addr = 120.56.37.48 #公网服务器ip 107 | server_port = 7000 #与服务端bind_port一致 108 | 109 | #公网通过ssh访问内部服务器 110 | [ssh] 111 | type = tcp #连接协议 112 | local_ip = 127.0.0.1 #内网服务器ip 113 | local_port = 22 #ssh默认端口号 114 | remote_port = 6000 #自定义的访问内部ssh端口号 115 | 116 | #公网访问内部web服务器以http方式 117 | [web] 118 | type = http #访问协议 119 | local_ip = 127.0.0.1 #内网服务器ip 120 | local_port = 80 #内网web服务的端口号 121 | custom_domains = www.veelove.cn,veelove.cn 122 | #所绑定的公网服务器域名,一级、二级域名都可以,绑定多个域名时用英文“,”分开 123 | ``` 124 | ### 六、启动客户端 125 | 126 | 首先设置frpc可执行权限 127 | 128 | chmod +x ./frpc 129 | 130 | 临时启动 131 | ``` 132 | ./frpc -c ./frpc.ini 133 | ``` 134 | 后台保持启动 135 | ``` 136 | nohup ./frpc -c ./frpc.ini & 137 | ``` 138 | ### 七、穿透公司代理内网 139 | 140 | 1.修改服务端配置文件 141 | ``` 142 | vi ./frps.ini 143 | ``` 144 | ``` 145 | [common] 146 | bind_port = 443 #端口号修改为443 147 | vhost_http_port = 80 #访问客户端web服务自定义的端口号 148 | ``` 149 | 2.修改客户端配置文件 150 | ``` 151 | vi ./frpc.ini 152 | ``` 153 | ``` 154 | [common] 155 | server_addr = 118.24.127.138 156 | server_port = 443 #端口号修改为443 157 | http_proxy = http://10.168.57.241:8088 #加入公司代理地址 158 | 159 | [ssh] 160 | type = tcp 161 | local_ip = 127.0.0.1 162 | local_port = 22 163 | remote_port = 6000 164 | 165 | [web] 166 | type = http 167 | local_ip = 127.0.0.1 168 | local_port = 80 169 | custom_domains = www.veelove.cn 170 | ``` 171 | 服务端与客户端启动方式不变,参照四、六。 172 | 173 | ### 八、群晖NAS使用frp穿透服务 174 | 175 | ①.设置ROOT密码,获取群晖的ROOT权限 176 | 177 | 1.打开控制面板,开启SSH功能 178 | 179 | ![image](https://github.com/pqguanyinli/frpc/blob/master/images/1.jpg) 180 | 181 | 2.终端输入命令ssh admin@192.168.1.201登录,密码为群辉NAS的用户密码(地址修改为自己的NAS地址,win用户用Putty这个软件登录) 182 | 183 | ![image](https://github.com/pqguanyinli/frpc/blob/master/images/2.png) 184 | 185 | 3.输入命令 186 | ``` 187 | sudo -i 188 | ``` 189 | 4.设置root密码 190 | ``` 191 | synouser --setpw root XXX 192 | ``` 193 | 【XXX便是你要修改的密码】 194 | 195 | ②.客户端调试 196 | 197 | 1.使用root用户登录群晖6.1 198 | ``` 199 | ssh root@192.168.1.201 200 | ``` 201 | (地址修改为自己的群晖NAS地址) 202 | 203 | 2.群晖NAS登陆后台配置文件 204 | ``` 205 | [common] 206 | server_addr = 118.24.127.138 207 | server_port = 7000 208 | 209 | [ssh] 210 | type = tcp 211 | local_ip = 127.0.0.1 212 | local_port = 22 213 | remote_port = 6000 214 | 215 | [nasweb] 216 | type = http 217 | local_ip = 127.0.0.1 218 | local_port = 5000 #群晖NAS登陆地址端口是5000 219 | custom_domains = nas.veelove.cn 220 | ``` 221 | 2.使用群晖NAS手机APP的DS photo软件在外网访问配置文件 222 | ``` 223 | [common] 224 | server_addr = 118.24.127.138 225 | server_port = 7000 226 | 227 | [ssh] 228 | type = tcp 229 | local_ip = 127.0.0.1 230 | local_port = 22 231 | remote_port = 6000 232 | 233 | [nasweb] 234 | type = http 235 | local_ip = 127.0.0.1 236 | local_port = 5000 #群晖NAS登陆地址端口是5000 237 | custom_domains = nas.veelove.cn 238 | 239 | [nasphoto] 240 | type = tcp #协议为TCP协议 241 | local_ip = 127.0.0.1 242 | local_port = 80 243 | remote_port = 8000 #需要做一个端口转发才可以实现APP登陆,端口自定义 244 | custom_domains = photo.veelove.cn 245 | ``` 246 | ### 九、外网访问esxi后台管理、群晖NAS、群晖NAS客户端DS Photo、LEDE软路由后台 247 | ``` 248 | [common] 249 | server_addr = 118.24.127.138 #更换为自己服务器IP地址 250 | server_port = 7000 251 | 252 | [lede] 253 | type = http #协议为http 254 | local_ip = 192.168.1.1 #保持不变,如果您更换过lede后台地址,请自行修改 255 | local_port = 80 256 | custom_domains = lede.veelove.cn #更换为自己的域名 257 | 258 | [esxi] 259 | type = https #协议为https 260 | local_ip = 192.168.1.101 #更换为自己esxi后台管理地址 261 | local_port = 443 262 | custom_domains = esxi.veelove.cn #更换为自己的域名 263 | 264 | [dsphoto] 265 | type = tcp #协议为tcp 266 | local_ip = 127.0.0.1 267 | local_port = 80 268 | remote_port = 8000 #转发端口可以自己设定 269 | custom_domains = photo.veelove.cn #更换为自己的域名 270 | 271 | [dsm] 272 | type = http #协议为http 273 | local_ip = 127.0.0.1 274 | local_port = 5000 275 | custom_domains = nas.veelove.cn #更换为自己的域名 276 | ``` 277 | ### 十、用谷歌云和vultr服务器搭建frp无法使用 需要开放7000端口 278 | 279 | (一)首先检查某端口是否开启: 280 | ``` 281 | firewall-cmd --query-port=80/tcp --zone=public #查询80端口是否开启,自行修改端口号 282 | ``` 283 | 返回no即未开启,显示yes为已开启。 284 | 285 | (二)开启某端口代码 286 | ``` 287 | firewall-cmd --zone=public --add-port=80/tcp --permanent #添加80端口,如需添加其他端口,自行修改端口号 288 | ``` 289 | 修改完成后需要重启服务器才能生效 290 | 291 | (三)如果出现FirewallD is not running 292 | 293 | 1.查看防火墙状态 294 | ``` 295 | systemctl status firewalld 296 | ``` 297 | 有如下提示表示未开启 298 | 299 | ![image](https://github.com/pqguanyinli/frpc/blob/master/images/fw1.png) 300 | 301 | 2.开启防火墙,没有任何提示即开启成功 302 | ``` 303 | systemctl start firewalld 304 | ``` 305 | 3.再次查看防火墙状态 306 | ``` 307 | systemctl status firewalld 308 | ``` 309 | 有如下提示表示已经开启成功 310 | 311 | ![image](https://github.com/pqguanyinli/frpc/blob/master/images/fw2.png) 312 | 313 | 4.关闭防火墙 314 | ``` 315 | systemctl stop firewalld 316 | ``` 317 | ### 十一、如何让Frp在群晖中自动开机运行 318 | 319 | 1.进入群晖控制面板》任务计划》新增》触发任务》用户定义的脚本 320 | 321 | ![image](https://github.com/pqguanyinli/frpc/blob/master/images/3.png) 322 | 323 | 2.添加脚本 324 | ``` 325 | /root/frp/frpc -c /root/frp/frpc.ini 326 | ``` 327 | 上面的frp修改为你frp目录的文件名称,我在视频里面建议是修改为frp方便记忆 328 | 329 | ![image](https://github.com/pqguanyinli/frpc/blob/master/images/4.png) 330 | 331 | 3.按照下图的序号号顺序操作,重启群晖NAS即可 332 | 333 | ![image](https://github.com/pqguanyinli/frpc/blob/master/images/5.png) 334 | 335 | ## 扩展: Debian 9/Ubuntu 17+添加rc.local开机自启的方法 336 | 337 | 说明:很多时候有些程序或者脚本都需要添加开机自启,最简单的方法就是使用rc.local自启,不过由于系统版本更替, 338 | 339 | 很多新版本系统都没有rc.local文件了,比如Debian 9、Ubuntu 17.10、Ubuntu 18.04。这时候就需要我们手动设置下。 340 | 341 | 方法: 342 | 343 | ### 1、添加rc-local.service 344 | ``` 345 | #以下为一整条命令,一起复制运行 346 | cat > /etc/systemd/system/rc-local.service < /etc/rc.local < k2p路由器frpc最新客户端下载:http://opt.cn2qq.com/opt-file/frpc 407 | > 408 | > frp 官方使用详细说明:https://github.com/fatedier/frp/blob/master/README_zh.md 409 | > 410 | > frp官方下载地址:https://github.com/fatedier/frp/releases 411 | ## 412 | --------------------------------------------------------------------------------